| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LOCAL_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| 6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace fileapi { | 27 namespace fileapi { |
| 28 | 28 |
| 29 class AsyncFileUtil; | 29 class AsyncFileUtil; |
| 30 class FileSystemContext; | 30 class FileSystemContext; |
| 31 class RecursiveOperationDelegate; | 31 class RecursiveOperationDelegate; |
| 32 | 32 |
| 33 // FileSystemOperation implementation for local file systems. | 33 // FileSystemOperation implementation for local file systems. |
| 34 class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation | 34 class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
| 35 : public NON_EXPORTED_BASE(FileSystemOperation) { | 35 : public NON_EXPORTED_BASE(FileSystemOperation) { |
| 36 public: | 36 public: |
| 37 // NOTE: This constructor should not be called outside MountPointProviders; |
| 38 // instead please consider using |
| 39 // file_system_context->CreateFileSystemOperation() to instantiate |
| 40 // an appropriate FileSystemOperation. |
| 41 LocalFileSystemOperation( |
| 42 FileSystemContext* file_system_context, |
| 43 scoped_ptr<FileSystemOperationContext> operation_context); |
| 44 |
| 37 virtual ~LocalFileSystemOperation(); | 45 virtual ~LocalFileSystemOperation(); |
| 38 | 46 |
| 39 // FileSystemOperation overrides. | 47 // FileSystemOperation overrides. |
| 40 virtual void CreateFile(const FileSystemURL& url, | 48 virtual void CreateFile(const FileSystemURL& url, |
| 41 bool exclusive, | 49 bool exclusive, |
| 42 const StatusCallback& callback) OVERRIDE; | 50 const StatusCallback& callback) OVERRIDE; |
| 43 virtual void CreateDirectory(const FileSystemURL& url, | 51 virtual void CreateDirectory(const FileSystemURL& url, |
| 44 bool exclusive, | 52 bool exclusive, |
| 45 bool recursive, | 53 bool recursive, |
| 46 const StatusCallback& callback) OVERRIDE; | 54 const StatusCallback& callback) OVERRIDE; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // its parent path is a file. | 159 // its parent path is a file. |
| 152 // | 160 // |
| 153 void MoveFileLocal(const FileSystemURL& src_url, | 161 void MoveFileLocal(const FileSystemURL& src_url, |
| 154 const FileSystemURL& dest_url, | 162 const FileSystemURL& dest_url, |
| 155 const StatusCallback& callback); | 163 const StatusCallback& callback); |
| 156 | 164 |
| 157 // Synchronously gets the platform path for the given |url|. | 165 // Synchronously gets the platform path for the given |url|. |
| 158 void SyncGetPlatformPath(const FileSystemURL& url, | 166 void SyncGetPlatformPath(const FileSystemURL& url, |
| 159 base::FilePath* platform_path); | 167 base::FilePath* platform_path); |
| 160 | 168 |
| 161 private: | |
| 162 enum OperationMode { | |
| 163 OPERATION_MODE_READ, | |
| 164 OPERATION_MODE_WRITE, | |
| 165 }; | |
| 166 | |
| 167 // Only MountPointProviders or testing class can create a | |
| 168 // new operation directly. | |
| 169 friend class FileSystemTestHelper; | |
| 170 friend class IsolatedMountPointProvider; | |
| 171 friend class SandboxMountPointProvider; | |
| 172 friend class TestMountPointProvider; | |
| 173 friend class chromeos::CrosMountPointProvider; | |
| 174 | |
| 175 friend class LocalFileSystemOperationTest; | |
| 176 friend class LocalFileSystemOperationWriteTest; | |
| 177 friend class FileWriterDelegateTest; | |
| 178 friend class FileSystemQuotaTest; | |
| 179 friend class LocalFileSystemTestOriginHelper; | |
| 180 | |
| 181 friend class RecursiveOperationDelegate; | |
| 182 friend class CrossOperationDelegate; | |
| 183 friend class sync_file_system::SyncableFileSystemOperation; | |
| 184 | |
| 185 LocalFileSystemOperation( | |
| 186 FileSystemContext* file_system_context, | |
| 187 scoped_ptr<FileSystemOperationContext> operation_context); | |
| 188 | |
| 189 FileSystemContext* file_system_context() const { | 169 FileSystemContext* file_system_context() const { |
| 190 return file_system_context_; | 170 return file_system_context_; |
| 191 } | 171 } |
| 192 | 172 |
| 193 FileSystemOperationContext* operation_context() const { | 173 FileSystemOperationContext* operation_context() const { |
| 194 if (parent_operation_) | 174 if (parent_operation_) |
| 195 return parent_operation_->operation_context(); | 175 return parent_operation_->operation_context(); |
| 196 return operation_context_.get(); | 176 return operation_context_.get(); |
| 197 } | 177 } |
| 198 | 178 |
| 179 private: |
| 180 enum OperationMode { |
| 181 OPERATION_MODE_READ, |
| 182 OPERATION_MODE_WRITE, |
| 183 }; |
| 184 |
| 185 friend class sync_file_system::SyncableFileSystemOperation; |
| 186 |
| 199 // Queries the quota and usage and then runs the given |task|. | 187 // Queries the quota and usage and then runs the given |task|. |
| 200 // If an error occurs during the quota query it runs |error_callback| instead. | 188 // If an error occurs during the quota query it runs |error_callback| instead. |
| 201 void GetUsageAndQuotaThenRunTask( | 189 void GetUsageAndQuotaThenRunTask( |
| 202 const FileSystemURL& url, | 190 const FileSystemURL& url, |
| 203 const base::Closure& task, | 191 const base::Closure& task, |
| 204 const base::Closure& error_callback); | 192 const base::Closure& error_callback); |
| 205 | 193 |
| 206 // Called after the quota info is obtained from the quota manager | 194 // Called after the quota info is obtained from the quota manager |
| 207 // (which is triggered by GetUsageAndQuotaThenRunTask). | 195 // (which is triggered by GetUsageAndQuotaThenRunTask). |
| 208 // Sets the quota info in the operation_context_ and then runs the given | 196 // Sets the quota info in the operation_context_ and then runs the given |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 297 |
| 310 scoped_refptr<FileSystemContext> file_system_context_; | 298 scoped_refptr<FileSystemContext> file_system_context_; |
| 311 | 299 |
| 312 scoped_ptr<FileSystemOperationContext> operation_context_; | 300 scoped_ptr<FileSystemOperationContext> operation_context_; |
| 313 AsyncFileUtil* async_file_util_; // Not owned. | 301 AsyncFileUtil* async_file_util_; // Not owned. |
| 314 | 302 |
| 315 // If this operation is created as a sub-operation for nested operation, | 303 // If this operation is created as a sub-operation for nested operation, |
| 316 // this holds non-null value and points to the parent operation. | 304 // this holds non-null value and points to the parent operation. |
| 317 // TODO(kinuko): Cleanup this when we finish cleaning up the | 305 // TODO(kinuko): Cleanup this when we finish cleaning up the |
| 318 // FileSystemOperation lifetime issue. | 306 // FileSystemOperation lifetime issue. |
| 319 LocalFileSystemOperation* parent_operation_; | 307 base::WeakPtr<LocalFileSystemOperation> parent_operation_; |
| 320 | 308 |
| 321 // These are all used only by Write(). | 309 // These are all used only by Write(). |
| 322 friend class FileWriterDelegate; | 310 friend class FileWriterDelegate; |
| 323 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 311 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| 324 | 312 |
| 325 scoped_ptr<RecursiveOperationDelegate> recursive_operation_delegate_; | 313 scoped_ptr<RecursiveOperationDelegate> recursive_operation_delegate_; |
| 326 | 314 |
| 327 // write_callback is kept in this class for so that we can dispatch it when | 315 // write_callback is kept in this class for so that we can dispatch it when |
| 328 // the operation is cancelled. calcel_callback is kept for canceling a | 316 // the operation is cancelled. calcel_callback is kept for canceling a |
| 329 // Truncate() operation. We can't actually stop Truncate in another thread; | 317 // Truncate() operation. We can't actually stop Truncate in another thread; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 345 // LocalFileSystemOperation instance is usually deleted upon completion but | 333 // LocalFileSystemOperation instance is usually deleted upon completion but |
| 346 // could be deleted while it has inflight callbacks when Cancel is called. | 334 // could be deleted while it has inflight callbacks when Cancel is called. |
| 347 base::WeakPtrFactory<LocalFileSystemOperation> weak_factory_; | 335 base::WeakPtrFactory<LocalFileSystemOperation> weak_factory_; |
| 348 | 336 |
| 349 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperation); | 337 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperation); |
| 350 }; | 338 }; |
| 351 | 339 |
| 352 } // namespace fileapi | 340 } // namespace fileapi |
| 353 | 341 |
| 354 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ | 342 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |