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

Side by Side 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: simple_file_writer fix Created 10 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
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | webkit/fileapi/file_system_operation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 18 matching lines...) Expand all
29 29
30 namespace fileapi { 30 namespace fileapi {
31 31
32 class FileSystemCallbackDispatcher; 32 class FileSystemCallbackDispatcher;
33 class FileWriterDelegate; 33 class FileWriterDelegate;
34 34
35 // This class is designed to serve one-time file system operation per instance. 35 // This class is designed to serve one-time file system operation per instance.
36 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, 36 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists,
37 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of 37 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of
38 // this object and it should be called no more than once. 38 // this object and it should be called no more than once.
39 // This class is self-destructed and an instance automatically gets deleted
40 // when its operation is finished.
39 class FileSystemOperation { 41 class FileSystemOperation {
40 public: 42 public:
43 // |dispatcher| will be owned by this class.
41 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, 44 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher,
42 scoped_refptr<base::MessageLoopProxy> proxy); 45 scoped_refptr<base::MessageLoopProxy> proxy);
43 virtual ~FileSystemOperation(); 46 virtual ~FileSystemOperation();
44 47
45 virtual void CreateFile(const FilePath& path, 48 virtual void CreateFile(const FilePath& path,
46 bool exclusive); 49 bool exclusive);
47 50
48 virtual void CreateDirectory(const FilePath& path, 51 virtual void CreateDirectory(const FilePath& path,
49 bool exclusive, 52 bool exclusive,
50 bool recursive); 53 bool recursive);
51 54
52 virtual void Copy(const FilePath& src_path, 55 virtual void Copy(const FilePath& src_path,
53 const FilePath& dest_path); 56 const FilePath& dest_path);
54 57
55 virtual void Move(const FilePath& src_path, 58 virtual void Move(const FilePath& src_path,
56 const FilePath& dest_path); 59 const FilePath& dest_path);
57 60
58 virtual void DirectoryExists(const FilePath& path); 61 virtual void DirectoryExists(const FilePath& path);
59 62
60 virtual void FileExists(const FilePath& path); 63 virtual void FileExists(const FilePath& path);
61 64
62 virtual void GetMetadata(const FilePath& path); 65 virtual void GetMetadata(const FilePath& path);
63 66
64 virtual void ReadDirectory(const FilePath& path); 67 virtual void ReadDirectory(const FilePath& path);
65 68
66 virtual void Remove(const FilePath& path, bool recursive); 69 virtual void Remove(const FilePath& path, bool recursive);
67 70
68 virtual void Write( 71 virtual void Write(scoped_refptr<URLRequestContext> url_request_context,
69 scoped_refptr<URLRequestContext> url_request_context, 72 const FilePath& path,
70 const FilePath& path, const GURL& blob_url, int64 offset); 73 const GURL& blob_url,
74 int64 offset);
71 75
72 virtual void Truncate(const FilePath& path, int64 length); 76 virtual void Truncate(const FilePath& path, int64 length);
73 77
74 virtual void TouchFile(const FilePath& path, 78 virtual void TouchFile(const FilePath& path,
75 const base::Time& last_access_time, 79 const base::Time& last_access_time,
76 const base::Time& last_modified_time); 80 const base::Time& last_modified_time);
77 81
78 // Try to cancel the current operation [we support cancelling write or 82 // Try to cancel the current operation [we support cancelling write or
79 // truncate only]. Report failure for the current operation, then tell the 83 // truncate only]. Report failure for the current operation, then tell the
80 // passed-in operation to report success. 84 // passed-in operation to report success.
81 virtual void Cancel(FileSystemOperation* cancel_operation); 85 virtual void Cancel(FileSystemOperation* cancel_operation);
82 86
83 protected: 87 protected:
84 #ifndef NDEBUG 88 #ifndef NDEBUG
85 enum OperationType { 89 enum OperationType {
86 kOperationNone, 90 kOperationNone,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 scoped_refptr<base::MessageLoopProxy> proxy_; 151 scoped_refptr<base::MessageLoopProxy> proxy_;
148 152
149 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; 153 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_;
150 154
151 base::ScopedCallbackFactory<FileSystemOperation> callback_factory_; 155 base::ScopedCallbackFactory<FileSystemOperation> callback_factory_;
152 156
153 // These are all used only by Write(). 157 // These are all used only by Write().
154 friend class FileWriterDelegate; 158 friend class FileWriterDelegate;
155 scoped_ptr<FileWriterDelegate> file_writer_delegate_; 159 scoped_ptr<FileWriterDelegate> file_writer_delegate_;
156 scoped_ptr<net::URLRequest> blob_request_; 160 scoped_ptr<net::URLRequest> blob_request_;
157 FileSystemOperation* cancel_operation_; 161 scoped_ptr<FileSystemOperation> cancel_operation_;
158 162
159 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); 163 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation);
160 }; 164 };
161 165
162 } // namespace fileapi 166 } // namespace fileapi
163 167
164 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ 168 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | webkit/fileapi/file_system_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698