Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / sync_file_system / local / syncable_file_system_operation.h
blob5903f5e6ae7c58f5603cffa4689a34a04f769982
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "storage/browser/fileapi/file_system_operation.h"
16 #include "storage/browser/fileapi/file_system_url.h"
18 namespace storage {
19 class FileSystemContext;
20 class FileSystemOperationContext;
23 namespace sync_file_system {
25 class SyncableFileOperationRunner;
27 // A wrapper class of FileSystemOperation for syncable file system.
28 class SyncableFileSystemOperation
29 : public NON_EXPORTED_BASE(storage::FileSystemOperation),
30 public base::NonThreadSafe {
31 public:
32 ~SyncableFileSystemOperation() override;
34 // storage::FileSystemOperation overrides.
35 void CreateFile(const storage::FileSystemURL& url,
36 bool exclusive,
37 const StatusCallback& callback) override;
38 void CreateDirectory(const storage::FileSystemURL& url,
39 bool exclusive,
40 bool recursive,
41 const StatusCallback& callback) override;
42 void Copy(const storage::FileSystemURL& src_url,
43 const storage::FileSystemURL& dest_url,
44 CopyOrMoveOption option,
45 ErrorBehavior error_behavior,
46 const CopyProgressCallback& progress_callback,
47 const StatusCallback& callback) override;
48 void Move(const storage::FileSystemURL& src_url,
49 const storage::FileSystemURL& dest_url,
50 CopyOrMoveOption option,
51 const StatusCallback& callback) override;
52 void DirectoryExists(const storage::FileSystemURL& url,
53 const StatusCallback& callback) override;
54 void FileExists(const storage::FileSystemURL& url,
55 const StatusCallback& callback) override;
56 void GetMetadata(const storage::FileSystemURL& url,
57 const GetMetadataCallback& callback) override;
58 void ReadDirectory(const storage::FileSystemURL& url,
59 const ReadDirectoryCallback& callback) override;
60 void Remove(const storage::FileSystemURL& url,
61 bool recursive,
62 const StatusCallback& callback) override;
63 void Write(const storage::FileSystemURL& url,
64 scoped_ptr<storage::FileWriterDelegate> writer_delegate,
65 scoped_ptr<net::URLRequest> blob_request,
66 const WriteCallback& callback) override;
67 void Truncate(const storage::FileSystemURL& url,
68 int64 length,
69 const StatusCallback& callback) override;
70 void TouchFile(const storage::FileSystemURL& url,
71 const base::Time& last_access_time,
72 const base::Time& last_modified_time,
73 const StatusCallback& callback) override;
74 void OpenFile(const storage::FileSystemURL& url,
75 int file_flags,
76 const OpenFileCallback& callback) override;
77 void Cancel(const StatusCallback& cancel_callback) override;
78 void CreateSnapshotFile(const storage::FileSystemURL& path,
79 const SnapshotFileCallback& callback) override;
80 void CopyInForeignFile(const base::FilePath& src_local_disk_path,
81 const storage::FileSystemURL& dest_url,
82 const StatusCallback& callback) override;
83 void RemoveFile(const storage::FileSystemURL& url,
84 const StatusCallback& callback) override;
85 void RemoveDirectory(const storage::FileSystemURL& url,
86 const StatusCallback& callback) override;
87 void CopyFileLocal(const storage::FileSystemURL& src_url,
88 const storage::FileSystemURL& dest_url,
89 CopyOrMoveOption option,
90 const CopyFileProgressCallback& progress_callback,
91 const StatusCallback& callback) override;
92 void MoveFileLocal(const storage::FileSystemURL& src_url,
93 const storage::FileSystemURL& dest_url,
94 CopyOrMoveOption option,
95 const StatusCallback& callback) override;
96 base::File::Error SyncGetPlatformPath(const storage::FileSystemURL& url,
97 base::FilePath* platform_path) override;
99 private:
100 typedef SyncableFileSystemOperation self;
101 class QueueableTask;
103 // Only SyncFileSystemBackend can create a new operation directly.
104 friend class SyncFileSystemBackend;
106 SyncableFileSystemOperation(
107 const storage::FileSystemURL& url,
108 storage::FileSystemContext* file_system_context,
109 scoped_ptr<storage::FileSystemOperationContext> operation_context);
111 void DidFinish(base::File::Error status);
112 void DidWrite(const WriteCallback& callback,
113 base::File::Error result,
114 int64 bytes,
115 bool complete);
117 void OnCancelled();
119 const storage::FileSystemURL url_;
121 scoped_ptr<storage::FileSystemOperation> impl_;
122 base::WeakPtr<SyncableFileOperationRunner> operation_runner_;
123 std::vector<storage::FileSystemURL> target_paths_;
125 StatusCallback completion_callback_;
127 base::WeakPtrFactory<SyncableFileSystemOperation> weak_factory_;
129 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation);
132 } // namespace sync_file_system
134 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_