| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "webkit/browser/fileapi/async_file_util.h" | 9 #include "storage/browser/fileapi/async_file_util.h" |
| 10 | 10 |
| 11 namespace fileapi { | 11 namespace storage { |
| 12 | 12 |
| 13 class FileSystemFileUtil; | 13 class FileSystemFileUtil; |
| 14 | 14 |
| 15 // An adapter class for FileSystemFileUtil classes to provide asynchronous | 15 // An adapter class for FileSystemFileUtil classes to provide asynchronous |
| 16 // interface. | 16 // interface. |
| 17 // | 17 // |
| 18 // A filesystem can do either: | 18 // A filesystem can do either: |
| 19 // - implement a synchronous version of FileUtil by extending | 19 // - implement a synchronous version of FileUtil by extending |
| 20 // FileSystemFileUtil and atach it to this adapter, or | 20 // FileSystemFileUtil and atach it to this adapter, or |
| 21 // - directly implement AsyncFileUtil. | 21 // - directly implement AsyncFileUtil. |
| 22 // | 22 // |
| 23 // This instance (as thus this->sync_file_util_) is guaranteed to be alive | 23 // This instance (as thus this->sync_file_util_) is guaranteed to be alive |
| 24 // as far as FileSystemOperationContext given to each operation is kept alive. | 24 // as far as FileSystemOperationContext given to each operation is kept alive. |
| 25 class WEBKIT_STORAGE_BROWSER_EXPORT AsyncFileUtilAdapter | 25 class STORAGE_EXPORT AsyncFileUtilAdapter |
| 26 : public NON_EXPORTED_BASE(AsyncFileUtil) { | 26 : public NON_EXPORTED_BASE(AsyncFileUtil) { |
| 27 public: | 27 public: |
| 28 // Creates a new AsyncFileUtil for |sync_file_util|. This takes the | 28 // Creates a new AsyncFileUtil for |sync_file_util|. This takes the |
| 29 // ownership of |sync_file_util|. (This doesn't take scoped_ptr<> just | 29 // ownership of |sync_file_util|. (This doesn't take scoped_ptr<> just |
| 30 // to save extra make_scoped_ptr; in all use cases a new fresh FileUtil is | 30 // to save extra make_scoped_ptr; in all use cases a new fresh FileUtil is |
| 31 // created only for this adapter.) | 31 // created only for this adapter.) |
| 32 explicit AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util); | 32 explicit AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util); |
| 33 | 33 |
| 34 virtual ~AsyncFileUtilAdapter(); | 34 virtual ~AsyncFileUtilAdapter(); |
| 35 | 35 |
| 36 FileSystemFileUtil* sync_file_util() { | 36 FileSystemFileUtil* sync_file_util() { return sync_file_util_.get(); } |
| 37 return sync_file_util_.get(); | |
| 38 } | |
| 39 | 37 |
| 40 // AsyncFileUtil overrides. | 38 // AsyncFileUtil overrides. |
| 41 virtual void CreateOrOpen( | 39 virtual void CreateOrOpen(scoped_ptr<FileSystemOperationContext> context, |
| 42 scoped_ptr<FileSystemOperationContext> context, | 40 const FileSystemURL& url, |
| 43 const FileSystemURL& url, | 41 int file_flags, |
| 44 int file_flags, | 42 const CreateOrOpenCallback& callback) OVERRIDE; |
| 45 const CreateOrOpenCallback& callback) OVERRIDE; | |
| 46 virtual void EnsureFileExists( | 43 virtual void EnsureFileExists( |
| 47 scoped_ptr<FileSystemOperationContext> context, | 44 scoped_ptr<FileSystemOperationContext> context, |
| 48 const FileSystemURL& url, | 45 const FileSystemURL& url, |
| 49 const EnsureFileExistsCallback& callback) OVERRIDE; | 46 const EnsureFileExistsCallback& callback) OVERRIDE; |
| 50 virtual void CreateDirectory( | 47 virtual void CreateDirectory(scoped_ptr<FileSystemOperationContext> context, |
| 51 scoped_ptr<FileSystemOperationContext> context, | 48 const FileSystemURL& url, |
| 52 const FileSystemURL& url, | 49 bool exclusive, |
| 53 bool exclusive, | 50 bool recursive, |
| 54 bool recursive, | 51 const StatusCallback& callback) OVERRIDE; |
| 55 const StatusCallback& callback) OVERRIDE; | 52 virtual void GetFileInfo(scoped_ptr<FileSystemOperationContext> context, |
| 56 virtual void GetFileInfo( | 53 const FileSystemURL& url, |
| 57 scoped_ptr<FileSystemOperationContext> context, | 54 const GetFileInfoCallback& callback) OVERRIDE; |
| 58 const FileSystemURL& url, | 55 virtual void ReadDirectory(scoped_ptr<FileSystemOperationContext> context, |
| 59 const GetFileInfoCallback& callback) OVERRIDE; | 56 const FileSystemURL& url, |
| 60 virtual void ReadDirectory( | 57 const ReadDirectoryCallback& callback) OVERRIDE; |
| 61 scoped_ptr<FileSystemOperationContext> context, | 58 virtual void Touch(scoped_ptr<FileSystemOperationContext> context, |
| 62 const FileSystemURL& url, | 59 const FileSystemURL& url, |
| 63 const ReadDirectoryCallback& callback) OVERRIDE; | 60 const base::Time& last_access_time, |
| 64 virtual void Touch( | 61 const base::Time& last_modified_time, |
| 65 scoped_ptr<FileSystemOperationContext> context, | 62 const StatusCallback& callback) OVERRIDE; |
| 66 const FileSystemURL& url, | 63 virtual void Truncate(scoped_ptr<FileSystemOperationContext> context, |
| 67 const base::Time& last_access_time, | 64 const FileSystemURL& url, |
| 68 const base::Time& last_modified_time, | 65 int64 length, |
| 69 const StatusCallback& callback) OVERRIDE; | 66 const StatusCallback& callback) OVERRIDE; |
| 70 virtual void Truncate( | 67 virtual void CopyFileLocal(scoped_ptr<FileSystemOperationContext> context, |
| 71 scoped_ptr<FileSystemOperationContext> context, | 68 const FileSystemURL& src_url, |
| 72 const FileSystemURL& url, | 69 const FileSystemURL& dest_url, |
| 73 int64 length, | 70 CopyOrMoveOption option, |
| 74 const StatusCallback& callback) OVERRIDE; | 71 const CopyFileProgressCallback& progress_callback, |
| 75 virtual void CopyFileLocal( | 72 const StatusCallback& callback) OVERRIDE; |
| 76 scoped_ptr<FileSystemOperationContext> context, | 73 virtual void MoveFileLocal(scoped_ptr<FileSystemOperationContext> context, |
| 77 const FileSystemURL& src_url, | 74 const FileSystemURL& src_url, |
| 78 const FileSystemURL& dest_url, | 75 const FileSystemURL& dest_url, |
| 79 CopyOrMoveOption option, | 76 CopyOrMoveOption option, |
| 80 const CopyFileProgressCallback& progress_callback, | 77 const StatusCallback& callback) OVERRIDE; |
| 81 const StatusCallback& callback) OVERRIDE; | 78 virtual void CopyInForeignFile(scoped_ptr<FileSystemOperationContext> context, |
| 82 virtual void MoveFileLocal( | 79 const base::FilePath& src_file_path, |
| 83 scoped_ptr<FileSystemOperationContext> context, | 80 const FileSystemURL& dest_url, |
| 84 const FileSystemURL& src_url, | 81 const StatusCallback& callback) OVERRIDE; |
| 85 const FileSystemURL& dest_url, | 82 virtual void DeleteFile(scoped_ptr<FileSystemOperationContext> context, |
| 86 CopyOrMoveOption option, | 83 const FileSystemURL& url, |
| 87 const StatusCallback& callback) OVERRIDE; | 84 const StatusCallback& callback) OVERRIDE; |
| 88 virtual void CopyInForeignFile( | 85 virtual void DeleteDirectory(scoped_ptr<FileSystemOperationContext> context, |
| 89 scoped_ptr<FileSystemOperationContext> context, | 86 const FileSystemURL& url, |
| 90 const base::FilePath& src_file_path, | 87 const StatusCallback& callback) OVERRIDE; |
| 91 const FileSystemURL& dest_url, | 88 virtual void DeleteRecursively(scoped_ptr<FileSystemOperationContext> context, |
| 92 const StatusCallback& callback) OVERRIDE; | 89 const FileSystemURL& url, |
| 93 virtual void DeleteFile( | 90 const StatusCallback& callback) OVERRIDE; |
| 94 scoped_ptr<FileSystemOperationContext> context, | |
| 95 const FileSystemURL& url, | |
| 96 const StatusCallback& callback) OVERRIDE; | |
| 97 virtual void DeleteDirectory( | |
| 98 scoped_ptr<FileSystemOperationContext> context, | |
| 99 const FileSystemURL& url, | |
| 100 const StatusCallback& callback) OVERRIDE; | |
| 101 virtual void DeleteRecursively( | |
| 102 scoped_ptr<FileSystemOperationContext> context, | |
| 103 const FileSystemURL& url, | |
| 104 const StatusCallback& callback) OVERRIDE; | |
| 105 virtual void CreateSnapshotFile( | 91 virtual void CreateSnapshotFile( |
| 106 scoped_ptr<FileSystemOperationContext> context, | 92 scoped_ptr<FileSystemOperationContext> context, |
| 107 const FileSystemURL& url, | 93 const FileSystemURL& url, |
| 108 const CreateSnapshotFileCallback& callback) OVERRIDE; | 94 const CreateSnapshotFileCallback& callback) OVERRIDE; |
| 109 | 95 |
| 110 private: | 96 private: |
| 111 scoped_ptr<FileSystemFileUtil> sync_file_util_; | 97 scoped_ptr<FileSystemFileUtil> sync_file_util_; |
| 112 | 98 |
| 113 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtilAdapter); | 99 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtilAdapter); |
| 114 }; | 100 }; |
| 115 | 101 |
| 116 } // namespace fileapi | 102 } // namespace storage |
| 117 | 103 |
| 118 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ | 104 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_ |
| OLD | NEW |