| OLD | NEW |
| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy_base.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "base/scoped_callback_factory.h" | 15 #include "base/scoped_callback_factory.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class Time; | 20 class Time; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class URLRequest; | 24 class URLRequest; |
| 25 class URLRequestContext; | 25 class URLRequestContext; |
| 26 } // namespace net | 26 } // namespace net |
| 27 | 27 |
| 28 class GURL; | 28 class GURL; |
| 29 | 29 |
| 30 namespace fileapi { | 30 namespace fileapi { |
| 31 | 31 |
| 32 class FileSystemCallbackDispatcher; | 32 class FileSystemCallbackDispatcher; |
| 33 class FileUtilProxyBase; |
| 33 class FileWriterDelegate; | 34 class FileWriterDelegate; |
| 34 | 35 |
| 35 // This class is designed to serve one-time file system operation per instance. | 36 // This class is designed to serve one-time file system operation per instance. |
| 36 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, | 37 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, |
| 37 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of | 38 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of |
| 38 // this object and it should be called no more than once. | 39 // this object and it should be called no more than once. |
| 39 // This class is self-destructed and an instance automatically gets deleted | 40 // This class is self-destructed and an instance automatically gets deleted |
| 40 // when its operation is finished. | 41 // when its operation is finished. |
| 41 class FileSystemOperation { | 42 class FileSystemOperation { |
| 42 public: | 43 public: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 kOperationTruncate, | 102 kOperationTruncate, |
| 102 kOperationTouchFile, | 103 kOperationTouchFile, |
| 103 kOperationCancel, | 104 kOperationCancel, |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 // A flag to make sure we call operation only once per instance. | 107 // A flag to make sure we call operation only once per instance. |
| 107 OperationType pending_operation_; | 108 OperationType pending_operation_; |
| 108 #endif | 109 #endif |
| 109 | 110 |
| 110 FileSystemCallbackDispatcher* dispatcher() const { return dispatcher_.get(); } | 111 FileSystemCallbackDispatcher* dispatcher() const { return dispatcher_.get(); } |
| 112 virtual base::FileUtilProxyBase* file_util_proxy() const; |
| 111 | 113 |
| 112 private: | 114 private: |
| 113 // Callback for CreateFile for |exclusive|=true cases. | 115 // Callback for CreateFile for |exclusive|=true cases. |
| 114 void DidEnsureFileExistsExclusive(base::PlatformFileError rv, | 116 void DidEnsureFileExistsExclusive(base::PlatformFileError rv, |
| 115 bool created); | 117 bool created); |
| 116 | 118 |
| 117 // Callback for CreateFile for |exclusive|=false cases. | 119 // Callback for CreateFile for |exclusive|=false cases. |
| 118 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, | 120 void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, |
| 119 bool created); | 121 bool created); |
| 120 | 122 |
| 121 // Generic callback that translates platform errors to WebKit error codes. | 123 // Generic callback that translates platform errors to WebKit error codes. |
| 122 void DidFinishFileOperation(base::PlatformFileError rv); | 124 void DidFinishFileOperation(base::PlatformFileError rv); |
| 123 | 125 |
| 124 void DidDirectoryExists(base::PlatformFileError rv, | 126 void DidDirectoryExists(base::PlatformFileError rv, |
| 125 const base::PlatformFileInfo& file_info); | 127 const base::PlatformFileInfo& file_info); |
| 126 | 128 |
| 127 void DidFileExists(base::PlatformFileError rv, | 129 void DidFileExists(base::PlatformFileError rv, |
| 128 const base::PlatformFileInfo& file_info); | 130 const base::PlatformFileInfo& file_info); |
| 129 | 131 |
| 130 void DidGetMetadata(base::PlatformFileError rv, | 132 void DidGetMetadata(base::PlatformFileError rv, |
| 131 const base::PlatformFileInfo& file_info); | 133 const base::PlatformFileInfo& file_info); |
| 132 | 134 |
| 133 void DidReadDirectory( | 135 void DidReadDirectory( |
| 134 base::PlatformFileError rv, | 136 base::PlatformFileError rv, |
| 135 const std::vector<base::FileUtilProxy::Entry>& entries); | 137 const std::vector<base::FileUtilProxyBase::Entry>& entries); |
| 136 | 138 |
| 137 void DidWrite( | 139 void DidWrite( |
| 138 base::PlatformFileError rv, | 140 base::PlatformFileError rv, |
| 139 int64 bytes, | 141 int64 bytes, |
| 140 bool complete); | 142 bool complete); |
| 141 | 143 |
| 142 void DidTouchFile(base::PlatformFileError rv); | 144 void DidTouchFile(base::PlatformFileError rv); |
| 143 | 145 |
| 144 // Helper for Write(). | 146 // Helper for Write(). |
| 145 void OnFileOpenedForWrite( | 147 void OnFileOpenedForWrite( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 159 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 161 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| 160 scoped_ptr<net::URLRequest> blob_request_; | 162 scoped_ptr<net::URLRequest> blob_request_; |
| 161 scoped_ptr<FileSystemOperation> cancel_operation_; | 163 scoped_ptr<FileSystemOperation> cancel_operation_; |
| 162 | 164 |
| 163 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 165 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
| 164 }; | 166 }; |
| 165 | 167 |
| 166 } // namespace fileapi | 168 } // namespace fileapi |
| 167 | 169 |
| 168 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 170 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |