| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef WEBKIT_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ | |
| 6 #define WEBKIT_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/files/file_path.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | |
| 12 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | |
| 13 #include "webkit/fileapi/async_file_util_adapter.h" | |
| 14 #include "webkit/storage/webkit_storage_export.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class SequencedTaskRunner; | |
| 18 } | |
| 19 | |
| 20 namespace fileapi { | |
| 21 | |
| 22 class AsyncFileUtilAdapter; | |
| 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. | |
| 28 class WEBKIT_STORAGE_EXPORT_PRIVATE TestMountPointProvider | |
| 29 : public FileSystemMountPointProvider { | |
| 30 public: | |
| 31 TestMountPointProvider( | |
| 32 base::SequencedTaskRunner* task_runner, | |
| 33 const base::FilePath& base_path); | |
| 34 virtual ~TestMountPointProvider(); | |
| 35 | |
| 36 // FileSystemMountPointProvider implementation. | |
| 37 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | |
| 38 virtual void ValidateFileSystemRoot( | |
| 39 const GURL& origin_url, | |
| 40 FileSystemType type, | |
| 41 bool create, | |
| 42 const ValidateFileSystemCallback& callback) OVERRIDE; | |
| 43 virtual base::FilePath GetFileSystemRootPathOnFileThread( | |
| 44 const FileSystemURL& url, | |
| 45 bool create) OVERRIDE; | |
| 46 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; | |
| 47 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | |
| 48 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | |
| 49 FileSystemType type, | |
| 50 base::PlatformFileError* error_code) OVERRIDE; | |
| 51 virtual void InitializeCopyOrMoveFileValidatorFactory( | |
| 52 FileSystemType type, | |
| 53 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) OVERRIDE; | |
| 54 virtual FilePermissionPolicy GetPermissionPolicy( | |
| 55 const FileSystemURL& url, | |
| 56 int permissions) const OVERRIDE; | |
| 57 virtual FileSystemOperation* CreateFileSystemOperation( | |
| 58 const FileSystemURL& url, | |
| 59 FileSystemContext* context, | |
| 60 base::PlatformFileError* error_code) const OVERRIDE; | |
| 61 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | |
| 62 const FileSystemURL& url, | |
| 63 int64 offset, | |
| 64 const base::Time& expected_modification_time, | |
| 65 FileSystemContext* context) const OVERRIDE; | |
| 66 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( | |
| 67 const FileSystemURL& url, | |
| 68 int64 offset, | |
| 69 FileSystemContext* context) const OVERRIDE; | |
| 70 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | |
| 71 virtual void DeleteFileSystem( | |
| 72 const GURL& origin_url, | |
| 73 FileSystemType type, | |
| 74 FileSystemContext* context, | |
| 75 const DeleteFileSystemCallback& callback) OVERRIDE; | |
| 76 | |
| 77 const UpdateObserverList* GetUpdateObservers(FileSystemType type) const; | |
| 78 | |
| 79 // For CopyOrMoveFileValidatorFactory testing. Once it's set to true | |
| 80 // GetCopyOrMoveFileValidatorFactory will start returning security | |
| 81 // error if validator is not initialized. | |
| 82 void set_require_copy_or_move_validator(bool flag) { | |
| 83 require_copy_or_move_validator_ = flag; | |
| 84 } | |
| 85 | |
| 86 private: | |
| 87 class QuotaUtil; | |
| 88 | |
| 89 base::FilePath base_path_; | |
| 90 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
| 91 scoped_ptr<AsyncFileUtilAdapter> local_file_util_; | |
| 92 scoped_ptr<QuotaUtil> quota_util_; | |
| 93 UpdateObserverList observers_; | |
| 94 | |
| 95 bool require_copy_or_move_validator_; | |
| 96 scoped_ptr<CopyOrMoveFileValidatorFactory> | |
| 97 copy_or_move_file_validator_factory_; | |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(TestMountPointProvider); | |
| 100 }; | |
| 101 | |
| 102 } // namespace fileapi | |
| 103 | |
| 104 #endif // WEBKIT_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_ | |
| OLD | NEW |