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

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: more cleanup around ValidateFileSystemRoot Created 9 years 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // FileSystemOperation implementation for local file systems. 44 // FileSystemOperation implementation for local file systems.
45 class FileSystemOperation : public FileSystemOperationInterface { 45 class FileSystemOperation : public FileSystemOperationInterface {
46 public: 46 public:
47 // |dispatcher| will be owned by this class. 47 // |dispatcher| will be owned by this class.
48 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, 48 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher,
49 scoped_refptr<base::MessageLoopProxy> proxy, 49 scoped_refptr<base::MessageLoopProxy> proxy,
50 FileSystemContext* file_system_context); 50 FileSystemContext* file_system_context);
51 virtual ~FileSystemOperation(); 51 virtual ~FileSystemOperation();
52 52
53 // FileSystemOperation overrides. 53 // FileSystemOperation overrides.
54 virtual void OpenFileSystem(const GURL& origin_url,
55 fileapi::FileSystemType type,
56 bool create) OVERRIDE;
57 virtual void CreateFile(const GURL& path, 54 virtual void CreateFile(const GURL& path,
58 bool exclusive) OVERRIDE; 55 bool exclusive) OVERRIDE;
59 virtual void CreateDirectory(const GURL& path, 56 virtual void CreateDirectory(const GURL& path,
60 bool exclusive, 57 bool exclusive,
61 bool recursive) OVERRIDE; 58 bool recursive) OVERRIDE;
62 virtual void Copy(const GURL& src_path, 59 virtual void Copy(const GURL& src_path,
63 const GURL& dest_path) OVERRIDE; 60 const GURL& dest_path) OVERRIDE;
64 virtual void Move(const GURL& src_path, 61 virtual void Move(const GURL& src_path,
65 const GURL& dest_path) OVERRIDE; 62 const GURL& dest_path) OVERRIDE;
66 virtual void DirectoryExists(const GURL& path) OVERRIDE; 63 virtual void DirectoryExists(const GURL& path) OVERRIDE;
67 virtual void FileExists(const GURL& path) OVERRIDE; 64 virtual void FileExists(const GURL& path) OVERRIDE;
68 virtual void GetMetadata(const GURL& path) OVERRIDE; 65 virtual void GetMetadata(const GURL& path) OVERRIDE;
69 virtual void ReadDirectory(const GURL& path) OVERRIDE; 66 virtual void ReadDirectory(const GURL& path) OVERRIDE;
70 virtual void Remove(const GURL& path, bool recursive) OVERRIDE; 67 virtual void Remove(const GURL& path, bool recursive) OVERRIDE;
71 virtual void Write(const net::URLRequestContext* url_request_context, 68 virtual void Write(const net::URLRequestContext* url_request_context,
72 const GURL& path, 69 const GURL& path,
73 const GURL& blob_url, 70 const GURL& blob_url,
74 int64 offset) OVERRIDE; 71 int64 offset) OVERRIDE;
75 virtual void Truncate(const GURL& path, int64 length) OVERRIDE; 72 virtual void Truncate(const GURL& path, int64 length) OVERRIDE;
76 virtual void TouchFile(const GURL& path, 73 virtual void TouchFile(const GURL& path,
77 const base::Time& last_access_time, 74 const base::Time& last_access_time,
78 const base::Time& last_modified_time) OVERRIDE; 75 const base::Time& last_modified_time) OVERRIDE;
79 virtual void OpenFile( 76 virtual void OpenFile(
80 const GURL& path, 77 const GURL& path,
81 int file_flags, 78 int file_flags,
82 base::ProcessHandle peer_handle) OVERRIDE; 79 base::ProcessHandle peer_handle) OVERRIDE;
80 virtual void Cancel(FileSystemCallbackDispatcher* cancel_dispatcher) OVERRIDE;
83 81
84 // Synchronously gets the platform path for the given |path|. 82 // Synchronously gets the platform path for the given |path|.
85 void SyncGetPlatformPath(const GURL& path, FilePath* platform_path); 83 void SyncGetPlatformPath(const GURL& path, FilePath* platform_path);
86 84
87 // Try to cancel the current operation [we support cancelling write or
88 // truncate only]. Report failure for the current operation, then tell the
89 // passed-in operation to report success.
90 void Cancel(FileSystemOperation* cancel_operation);
91
92 private: 85 private:
93 class ScopedQuotaUtilHelper; 86 class ScopedQuotaUtilHelper;
94 87
95 FileSystemContext* file_system_context() const { 88 FileSystemContext* file_system_context() const {
96 return operation_context_.file_system_context(); 89 return operation_context_.file_system_context();
97 } 90 }
98 91
99 FileSystemOperationContext* file_system_operation_context() { 92 FileSystemOperationContext* file_system_operation_context() {
100 return &operation_context_; 93 return &operation_context_;
101 } 94 }
(...skipping 28 matching lines...) Expand all
130 int64 usage, int64 quota); 123 int64 usage, int64 quota);
131 void DelayedWriteForQuota(quota::QuotaStatusCode status, 124 void DelayedWriteForQuota(quota::QuotaStatusCode status,
132 int64 usage, int64 quota); 125 int64 usage, int64 quota);
133 void DelayedTruncateForQuota(int64 length, 126 void DelayedTruncateForQuota(int64 length,
134 quota::QuotaStatusCode status, 127 quota::QuotaStatusCode status,
135 int64 usage, int64 quota); 128 int64 usage, int64 quota);
136 void DelayedOpenFileForQuota(int file_flags, 129 void DelayedOpenFileForQuota(int file_flags,
137 quota::QuotaStatusCode status, 130 quota::QuotaStatusCode status,
138 int64 usage, int64 quota); 131 int64 usage, int64 quota);
139 132
140 // A callback used for OpenFileSystem.
141 void DidGetRootPath(bool success,
142 const FilePath& path,
143 const std::string& name);
144
145 // Callback for CreateFile for |exclusive|=true cases. 133 // Callback for CreateFile for |exclusive|=true cases.
146 void DidEnsureFileExistsExclusive(base::PlatformFileError rv, 134 void DidEnsureFileExistsExclusive(base::PlatformFileError rv,
147 bool created); 135 bool created);
148 136
149 // Callback for CreateFile for |exclusive|=false cases. 137 // Callback for CreateFile for |exclusive|=false cases.
150 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, 138 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv,
151 bool created); 139 bool created);
152 140
153 // Generic callback that translates platform errors to WebKit error codes. 141 // Generic callback that translates platform errors to WebKit error codes.
154 void DidFinishFileOperation(base::PlatformFileError rv); 142 void DidFinishFileOperation(base::PlatformFileError rv);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // function and store the results to operation_context_ and 216 // function and store the results to operation_context_ and
229 // *_virtual_path_. 217 // *_virtual_path_.
230 // Return the result of VerifyFileSystem*(). 218 // Return the result of VerifyFileSystem*().
231 bool SetupSrcContextForRead(const GURL& path); 219 bool SetupSrcContextForRead(const GURL& path);
232 bool SetupSrcContextForWrite(const GURL& path, bool create); 220 bool SetupSrcContextForWrite(const GURL& path, bool create);
233 bool SetupDestContextForWrite(const GURL& path, bool create); 221 bool SetupDestContextForWrite(const GURL& path, bool create);
234 222
235 #ifndef NDEBUG 223 #ifndef NDEBUG
236 enum OperationType { 224 enum OperationType {
237 kOperationNone, 225 kOperationNone,
238 kOperationOpenFileSystem,
239 kOperationCreateFile, 226 kOperationCreateFile,
240 kOperationCreateDirectory, 227 kOperationCreateDirectory,
241 kOperationCopy, 228 kOperationCopy,
242 kOperationMove, 229 kOperationMove,
243 kOperationDirectoryExists, 230 kOperationDirectoryExists,
244 kOperationFileExists, 231 kOperationFileExists,
245 kOperationGetMetadata, 232 kOperationGetMetadata,
246 kOperationReadDirectory, 233 kOperationReadDirectory,
247 kOperationRemove, 234 kOperationRemove,
248 kOperationWrite, 235 kOperationWrite,
(...skipping 15 matching lines...) Expand all
264 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; 251 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_;
265 252
266 FileSystemOperationContext operation_context_; 253 FileSystemOperationContext operation_context_;
267 254
268 scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_; 255 scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_;
269 256
270 // These are all used only by Write(). 257 // These are all used only by Write().
271 friend class FileWriterDelegate; 258 friend class FileWriterDelegate;
272 scoped_ptr<FileWriterDelegate> file_writer_delegate_; 259 scoped_ptr<FileWriterDelegate> file_writer_delegate_;
273 scoped_ptr<net::URLRequest> blob_request_; 260 scoped_ptr<net::URLRequest> blob_request_;
274 scoped_ptr<FileSystemOperation> cancel_operation_; 261 scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher_;
275 262
276 // Used only by OpenFile, in order to clone the file handle back to the 263 // Used only by OpenFile, in order to clone the file handle back to the
277 // requesting process. 264 // requesting process.
278 base::ProcessHandle peer_handle_; 265 base::ProcessHandle peer_handle_;
279 266
280 // Used to keep a virtual path around while we check for quota. 267 // Used to keep a virtual path around while we check for quota.
281 // If an operation needs only one path, use src_virtual_path_, even if it's a 268 // If an operation needs only one path, use src_virtual_path_, even if it's a
282 // write. 269 // write.
283 FilePath src_virtual_path_; 270 FilePath src_virtual_path_;
284 FilePath dest_virtual_path_; 271 FilePath dest_virtual_path_;
285 272
286 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); 273 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation);
287 }; 274 };
288 275
289 } // namespace fileapi 276 } // namespace fileapi
290 277
291 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ 278 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698