blob: d4f662827047351a39a501c7ddc44727c06e63e8 [file] [log] [blame]
[email protected]6faad822012-05-11 12:58:291// 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]c6f9203a2013-05-28 02:08:075#ifndef WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_
6#define WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_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]c4298d02013-05-20 05:42:5212#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
[email protected]f25e1132013-05-24 13:58:0413#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
[email protected]bcded8d2012-10-18 09:09:0414#include "webkit/storage/webkit_storage_export.h"
[email protected]6faad822012-05-11 12:58:2915
16namespace base {
17class SequencedTaskRunner;
18}
19
20namespace fileapi {
21
[email protected]25b697992013-01-29 07:10:0522class AsyncFileUtilAdapter;
[email protected]6faad822012-05-11 12:58:2923class 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]bcded8d2012-10-18 09:09:0428class WEBKIT_STORAGE_EXPORT_PRIVATE TestMountPointProvider
[email protected]0b38b4e52012-05-30 08:14:2729 : public FileSystemMountPointProvider {
[email protected]6faad822012-05-11 12:58:2930 public:
[email protected]6faad822012-05-11 12:58:2931 TestMountPointProvider(
32 base::SequencedTaskRunner* task_runner,
[email protected]a3ef4832013-02-02 05:12:3333 const base::FilePath& base_path);
[email protected]6faad822012-05-11 12:58:2934 virtual ~TestMountPointProvider();
35
36 // FileSystemMountPointProvider implementation.
[email protected]420fb562013-04-18 01:46:3437 virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
[email protected]22dea52c2013-05-29 07:44:4038 virtual void OpenFileSystem(
[email protected]6faad822012-05-11 12:58:2939 const GURL& origin_url,
40 FileSystemType type,
[email protected]22dea52c2013-05-29 07:44:4041 OpenFileSystemMode mode,
42 const OpenFileSystemCallback& callback) OVERRIDE;
[email protected]d6afd112012-07-25 22:55:0443 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE;
[email protected]25b697992013-01-29 07:10:0544 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
[email protected]98407ee2013-04-04 08:52:1745 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
46 FileSystemType type,
47 base::PlatformFileError* error_code) OVERRIDE;
[email protected]b40ffe72013-01-10 04:05:3148 virtual FilePermissionPolicy GetPermissionPolicy(
49 const FileSystemURL& url,
50 int permissions) const OVERRIDE;
[email protected]8e3bc3e2012-08-24 13:12:5351 virtual FileSystemOperation* CreateFileSystemOperation(
[email protected]949f25a2012-06-27 01:53:0952 const FileSystemURL& url,
[email protected]d23a00cc2012-09-11 17:38:1353 FileSystemContext* context,
54 base::PlatformFileError* error_code) const OVERRIDE;
[email protected]3ee9eb02013-04-10 09:17:0555 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
[email protected]d5e08552012-08-02 21:43:4056 const FileSystemURL& url,
57 int64 offset,
[email protected]a1057832012-10-15 13:28:0658 const base::Time& expected_modification_time,
[email protected]d5e08552012-08-02 21:43:4059 FileSystemContext* context) const OVERRIDE;
[email protected]3ee9eb02013-04-10 09:17:0560 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
[email protected]d5e08552012-08-02 21:43:4061 const FileSystemURL& url,
62 int64 offset,
63 FileSystemContext* context) const OVERRIDE;
[email protected]6faad822012-05-11 12:58:2964 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
[email protected]d5e08552012-08-02 21:43:4065 virtual void DeleteFileSystem(
66 const GURL& origin_url,
67 FileSystemType type,
68 FileSystemContext* context,
69 const DeleteFileSystemCallback& callback) OVERRIDE;
[email protected]6faad822012-05-11 12:58:2970
[email protected]96f03c42013-05-29 08:51:3271 // Initialize the CopyOrMoveFileValidatorFactory. Invalid to call more than
72 // once.
73 void InitializeCopyOrMoveFileValidatorFactory(
74 scoped_ptr<CopyOrMoveFileValidatorFactory> factory);
75
[email protected]caf66702012-09-07 07:02:2076 const UpdateObserverList* GetUpdateObservers(FileSystemType type) const;
77
[email protected]c3d638b32013-04-22 02:18:4978 // For CopyOrMoveFileValidatorFactory testing. Once it's set to true
79 // GetCopyOrMoveFileValidatorFactory will start returning security
80 // error if validator is not initialized.
81 void set_require_copy_or_move_validator(bool flag) {
82 require_copy_or_move_validator_ = flag;
83 }
84
[email protected]6faad822012-05-11 12:58:2985 private:
[email protected]caf66702012-09-07 07:02:2086 class QuotaUtil;
87
[email protected]a3ef4832013-02-02 05:12:3388 base::FilePath base_path_;
[email protected]caf66702012-09-07 07:02:2089 scoped_refptr<base::SequencedTaskRunner> task_runner_;
[email protected]25b697992013-01-29 07:10:0590 scoped_ptr<AsyncFileUtilAdapter> local_file_util_;
[email protected]caf66702012-09-07 07:02:2091 scoped_ptr<QuotaUtil> quota_util_;
92 UpdateObserverList observers_;
[email protected]c3d638b32013-04-22 02:18:4993
94 bool require_copy_or_move_validator_;
95 scoped_ptr<CopyOrMoveFileValidatorFactory>
96 copy_or_move_file_validator_factory_;
97
98 DISALLOW_COPY_AND_ASSIGN(TestMountPointProvider);
[email protected]6faad822012-05-11 12:58:2999};
100
101} // namespace fileapi
102
[email protected]c6f9203a2013-05-28 02:08:07103#endif // WEBKIT_BROWSER_FILEAPI_TEST_MOUNT_POINT_PROVIDER_H_