| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ |
| 6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ | 6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "storage/browser/blob/scoped_file.h" | 15 #include "storage/browser/blob/scoped_file.h" |
| 14 #include "storage/browser/fileapi/file_system_operation.h" | 16 #include "storage/browser/fileapi/file_system_operation.h" |
| 15 #include "storage/browser/fileapi/file_system_operation_context.h" | 17 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 16 #include "storage/browser/fileapi/file_system_url.h" | 18 #include "storage/browser/fileapi/file_system_url.h" |
| 17 #include "storage/browser/fileapi/file_writer_delegate.h" | 19 #include "storage/browser/fileapi/file_writer_delegate.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void ReadDirectory(const FileSystemURL& url, | 60 void ReadDirectory(const FileSystemURL& url, |
| 59 const ReadDirectoryCallback& callback) override; | 61 const ReadDirectoryCallback& callback) override; |
| 60 void Remove(const FileSystemURL& url, | 62 void Remove(const FileSystemURL& url, |
| 61 bool recursive, | 63 bool recursive, |
| 62 const StatusCallback& callback) override; | 64 const StatusCallback& callback) override; |
| 63 void Write(const FileSystemURL& url, | 65 void Write(const FileSystemURL& url, |
| 64 scoped_ptr<FileWriterDelegate> writer_delegate, | 66 scoped_ptr<FileWriterDelegate> writer_delegate, |
| 65 scoped_ptr<net::URLRequest> blob_request, | 67 scoped_ptr<net::URLRequest> blob_request, |
| 66 const WriteCallback& callback) override; | 68 const WriteCallback& callback) override; |
| 67 void Truncate(const FileSystemURL& url, | 69 void Truncate(const FileSystemURL& url, |
| 68 int64 length, | 70 int64_t length, |
| 69 const StatusCallback& callback) override; | 71 const StatusCallback& callback) override; |
| 70 void TouchFile(const FileSystemURL& url, | 72 void TouchFile(const FileSystemURL& url, |
| 71 const base::Time& last_access_time, | 73 const base::Time& last_access_time, |
| 72 const base::Time& last_modified_time, | 74 const base::Time& last_modified_time, |
| 73 const StatusCallback& callback) override; | 75 const StatusCallback& callback) override; |
| 74 void OpenFile(const FileSystemURL& url, | 76 void OpenFile(const FileSystemURL& url, |
| 75 int file_flags, | 77 int file_flags, |
| 76 const OpenFileCallback& callback) override; | 78 const OpenFileCallback& callback) override; |
| 77 void Cancel(const StatusCallback& cancel_callback) override; | 79 void Cancel(const StatusCallback& cancel_callback) override; |
| 78 void CreateSnapshotFile(const FileSystemURL& path, | 80 void CreateSnapshotFile(const FileSystemURL& path, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 const base::Closure& error_callback); | 118 const base::Closure& error_callback); |
| 117 | 119 |
| 118 // Called after the quota info is obtained from the quota manager | 120 // Called after the quota info is obtained from the quota manager |
| 119 // (which is triggered by GetUsageAndQuotaThenRunTask). | 121 // (which is triggered by GetUsageAndQuotaThenRunTask). |
| 120 // Sets the quota info in the operation_context_ and then runs the given | 122 // Sets the quota info in the operation_context_ and then runs the given |
| 121 // |task| if the returned quota status is successful, otherwise runs | 123 // |task| if the returned quota status is successful, otherwise runs |
| 122 // |error_callback|. | 124 // |error_callback|. |
| 123 void DidGetUsageAndQuotaAndRunTask(const base::Closure& task, | 125 void DidGetUsageAndQuotaAndRunTask(const base::Closure& task, |
| 124 const base::Closure& error_callback, | 126 const base::Closure& error_callback, |
| 125 storage::QuotaStatusCode status, | 127 storage::QuotaStatusCode status, |
| 126 int64 usage, | 128 int64_t usage, |
| 127 int64 quota); | 129 int64_t quota); |
| 128 | 130 |
| 129 // The 'body' methods that perform the actual work (i.e. posting the | 131 // The 'body' methods that perform the actual work (i.e. posting the |
| 130 // file task on proxy_) after the quota check. | 132 // file task on proxy_) after the quota check. |
| 131 void DoCreateFile(const FileSystemURL& url, | 133 void DoCreateFile(const FileSystemURL& url, |
| 132 const StatusCallback& callback, bool exclusive); | 134 const StatusCallback& callback, bool exclusive); |
| 133 void DoCreateDirectory(const FileSystemURL& url, | 135 void DoCreateDirectory(const FileSystemURL& url, |
| 134 const StatusCallback& callback, | 136 const StatusCallback& callback, |
| 135 bool exclusive, | 137 bool exclusive, |
| 136 bool recursive); | 138 bool recursive); |
| 137 void DoCopyFileLocal(const FileSystemURL& src, | 139 void DoCopyFileLocal(const FileSystemURL& src, |
| 138 const FileSystemURL& dest, | 140 const FileSystemURL& dest, |
| 139 CopyOrMoveOption option, | 141 CopyOrMoveOption option, |
| 140 const CopyFileProgressCallback& progress_callback, | 142 const CopyFileProgressCallback& progress_callback, |
| 141 const StatusCallback& callback); | 143 const StatusCallback& callback); |
| 142 void DoMoveFileLocal(const FileSystemURL& src, | 144 void DoMoveFileLocal(const FileSystemURL& src, |
| 143 const FileSystemURL& dest, | 145 const FileSystemURL& dest, |
| 144 CopyOrMoveOption option, | 146 CopyOrMoveOption option, |
| 145 const StatusCallback& callback); | 147 const StatusCallback& callback); |
| 146 void DoCopyInForeignFile(const base::FilePath& src_local_disk_file_path, | 148 void DoCopyInForeignFile(const base::FilePath& src_local_disk_file_path, |
| 147 const FileSystemURL& dest, | 149 const FileSystemURL& dest, |
| 148 const StatusCallback& callback); | 150 const StatusCallback& callback); |
| 149 void DoTruncate(const FileSystemURL& url, | 151 void DoTruncate(const FileSystemURL& url, |
| 150 const StatusCallback& callback, int64 length); | 152 const StatusCallback& callback, |
| 153 int64_t length); |
| 151 void DoOpenFile(const FileSystemURL& url, | 154 void DoOpenFile(const FileSystemURL& url, |
| 152 const OpenFileCallback& callback, int file_flags); | 155 const OpenFileCallback& callback, int file_flags); |
| 153 | 156 |
| 154 // Callback for CreateFile for |exclusive|=true cases. | 157 // Callback for CreateFile for |exclusive|=true cases. |
| 155 void DidEnsureFileExistsExclusive(const StatusCallback& callback, | 158 void DidEnsureFileExistsExclusive(const StatusCallback& callback, |
| 156 base::File::Error rv, | 159 base::File::Error rv, |
| 157 bool created); | 160 bool created); |
| 158 | 161 |
| 159 // Callback for CreateFile for |exclusive|=false cases. | 162 // Callback for CreateFile for |exclusive|=false cases. |
| 160 void DidEnsureFileExistsNonExclusive(const StatusCallback& callback, | 163 void DidEnsureFileExistsNonExclusive(const StatusCallback& callback, |
| 161 base::File::Error rv, | 164 base::File::Error rv, |
| 162 bool created); | 165 bool created); |
| 163 | 166 |
| 164 void DidFinishOperation(const StatusCallback& callback, | 167 void DidFinishOperation(const StatusCallback& callback, |
| 165 base::File::Error rv); | 168 base::File::Error rv); |
| 166 void DidDirectoryExists(const StatusCallback& callback, | 169 void DidDirectoryExists(const StatusCallback& callback, |
| 167 base::File::Error rv, | 170 base::File::Error rv, |
| 168 const base::File::Info& file_info); | 171 const base::File::Info& file_info); |
| 169 void DidFileExists(const StatusCallback& callback, | 172 void DidFileExists(const StatusCallback& callback, |
| 170 base::File::Error rv, | 173 base::File::Error rv, |
| 171 const base::File::Info& file_info); | 174 const base::File::Info& file_info); |
| 172 void DidDeleteRecursively(const FileSystemURL& url, | 175 void DidDeleteRecursively(const FileSystemURL& url, |
| 173 const StatusCallback& callback, | 176 const StatusCallback& callback, |
| 174 base::File::Error rv); | 177 base::File::Error rv); |
| 175 void DidWrite(const FileSystemURL& url, | 178 void DidWrite(const FileSystemURL& url, |
| 176 const WriteCallback& callback, | 179 const WriteCallback& callback, |
| 177 base::File::Error rv, | 180 base::File::Error rv, |
| 178 int64 bytes, | 181 int64_t bytes, |
| 179 FileWriterDelegate::WriteProgressStatus write_status); | 182 FileWriterDelegate::WriteProgressStatus write_status); |
| 180 | 183 |
| 181 // Used only for internal assertions. | 184 // Used only for internal assertions. |
| 182 // Returns false if there's another inflight pending operation. | 185 // Returns false if there's another inflight pending operation. |
| 183 bool SetPendingOperationType(OperationType type); | 186 bool SetPendingOperationType(OperationType type); |
| 184 | 187 |
| 185 scoped_refptr<FileSystemContext> file_system_context_; | 188 scoped_refptr<FileSystemContext> file_system_context_; |
| 186 | 189 |
| 187 scoped_ptr<FileSystemOperationContext> operation_context_; | 190 scoped_ptr<FileSystemOperationContext> operation_context_; |
| 188 AsyncFileUtil* async_file_util_; // Not owned. | 191 AsyncFileUtil* async_file_util_; // Not owned. |
| 189 | 192 |
| 190 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 193 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| 191 scoped_ptr<RecursiveOperationDelegate> recursive_operation_delegate_; | 194 scoped_ptr<RecursiveOperationDelegate> recursive_operation_delegate_; |
| 192 | 195 |
| 193 StatusCallback cancel_callback_; | 196 StatusCallback cancel_callback_; |
| 194 | 197 |
| 195 // A flag to make sure we call operation only once per instance. | 198 // A flag to make sure we call operation only once per instance. |
| 196 OperationType pending_operation_; | 199 OperationType pending_operation_; |
| 197 | 200 |
| 198 base::WeakPtrFactory<FileSystemOperationImpl> weak_factory_; | 201 base::WeakPtrFactory<FileSystemOperationImpl> weak_factory_; |
| 199 | 202 |
| 200 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationImpl); | 203 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationImpl); |
| 201 }; | 204 }; |
| 202 | 205 |
| 203 } // namespace storage | 206 } // namespace storage |
| 204 | 207 |
| 205 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ | 208 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_IMPL_H_ |
| OLD | NEW |