[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | c6f9203a | 2013-05-28 02:08:07 | [diff] [blame] | 5 | #ifndef WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ |
| 6 | #define WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 7 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 8 | #include "base/files/file_path.h" |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
| 10 | #include "base/memory/scoped_ptr.h" |
[email protected] | c6f9203a | 2013-05-28 02:08:07 | [diff] [blame] | 11 | #include "webkit/browser/fileapi/async_file_util_adapter.h" |
[email protected] | c4298d0 | 2013-05-20 05:42:52 | [diff] [blame] | 12 | #include "webkit/browser/fileapi/file_system_mount_point_provider.h" |
[email protected] | f25e113 | 2013-05-24 13:58:04 | [diff] [blame] | 13 | #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
[email protected] | bcded8d | 2012-10-18 09:09:04 | [diff] [blame] | 14 | #include "webkit/storage/webkit_storage_export.h" |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| 17 | class SequencedTaskRunner; |
| 18 | } |
| 19 | |
| 20 | namespace fileapi { |
| 21 | |
[email protected] | 25b69799 | 2013-01-29 07:10:05 | [diff] [blame] | 22 | class AsyncFileUtilAdapter; |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 23 | class FileSystemQuotaUtil; |
| 24 | |
| 25 | // This should be only used for testing. |
| 26 | // This mount point provider uses LocalFileUtil and stores data file |
| 27 | // under the given directory. |
[email protected] | bcded8d | 2012-10-18 09:09:04 | [diff] [blame] | 28 | class WEBKIT_STORAGE_EXPORT_PRIVATE TestMountPointProvider |
[email protected] | 0b38b4e5 | 2012-05-30 08:14:27 | [diff] [blame] | 29 | : public FileSystemMountPointProvider { |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 30 | public: |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 31 | TestMountPointProvider( |
| 32 | base::SequencedTaskRunner* task_runner, |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 33 | const base::FilePath& base_path); |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 34 | virtual ~TestMountPointProvider(); |
| 35 | |
| 36 | // FileSystemMountPointProvider implementation. |
[email protected] | 420fb56 | 2013-04-18 01:46:34 | [diff] [blame] | 37 | virtual bool CanHandleType(FileSystemType type) const OVERRIDE; |
[email protected] | 22dea52c | 2013-05-29 07:44:40 | [diff] [blame] | 38 | virtual void OpenFileSystem( |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 39 | const GURL& origin_url, |
| 40 | FileSystemType type, |
[email protected] | 22dea52c | 2013-05-29 07:44:40 | [diff] [blame] | 41 | OpenFileSystemMode mode, |
| 42 | const OpenFileSystemCallback& callback) OVERRIDE; |
[email protected] | d6afd11 | 2012-07-25 22:55:04 | [diff] [blame] | 43 | virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; |
[email protected] | 25b69799 | 2013-01-29 07:10:05 | [diff] [blame] | 44 | virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; |
[email protected] | 98407ee | 2013-04-04 08:52:17 | [diff] [blame] | 45 | virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( |
| 46 | FileSystemType type, |
| 47 | base::PlatformFileError* error_code) OVERRIDE; |
| 48 | virtual void InitializeCopyOrMoveFileValidatorFactory( |
| 49 | FileSystemType type, |
| 50 | scoped_ptr<CopyOrMoveFileValidatorFactory> factory) OVERRIDE; |
[email protected] | b40ffe7 | 2013-01-10 04:05:31 | [diff] [blame] | 51 | virtual FilePermissionPolicy GetPermissionPolicy( |
| 52 | const FileSystemURL& url, |
| 53 | int permissions) const OVERRIDE; |
[email protected] | 8e3bc3e | 2012-08-24 13:12:53 | [diff] [blame] | 54 | virtual FileSystemOperation* CreateFileSystemOperation( |
[email protected] | 949f25a | 2012-06-27 01:53:09 | [diff] [blame] | 55 | const FileSystemURL& url, |
[email protected] | d23a00cc | 2012-09-11 17:38:13 | [diff] [blame] | 56 | FileSystemContext* context, |
| 57 | base::PlatformFileError* error_code) const OVERRIDE; |
[email protected] | 3ee9eb0 | 2013-04-10 09:17:05 | [diff] [blame] | 58 | virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
[email protected] | d5e0855 | 2012-08-02 21:43:40 | [diff] [blame] | 59 | const FileSystemURL& url, |
| 60 | int64 offset, |
[email protected] | a105783 | 2012-10-15 13:28:06 | [diff] [blame] | 61 | const base::Time& expected_modification_time, |
[email protected] | d5e0855 | 2012-08-02 21:43:40 | [diff] [blame] | 62 | FileSystemContext* context) const OVERRIDE; |
[email protected] | 3ee9eb0 | 2013-04-10 09:17:05 | [diff] [blame] | 63 | virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( |
[email protected] | d5e0855 | 2012-08-02 21:43:40 | [diff] [blame] | 64 | const FileSystemURL& url, |
| 65 | int64 offset, |
| 66 | FileSystemContext* context) const OVERRIDE; |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 67 | virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
[email protected] | d5e0855 | 2012-08-02 21:43:40 | [diff] [blame] | 68 | virtual void DeleteFileSystem( |
| 69 | const GURL& origin_url, |
| 70 | FileSystemType type, |
| 71 | FileSystemContext* context, |
| 72 | const DeleteFileSystemCallback& callback) OVERRIDE; |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 73 | |
[email protected] | caf6670 | 2012-09-07 07:02:20 | [diff] [blame] | 74 | const UpdateObserverList* GetUpdateObservers(FileSystemType type) const; |
| 75 | |
[email protected] | c3d638b3 | 2013-04-22 02:18:49 | [diff] [blame] | 76 | // For CopyOrMoveFileValidatorFactory testing. Once it's set to true |
| 77 | // GetCopyOrMoveFileValidatorFactory will start returning security |
| 78 | // error if validator is not initialized. |
| 79 | void set_require_copy_or_move_validator(bool flag) { |
| 80 | require_copy_or_move_validator_ = flag; |
| 81 | } |
| 82 | |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 83 | private: |
[email protected] | caf6670 | 2012-09-07 07:02:20 | [diff] [blame] | 84 | class QuotaUtil; |
| 85 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 86 | base::FilePath base_path_; |
[email protected] | caf6670 | 2012-09-07 07:02:20 | [diff] [blame] | 87 | scoped_refptr<base::SequencedTaskRunner> task_runner_; |
[email protected] | 25b69799 | 2013-01-29 07:10:05 | [diff] [blame] | 88 | scoped_ptr<AsyncFileUtilAdapter> local_file_util_; |
[email protected] | caf6670 | 2012-09-07 07:02:20 | [diff] [blame] | 89 | scoped_ptr<QuotaUtil> quota_util_; |
| 90 | UpdateObserverList observers_; |
[email protected] | c3d638b3 | 2013-04-22 02:18:49 | [diff] [blame] | 91 | |
| 92 | bool require_copy_or_move_validator_; |
| 93 | scoped_ptr<CopyOrMoveFileValidatorFactory> |
| 94 | copy_or_move_file_validator_factory_; |
| 95 | |
| 96 | DISALLOW_COPY_AND_ASSIGN(TestMountPointProvider); |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace fileapi |
| 100 | |
[email protected] | c6f9203a | 2013-05-28 02:08:07 | [diff] [blame] | 101 | #endif // WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ |