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

Unified Diff: webkit/fileapi/file_system_operation.h

Issue 4821005: Make FileSystemOperation's lifetime more explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/file_system_operation.h
diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h
index 01e2da1853c6dbeba2f55494a71137b6ee7f9b27..09392b498e8d13c22ba12e6cd803d0133431dc7c 100644
--- a/webkit/fileapi/file_system_operation.h
+++ b/webkit/fileapi/file_system_operation.h
@@ -33,8 +33,11 @@ class FileWriterDelegate;
// Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists,
// GetMetadata, ReadDirectory and Remove) may be called during the lifetime of
// this object and it should be called no more than once.
+// This class is self-destructed and an instance automatically gets deleted
+// when its operation is finished.
class FileSystemOperation {
public:
+ // |dispatcher| will be owned by this class.
FileSystemOperation(FileSystemCallbackDispatcher* dispatcher,
scoped_refptr<base::MessageLoopProxy> proxy);
virtual ~FileSystemOperation();
@@ -62,15 +65,16 @@ class FileSystemOperation {
virtual void Remove(const FilePath& path, bool recursive);
- virtual void Write(
- scoped_refptr<URLRequestContext> url_request_context,
- const FilePath& path, const GURL& blob_url, int64 offset);
+ virtual void Write(scoped_refptr<URLRequestContext> url_request_context,
+ const FilePath& path,
+ const GURL& blob_url,
+ int64 offset);
virtual void Truncate(const FilePath& path, int64 length);
virtual void TouchFile(const FilePath& path,
- const base::Time& last_access_time,
- const base::Time& last_modified_time);
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time);
// Try to cancel the current operation [we support cancelling write or
// truncate only]. Report failure for the current operation, then tell the
@@ -100,7 +104,15 @@ class FileSystemOperation {
OperationType pending_operation_;
#endif
- FileSystemCallbackDispatcher* dispatcher() const { return dispatcher_.get(); }
+ // Returns a destructive dispatcher which deletes the operation instance
+ // after any of its callback methods is called (except for DidWrite with
+ // complete=false cases).
+ FileSystemCallbackDispatcher* destructive_dispatcher() const {
+ return destructive_dispatcher_.get();
+ }
+
+ // Returns a non-destructive dispatcher.
+ FileSystemCallbackDispatcher* non_destructive_dispatcher() const;
private:
// Callback for CreateFile for |exclusive|=true cases.
@@ -143,7 +155,7 @@ class FileSystemOperation {
// Proxy for calling file_util_proxy methods.
scoped_refptr<base::MessageLoopProxy> proxy_;
- scoped_ptr<FileSystemCallbackDispatcher> dispatcher_;
+ scoped_ptr<FileSystemCallbackDispatcher> destructive_dispatcher_;
base::ScopedCallbackFactory<FileSystemOperation> callback_factory_;

Powered by Google App Engine
This is Rietveld 408576698