Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1615)

Side by Side Diff: webkit/fileapi/file_system_operation.h

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 25 matching lines...) Expand all
36 namespace fileapi { 36 namespace fileapi {
37 37
38 class FileSystemCallbackDispatcher; 38 class FileSystemCallbackDispatcher;
39 class FileSystemContext; 39 class FileSystemContext;
40 class FileWriterDelegate; 40 class FileWriterDelegate;
41 class FileSystemOperationTest; 41 class FileSystemOperationTest;
42 42
43 // FileSystemOperation implementation for local file systems. 43 // FileSystemOperation implementation for local file systems.
44 class FileSystemOperation : public FileSystemOperationInterface { 44 class FileSystemOperation : public FileSystemOperationInterface {
45 public: 45 public:
46 // |dispatcher| will be owned by this class. 46 FileSystemOperation(scoped_ptr<FileSystemCallbackDispatcher> dispatcher,
47 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher,
48 scoped_refptr<base::MessageLoopProxy> proxy, 47 scoped_refptr<base::MessageLoopProxy> proxy,
49 FileSystemContext* file_system_context); 48 FileSystemContext* file_system_context);
50 virtual ~FileSystemOperation(); 49 virtual ~FileSystemOperation();
51 50
52 // FileSystemOperation overrides. 51 // FileSystemOperation overrides.
53 virtual void OpenFileSystem(const GURL& origin_url,
54 fileapi::FileSystemType type,
55 bool create) OVERRIDE;
56 virtual void CreateFile(const GURL& path, 52 virtual void CreateFile(const GURL& path,
57 bool exclusive) OVERRIDE; 53 bool exclusive) OVERRIDE;
58 virtual void CreateDirectory(const GURL& path, 54 virtual void CreateDirectory(const GURL& path,
59 bool exclusive, 55 bool exclusive,
60 bool recursive) OVERRIDE; 56 bool recursive) OVERRIDE;
61 virtual void Copy(const GURL& src_path, 57 virtual void Copy(const GURL& src_path,
62 const GURL& dest_path) OVERRIDE; 58 const GURL& dest_path) OVERRIDE;
63 virtual void Move(const GURL& src_path, 59 virtual void Move(const GURL& src_path,
64 const GURL& dest_path) OVERRIDE; 60 const GURL& dest_path) OVERRIDE;
65 virtual void DirectoryExists(const GURL& path) OVERRIDE; 61 virtual void DirectoryExists(const GURL& path) OVERRIDE;
66 virtual void FileExists(const GURL& path) OVERRIDE; 62 virtual void FileExists(const GURL& path) OVERRIDE;
67 virtual void GetMetadata(const GURL& path) OVERRIDE; 63 virtual void GetMetadata(const GURL& path) OVERRIDE;
68 virtual void ReadDirectory(const GURL& path) OVERRIDE; 64 virtual void ReadDirectory(const GURL& path) OVERRIDE;
69 virtual void Remove(const GURL& path, bool recursive) OVERRIDE; 65 virtual void Remove(const GURL& path, bool recursive) OVERRIDE;
70 virtual void Write(const net::URLRequestContext* url_request_context, 66 virtual void Write(const net::URLRequestContext* url_request_context,
71 const GURL& path, 67 const GURL& path,
72 const GURL& blob_url, 68 const GURL& blob_url,
73 int64 offset) OVERRIDE; 69 int64 offset) OVERRIDE;
74 virtual void Truncate(const GURL& path, int64 length) OVERRIDE; 70 virtual void Truncate(const GURL& path, int64 length) OVERRIDE;
75 virtual void TouchFile(const GURL& path, 71 virtual void TouchFile(const GURL& path,
76 const base::Time& last_access_time, 72 const base::Time& last_access_time,
77 const base::Time& last_modified_time) OVERRIDE; 73 const base::Time& last_modified_time) OVERRIDE;
78 virtual void OpenFile( 74 virtual void OpenFile(
79 const GURL& path, 75 const GURL& path,
80 int file_flags, 76 int file_flags,
81 base::ProcessHandle peer_handle) OVERRIDE; 77 base::ProcessHandle peer_handle) OVERRIDE;
78 virtual void Cancel(
79 scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher) OVERRIDE;
82 80
83 // Synchronously gets the platform path for the given |path|. 81 // Synchronously gets the platform path for the given |path|.
84 void SyncGetPlatformPath(const GURL& path, FilePath* platform_path); 82 void SyncGetPlatformPath(const GURL& path, FilePath* platform_path);
85 83
86 // Try to cancel the current operation [we support cancelling write or
87 // truncate only]. Report failure for the current operation, then tell the
88 // passed-in operation to report success.
89 void Cancel(FileSystemOperation* cancel_operation);
90
91 private: 84 private:
92 class ScopedQuotaUtilHelper; 85 class ScopedQuotaUtilHelper;
93 86
94 FileSystemContext* file_system_context() const { 87 FileSystemContext* file_system_context() const {
95 return operation_context_.file_system_context(); 88 return operation_context_.file_system_context();
96 } 89 }
97 90
98 FileSystemOperationContext* file_system_operation_context() { 91 FileSystemOperationContext* file_system_operation_context() {
99 return &operation_context_; 92 return &operation_context_;
100 } 93 }
(...skipping 28 matching lines...) Expand all
129 int64 usage, int64 quota); 122 int64 usage, int64 quota);
130 void DelayedWriteForQuota(quota::QuotaStatusCode status, 123 void DelayedWriteForQuota(quota::QuotaStatusCode status,
131 int64 usage, int64 quota); 124 int64 usage, int64 quota);
132 void DelayedTruncateForQuota(int64 length, 125 void DelayedTruncateForQuota(int64 length,
133 quota::QuotaStatusCode status, 126 quota::QuotaStatusCode status,
134 int64 usage, int64 quota); 127 int64 usage, int64 quota);
135 void DelayedOpenFileForQuota(int file_flags, 128 void DelayedOpenFileForQuota(int file_flags,
136 quota::QuotaStatusCode status, 129 quota::QuotaStatusCode status,
137 int64 usage, int64 quota); 130 int64 usage, int64 quota);
138 131
139 // A callback used for OpenFileSystem.
140 void DidGetRootPath(bool success,
141 const FilePath& path,
142 const std::string& name);
143
144 // Callback for CreateFile for |exclusive|=true cases. 132 // Callback for CreateFile for |exclusive|=true cases.
145 void DidEnsureFileExistsExclusive(base::PlatformFileError rv, 133 void DidEnsureFileExistsExclusive(base::PlatformFileError rv,
146 bool created); 134 bool created);
147 135
148 // Callback for CreateFile for |exclusive|=false cases. 136 // Callback for CreateFile for |exclusive|=false cases.
149 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, 137 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv,
150 bool created); 138 bool created);
151 139
152 // Generic callback that translates platform errors to WebKit error codes. 140 // Generic callback that translates platform errors to WebKit error codes.
153 void DidFinishFileOperation(base::PlatformFileError rv); 141 void DidFinishFileOperation(base::PlatformFileError rv);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // function and store the results to operation_context_ and 215 // function and store the results to operation_context_ and
228 // *_virtual_path_. 216 // *_virtual_path_.
229 // Return the result of VerifyFileSystem*(). 217 // Return the result of VerifyFileSystem*().
230 bool SetupSrcContextForRead(const GURL& path); 218 bool SetupSrcContextForRead(const GURL& path);
231 bool SetupSrcContextForWrite(const GURL& path, bool create); 219 bool SetupSrcContextForWrite(const GURL& path, bool create);
232 bool SetupDestContextForWrite(const GURL& path, bool create); 220 bool SetupDestContextForWrite(const GURL& path, bool create);
233 221
234 #ifndef NDEBUG 222 #ifndef NDEBUG
235 enum OperationType { 223 enum OperationType {
236 kOperationNone, 224 kOperationNone,
237 kOperationOpenFileSystem,
238 kOperationCreateFile, 225 kOperationCreateFile,
239 kOperationCreateDirectory, 226 kOperationCreateDirectory,
240 kOperationCopy, 227 kOperationCopy,
241 kOperationMove, 228 kOperationMove,
242 kOperationDirectoryExists, 229 kOperationDirectoryExists,
243 kOperationFileExists, 230 kOperationFileExists,
244 kOperationGetMetadata, 231 kOperationGetMetadata,
245 kOperationReadDirectory, 232 kOperationReadDirectory,
246 kOperationRemove, 233 kOperationRemove,
247 kOperationWrite, 234 kOperationWrite,
(...skipping 15 matching lines...) Expand all
263 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; 250 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_;
264 251
265 FileSystemOperationContext operation_context_; 252 FileSystemOperationContext operation_context_;
266 253
267 scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_; 254 scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_;
268 255
269 // These are all used only by Write(). 256 // These are all used only by Write().
270 friend class FileWriterDelegate; 257 friend class FileWriterDelegate;
271 scoped_ptr<FileWriterDelegate> file_writer_delegate_; 258 scoped_ptr<FileWriterDelegate> file_writer_delegate_;
272 scoped_ptr<net::URLRequest> blob_request_; 259 scoped_ptr<net::URLRequest> blob_request_;
273 scoped_ptr<FileSystemOperation> cancel_operation_; 260 scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher_;
274 261
275 // Used only by OpenFile, in order to clone the file handle back to the 262 // Used only by OpenFile, in order to clone the file handle back to the
276 // requesting process. 263 // requesting process.
277 base::ProcessHandle peer_handle_; 264 base::ProcessHandle peer_handle_;
278 265
279 // Used to keep a virtual path around while we check for quota. 266 // Used to keep a virtual path around while we check for quota.
280 // If an operation needs only one path, use src_virtual_path_, even if it's a 267 // If an operation needs only one path, use src_virtual_path_, even if it's a
281 // write. 268 // write.
282 FilePath src_virtual_path_; 269 FilePath src_virtual_path_;
283 FilePath dest_virtual_path_; 270 FilePath dest_virtual_path_;
284 271
285 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); 272 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation);
286 }; 273 };
287 274
288 } // namespace fileapi 275 } // namespace fileapi
289 276
290 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ 277 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_mount_point_provider_unittest.cc ('k') | webkit/fileapi/file_system_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698