| 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 CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "webkit/browser/fileapi/async_file_util_adapter.h" | 11 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
| 12 #include "webkit/browser/fileapi/file_system_backend.h" | 12 #include "webkit/browser/fileapi/file_system_backend.h" |
| 13 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | 13 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace fileapi { |
| 20 | |
| 21 class AsyncFileUtilAdapter; | 20 class AsyncFileUtilAdapter; |
| 22 class FileSystemQuotaUtil; | 21 class FileSystemQuotaUtil; |
| 22 } |
| 23 |
| 24 namespace content { |
| 23 | 25 |
| 24 // This should be only used for testing. | 26 // This should be only used for testing. |
| 25 // This file system backend uses LocalFileUtil and stores data file | 27 // This file system backend uses LocalFileUtil and stores data file |
| 26 // under the given directory. | 28 // under the given directory. |
| 27 class TestFileSystemBackend : public FileSystemBackend { | 29 class TestFileSystemBackend : public fileapi::FileSystemBackend { |
| 28 public: | 30 public: |
| 29 TestFileSystemBackend( | 31 TestFileSystemBackend( |
| 30 base::SequencedTaskRunner* task_runner, | 32 base::SequencedTaskRunner* task_runner, |
| 31 const base::FilePath& base_path); | 33 const base::FilePath& base_path); |
| 32 virtual ~TestFileSystemBackend(); | 34 virtual ~TestFileSystemBackend(); |
| 33 | 35 |
| 34 // FileSystemBackend implementation. | 36 // FileSystemBackend implementation. |
| 35 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | 37 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; |
| 36 virtual void Initialize(FileSystemContext* context) OVERRIDE; | 38 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; |
| 37 virtual void OpenFileSystem( | 39 virtual void OpenFileSystem( |
| 38 const GURL& origin_url, | 40 const GURL& origin_url, |
| 39 FileSystemType type, | 41 fileapi::FileSystemType type, |
| 40 OpenFileSystemMode mode, | 42 fileapi::OpenFileSystemMode mode, |
| 41 const OpenFileSystemCallback& callback) OVERRIDE; | 43 const OpenFileSystemCallback& callback) OVERRIDE; |
| 42 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | 44 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil( |
| 43 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | 45 fileapi::FileSystemType type) OVERRIDE; |
| 44 FileSystemType type, | 46 virtual fileapi::CopyOrMoveFileValidatorFactory* |
| 47 GetCopyOrMoveFileValidatorFactory( |
| 48 fileapi::FileSystemType type, |
| 45 base::PlatformFileError* error_code) OVERRIDE; | 49 base::PlatformFileError* error_code) OVERRIDE; |
| 46 virtual FileSystemOperation* CreateFileSystemOperation( | 50 virtual fileapi::FileSystemOperation* CreateFileSystemOperation( |
| 47 const FileSystemURL& url, | 51 const fileapi::FileSystemURL& url, |
| 48 FileSystemContext* context, | 52 fileapi::FileSystemContext* context, |
| 49 base::PlatformFileError* error_code) const OVERRIDE; | 53 base::PlatformFileError* error_code) const OVERRIDE; |
| 50 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 54 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
| 51 const FileSystemURL& url, | 55 const fileapi::FileSystemURL& url, |
| 52 int64 offset, | 56 int64 offset, |
| 53 const base::Time& expected_modification_time, | 57 const base::Time& expected_modification_time, |
| 54 FileSystemContext* context) const OVERRIDE; | 58 fileapi::FileSystemContext* context) const OVERRIDE; |
| 55 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( | 59 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( |
| 56 const FileSystemURL& url, | 60 const fileapi::FileSystemURL& url, |
| 57 int64 offset, | 61 int64 offset, |
| 58 FileSystemContext* context) const OVERRIDE; | 62 fileapi::FileSystemContext* context) const OVERRIDE; |
| 59 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 63 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
| 60 | 64 |
| 61 // Initialize the CopyOrMoveFileValidatorFactory. Invalid to call more than | 65 // Initialize the CopyOrMoveFileValidatorFactory. Invalid to call more than |
| 62 // once. | 66 // once. |
| 63 void InitializeCopyOrMoveFileValidatorFactory( | 67 void InitializeCopyOrMoveFileValidatorFactory( |
| 64 scoped_ptr<CopyOrMoveFileValidatorFactory> factory); | 68 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory); |
| 65 | 69 |
| 66 const UpdateObserverList* GetUpdateObservers(FileSystemType type) const; | 70 const fileapi::UpdateObserverList* |
| 67 void AddFileChangeObserver(FileChangeObserver* observer); | 71 GetUpdateObservers(fileapi::FileSystemType type) const; |
| 72 void AddFileChangeObserver(fileapi::FileChangeObserver* observer); |
| 68 | 73 |
| 69 // For CopyOrMoveFileValidatorFactory testing. Once it's set to true | 74 // For CopyOrMoveFileValidatorFactory testing. Once it's set to true |
| 70 // GetCopyOrMoveFileValidatorFactory will start returning security | 75 // GetCopyOrMoveFileValidatorFactory will start returning security |
| 71 // error if validator is not initialized. | 76 // error if validator is not initialized. |
| 72 void set_require_copy_or_move_validator(bool flag) { | 77 void set_require_copy_or_move_validator(bool flag) { |
| 73 require_copy_or_move_validator_ = flag; | 78 require_copy_or_move_validator_ = flag; |
| 74 } | 79 } |
| 75 | 80 |
| 76 private: | 81 private: |
| 77 class QuotaUtil; | 82 class QuotaUtil; |
| 78 | 83 |
| 79 base::FilePath base_path_; | 84 base::FilePath base_path_; |
| 80 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 85 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 81 scoped_ptr<AsyncFileUtilAdapter> file_util_; | 86 scoped_ptr<fileapi::AsyncFileUtilAdapter> file_util_; |
| 82 scoped_ptr<QuotaUtil> quota_util_; | 87 scoped_ptr<QuotaUtil> quota_util_; |
| 83 | 88 |
| 84 bool require_copy_or_move_validator_; | 89 bool require_copy_or_move_validator_; |
| 85 scoped_ptr<CopyOrMoveFileValidatorFactory> | 90 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> |
| 86 copy_or_move_file_validator_factory_; | 91 copy_or_move_file_validator_factory_; |
| 87 | 92 |
| 88 DISALLOW_COPY_AND_ASSIGN(TestFileSystemBackend); | 93 DISALLOW_COPY_AND_ASSIGN(TestFileSystemBackend); |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 } // namespace fileapi | 96 } // namespace content |
| 92 | 97 |
| 93 #endif // CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ | 98 #endif // CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_ |
| OLD | NEW |