blob: 9ce56fb912e905d92f21a5a4f2208102e05d1d0d [file] [log] [blame]
[email protected]d77ecbf62013-10-02 06:43:081// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]6faad822012-05-11 12:58:292// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]d77ecbf62013-10-02 06:43:085#ifndef CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_
6#define CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_
[email protected]6faad822012-05-11 12:58:297
[email protected]57999812013-02-24 05:40:528#include "base/files/file_path.h"
[email protected]6faad822012-05-11 12:58:299#include "base/memory/ref_counted.h"
10#include "base/memory/scoped_ptr.h"
[email protected]c6f9203a2013-05-28 02:08:0711#include "webkit/browser/fileapi/async_file_util_adapter.h"
[email protected]f19bbf62013-07-09 01:22:3212#include "webkit/browser/fileapi/file_system_backend.h"
[email protected]f25e1132013-05-24 13:58:0413#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
[email protected]6faad822012-05-11 12:58:2914
15namespace base {
16class SequencedTaskRunner;
17}
18
19namespace fileapi {
[email protected]25b697992013-01-29 07:10:0520class AsyncFileUtilAdapter;
[email protected]6faad822012-05-11 12:58:2921class FileSystemQuotaUtil;
[email protected]7ade66ee2014-01-16 17:35:5322}
23
24namespace content {
[email protected]6faad822012-05-11 12:58:2925
26// This should be only used for testing.
[email protected]f19bbf62013-07-09 01:22:3227// This file system backend uses LocalFileUtil and stores data file
[email protected]6faad822012-05-11 12:58:2928// under the given directory.
[email protected]7ade66ee2014-01-16 17:35:5329class TestFileSystemBackend : public fileapi::FileSystemBackend {
[email protected]6faad822012-05-11 12:58:2930 public:
[email protected]f19bbf62013-07-09 01:22:3231 TestFileSystemBackend(
[email protected]6faad822012-05-11 12:58:2932 base::SequencedTaskRunner* task_runner,
[email protected]a3ef4832013-02-02 05:12:3333 const base::FilePath& base_path);
[email protected]f19bbf62013-07-09 01:22:3234 virtual ~TestFileSystemBackend();
[email protected]6faad822012-05-11 12:58:2935
[email protected]f19bbf62013-07-09 01:22:3236 // FileSystemBackend implementation.
[email protected]7ade66ee2014-01-16 17:35:5337 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
38 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
[email protected]3fc17aed2013-07-24 10:01:5039 virtual void OpenFileSystem(
[email protected]6faad822012-05-11 12:58:2940 const GURL& origin_url,
[email protected]7ade66ee2014-01-16 17:35:5341 fileapi::FileSystemType type,
42 fileapi::OpenFileSystemMode mode,
[email protected]3fc17aed2013-07-24 10:01:5043 const OpenFileSystemCallback& callback) OVERRIDE;
[email protected]7ade66ee2014-01-16 17:35:5344 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
45 fileapi::FileSystemType type) OVERRIDE;
46 virtual fileapi::CopyOrMoveFileValidatorFactory*
47 GetCopyOrMoveFileValidatorFactory(
48 fileapi::FileSystemType type,
[email protected]141bcc52014-01-27 21:36:0049 base::File::Error* error_code) OVERRIDE;
[email protected]7ade66ee2014-01-16 17:35:5350 virtual fileapi::FileSystemOperation* CreateFileSystemOperation(
51 const fileapi::FileSystemURL& url,
52 fileapi::FileSystemContext* context,
[email protected]141bcc52014-01-27 21:36:0053 base::File::Error* error_code) const OVERRIDE;
[email protected]3ee9eb02013-04-10 09:17:0554 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
[email protected]7ade66ee2014-01-16 17:35:5355 const fileapi::FileSystemURL& url,
[email protected]d5e08552012-08-02 21:43:4056 int64 offset,
[email protected]a1057832012-10-15 13:28:0657 const base::Time& expected_modification_time,
[email protected]7ade66ee2014-01-16 17:35:5358 fileapi::FileSystemContext* context) const OVERRIDE;
59 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
60 const fileapi::FileSystemURL& url,
[email protected]d5e08552012-08-02 21:43:4061 int64 offset,
[email protected]7ade66ee2014-01-16 17:35:5362 fileapi::FileSystemContext* context) const OVERRIDE;
63 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
[email protected]6faad822012-05-11 12:58:2964
[email protected]96f03c42013-05-29 08:51:3265 // Initialize the CopyOrMoveFileValidatorFactory. Invalid to call more than
66 // once.
67 void InitializeCopyOrMoveFileValidatorFactory(
[email protected]7ade66ee2014-01-16 17:35:5368 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory);
[email protected]96f03c42013-05-29 08:51:3269
[email protected]7ade66ee2014-01-16 17:35:5370 const fileapi::UpdateObserverList*
71 GetUpdateObservers(fileapi::FileSystemType type) const;
72 void AddFileChangeObserver(fileapi::FileChangeObserver* observer);
[email protected]caf66702012-09-07 07:02:2073
[email protected]c3d638b32013-04-22 02:18:4974 // For CopyOrMoveFileValidatorFactory testing. Once it's set to true
75 // GetCopyOrMoveFileValidatorFactory will start returning security
76 // error if validator is not initialized.
77 void set_require_copy_or_move_validator(bool flag) {
78 require_copy_or_move_validator_ = flag;
79 }
80
[email protected]6faad822012-05-11 12:58:2981 private:
[email protected]caf66702012-09-07 07:02:2082 class QuotaUtil;
83
[email protected]a3ef4832013-02-02 05:12:3384 base::FilePath base_path_;
[email protected]caf66702012-09-07 07:02:2085 scoped_refptr<base::SequencedTaskRunner> task_runner_;
[email protected]7ade66ee2014-01-16 17:35:5386 scoped_ptr<fileapi::AsyncFileUtilAdapter> file_util_;
[email protected]caf66702012-09-07 07:02:2087 scoped_ptr<QuotaUtil> quota_util_;
[email protected]c3d638b32013-04-22 02:18:4988
89 bool require_copy_or_move_validator_;
[email protected]7ade66ee2014-01-16 17:35:5390 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory>
[email protected]c3d638b32013-04-22 02:18:4991 copy_or_move_file_validator_factory_;
92
[email protected]f19bbf62013-07-09 01:22:3293 DISALLOW_COPY_AND_ASSIGN(TestFileSystemBackend);
[email protected]6faad822012-05-11 12:58:2994};
95
[email protected]7ade66ee2014-01-16 17:35:5396} // namespace content
[email protected]6faad822012-05-11 12:58:2997
[email protected]d77ecbf62013-10-02 06:43:0898#endif // CONTENT_PUBLIC_TEST_TEST_FILE_SYSTEM_BACKEND_H_