Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / test / sandbox_file_system_test_helper.h
blob2edac67e71de0b4059fe0eef4bd9005c6c20ed84
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_
6 #define CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "storage/browser/fileapi/file_system_url.h"
13 #include "storage/browser/fileapi/file_system_usage_cache.h"
14 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
15 #include "storage/common/fileapi/file_system_types.h"
16 #include "storage/common/fileapi/file_system_util.h"
17 #include "storage/common/quota/quota_types.h"
18 #include "url/gurl.h"
20 namespace base {
21 class FilePath;
24 namespace storage {
25 class QuotaManagerProxy;
28 namespace storage {
29 class FileSystemContext;
30 class FileSystemFileUtil;
31 class FileSystemOperationContext;
32 class FileSystemOperationRunner;
35 namespace content {
37 // Filesystem test helper class that encapsulates test environment for
38 // a given {origin, type} pair. This helper only works for sandboxed
39 // file systems (Temporary or Persistent).
40 class SandboxFileSystemTestHelper {
41 public:
42 SandboxFileSystemTestHelper(const GURL& origin, storage::FileSystemType type);
43 SandboxFileSystemTestHelper();
44 ~SandboxFileSystemTestHelper();
46 void SetUp(const base::FilePath& base_dir);
47 // If you want to use more than one SandboxFileSystemTestHelper in
48 // a single base directory, they have to share a context, so that they don't
49 // have multiple databases fighting over the lock to the origin directory
50 // [deep down inside ObfuscatedFileUtil].
51 void SetUp(storage::FileSystemContext* file_system_context);
52 void SetUp(const base::FilePath& base_dir,
53 storage::QuotaManagerProxy* quota_manager_proxy);
54 void TearDown();
56 base::FilePath GetOriginRootPath();
57 base::FilePath GetLocalPath(const base::FilePath& path);
58 base::FilePath GetLocalPathFromASCII(const std::string& path);
60 // Returns empty path if filesystem type is neither temporary nor persistent.
61 base::FilePath GetUsageCachePath() const;
63 storage::FileSystemURL CreateURL(const base::FilePath& path) const;
64 storage::FileSystemURL CreateURLFromUTF8(const std::string& utf8) const {
65 return CreateURL(base::FilePath::FromUTF8Unsafe(utf8));
68 // This returns cached usage size returned by QuotaUtil.
69 int64 GetCachedOriginUsage() const;
71 // This doesn't work with OFSFU.
72 int64 ComputeCurrentOriginUsage();
74 int64 ComputeCurrentDirectoryDatabaseUsage();
76 storage::FileSystemOperationRunner* operation_runner();
77 storage::FileSystemOperationContext* NewOperationContext();
79 void AddFileChangeObserver(storage::FileChangeObserver* observer);
80 void AddFileUpdateObserver(storage::FileUpdateObserver* observer);
82 storage::FileSystemContext* file_system_context() const {
83 return file_system_context_.get();
86 const GURL& origin() const { return origin_; }
87 storage::FileSystemType type() const { return type_; }
88 storage::StorageType storage_type() const {
89 return storage::FileSystemTypeToQuotaStorageType(type_);
91 storage::FileSystemFileUtil* file_util() const { return file_util_; }
92 storage::FileSystemUsageCache* usage_cache();
94 private:
95 void SetUpFileSystem();
97 scoped_refptr<storage::FileSystemContext> file_system_context_;
99 const GURL origin_;
100 const storage::FileSystemType type_;
101 storage::FileSystemFileUtil* file_util_;
104 } // namespace content
106 #endif // CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_