| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace fileapi { | 27 namespace fileapi { |
| 28 | 28 |
| 29 class FileSystemCallbackDispatcher; | 29 class FileSystemCallbackDispatcher; |
| 30 class FileWriterDelegate; | 30 class FileWriterDelegate; |
| 31 | 31 |
| 32 // This class is designed to serve one-time file system operation per instance. | 32 // This class is designed to serve one-time file system operation per instance. |
| 33 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, | 33 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, |
| 34 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of | 34 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of |
| 35 // this object and it should be called no more than once. | 35 // this object and it should be called no more than once. |
| 36 // This class is self-destructed and an instance automatically gets deleted |
| 37 // when its operation is finished. |
| 36 class FileSystemOperation { | 38 class FileSystemOperation { |
| 37 public: | 39 public: |
| 40 // |dispatcher| will be owned by this class. |
| 38 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, | 41 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, |
| 39 scoped_refptr<base::MessageLoopProxy> proxy); | 42 scoped_refptr<base::MessageLoopProxy> proxy); |
| 40 virtual ~FileSystemOperation(); | 43 virtual ~FileSystemOperation(); |
| 41 | 44 |
| 42 virtual void CreateFile(const FilePath& path, | 45 virtual void CreateFile(const FilePath& path, |
| 43 bool exclusive); | 46 bool exclusive); |
| 44 | 47 |
| 45 virtual void CreateDirectory(const FilePath& path, | 48 virtual void CreateDirectory(const FilePath& path, |
| 46 bool exclusive, | 49 bool exclusive, |
| 47 bool recursive); | 50 bool recursive); |
| 48 | 51 |
| 49 virtual void Copy(const FilePath& src_path, | 52 virtual void Copy(const FilePath& src_path, |
| 50 const FilePath& dest_path); | 53 const FilePath& dest_path); |
| 51 | 54 |
| 52 virtual void Move(const FilePath& src_path, | 55 virtual void Move(const FilePath& src_path, |
| 53 const FilePath& dest_path); | 56 const FilePath& dest_path); |
| 54 | 57 |
| 55 virtual void DirectoryExists(const FilePath& path); | 58 virtual void DirectoryExists(const FilePath& path); |
| 56 | 59 |
| 57 virtual void FileExists(const FilePath& path); | 60 virtual void FileExists(const FilePath& path); |
| 58 | 61 |
| 59 virtual void GetMetadata(const FilePath& path); | 62 virtual void GetMetadata(const FilePath& path); |
| 60 | 63 |
| 61 virtual void ReadDirectory(const FilePath& path); | 64 virtual void ReadDirectory(const FilePath& path); |
| 62 | 65 |
| 63 virtual void Remove(const FilePath& path, bool recursive); | 66 virtual void Remove(const FilePath& path, bool recursive); |
| 64 | 67 |
| 65 virtual void Write( | 68 virtual void Write(scoped_refptr<URLRequestContext> url_request_context, |
| 66 scoped_refptr<URLRequestContext> url_request_context, | 69 const FilePath& path, |
| 67 const FilePath& path, const GURL& blob_url, int64 offset); | 70 const GURL& blob_url, |
| 71 int64 offset); |
| 68 | 72 |
| 69 virtual void Truncate(const FilePath& path, int64 length); | 73 virtual void Truncate(const FilePath& path, int64 length); |
| 70 | 74 |
| 71 virtual void TouchFile(const FilePath& path, | 75 virtual void TouchFile(const FilePath& path, |
| 72 const base::Time& last_access_time, | 76 const base::Time& last_access_time, |
| 73 const base::Time& last_modified_time); | 77 const base::Time& last_modified_time); |
| 74 | 78 |
| 75 // Try to cancel the current operation [we support cancelling write or | 79 // Try to cancel the current operation [we support cancelling write or |
| 76 // truncate only]. Report failure for the current operation, then tell the | 80 // truncate only]. Report failure for the current operation, then tell the |
| 77 // passed-in operation to report success. | 81 // passed-in operation to report success. |
| 78 virtual void Cancel(FileSystemOperation* cancel_operation); | 82 virtual void Cancel(FileSystemOperation* cancel_operation); |
| 79 | 83 |
| 80 protected: | 84 protected: |
| 81 #ifndef NDEBUG | 85 #ifndef NDEBUG |
| 82 enum OperationType { | 86 enum OperationType { |
| 83 kOperationNone, | 87 kOperationNone, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 scoped_refptr<base::MessageLoopProxy> proxy_; | 148 scoped_refptr<base::MessageLoopProxy> proxy_; |
| 145 | 149 |
| 146 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; | 150 scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; |
| 147 | 151 |
| 148 base::ScopedCallbackFactory<FileSystemOperation> callback_factory_; | 152 base::ScopedCallbackFactory<FileSystemOperation> callback_factory_; |
| 149 | 153 |
| 150 // These are all used only by Write(). | 154 // These are all used only by Write(). |
| 151 friend class FileWriterDelegate; | 155 friend class FileWriterDelegate; |
| 152 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 156 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| 153 scoped_ptr<URLRequest> blob_request_; | 157 scoped_ptr<URLRequest> blob_request_; |
| 154 FileSystemOperation* cancel_operation_; | 158 scoped_ptr<FileSystemOperation> cancel_operation_; |
| 155 | 159 |
| 156 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 160 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
| 157 }; | 161 }; |
| 158 | 162 |
| 159 } // namespace fileapi | 163 } // namespace fileapi |
| 160 | 164 |
| 161 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 165 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |