summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_operation.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-30 18:58:13 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-30 18:58:13 +0000
commit103c8d4b8d27edf535d8a3e7836fd1bffba28bfc (patch)
tree343fe70815e83ca913ce3f6c5bd9bdec123a56ff /webkit/fileapi/file_system_operation.h
parent91abc359dcbbd46f7793338d36d51dfd8629b571 (diff)
downloadchromium_src-103c8d4b8d27edf535d8a3e7836fd1bffba28bfc.zip
chromium_src-103c8d4b8d27edf535d8a3e7836fd1bffba28bfc.tar.gz
chromium_src-103c8d4b8d27edf535d8a3e7836fd1bffba28bfc.tar.bz2
Make FileSystemOperation's lifetime more explicit.
In the current code calling dispatcher->DidXxx in an operation's DidXxx method MAY indirectly delete the operation itself depending on the dispatcher's implementation. I was confused by this several times and I want to make this flow more explicit. This patch lets FileSystemOperation control its lifetime by itself so that each callback dispatcher implementation does not need to take care of it. Also moved BrowserFileSystemCallbackDispatcher into file_system_dispatcher_host.cc as it's only used in it and its implementation is tightly coupled with the DispatcherHost. BUG=60243 TEST=none Review URL: http://codereview.chromium.org/4821005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_operation.h')
-rw-r--r--webkit/fileapi/file_system_operation.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h
index 6614b5e..e260e24 100644
--- a/webkit/fileapi/file_system_operation.h
+++ b/webkit/fileapi/file_system_operation.h
@@ -36,8 +36,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();
@@ -65,15 +68,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
@@ -154,7 +158,7 @@ class FileSystemOperation {
friend class FileWriterDelegate;
scoped_ptr<FileWriterDelegate> file_writer_delegate_;
scoped_ptr<net::URLRequest> blob_request_;
- FileSystemOperation* cancel_operation_;
+ scoped_ptr<FileSystemOperation> cancel_operation_;
DISALLOW_COPY_AND_ASSIGN(FileSystemOperation);
};