Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/public/test/sandbox_file_system_test_helper.h

Issue 2368913003: Populate storage_unittests target. (Closed)
Patch Set: Removed unnecessary include from storage/browser/blob/blob_storage_context_unittest.cc. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_
6 #define CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "storage/browser/fileapi/file_system_url.h"
15 #include "storage/browser/fileapi/file_system_usage_cache.h"
16 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
17 #include "storage/common/fileapi/file_system_types.h"
18 #include "storage/common/fileapi/file_system_util.h"
19 #include "storage/common/quota/quota_types.h"
20 #include "url/gurl.h"
21
22 namespace base {
23 class FilePath;
24 }
25
26 namespace storage {
27 class QuotaManagerProxy;
28 }
29
30 namespace storage {
31 class FileSystemContext;
32 class FileSystemFileUtil;
33 class FileSystemOperationContext;
34 class FileSystemOperationRunner;
35 }
36
37 namespace content {
38
39 // Filesystem test helper class that encapsulates test environment for
40 // a given {origin, type} pair. This helper only works for sandboxed
41 // file systems (Temporary or Persistent).
42 class SandboxFileSystemTestHelper {
43 public:
44 SandboxFileSystemTestHelper(const GURL& origin, storage::FileSystemType type);
45 SandboxFileSystemTestHelper();
46 ~SandboxFileSystemTestHelper();
47
48 void SetUp(const base::FilePath& base_dir);
49 // If you want to use more than one SandboxFileSystemTestHelper in
50 // a single base directory, they have to share a context, so that they don't
51 // have multiple databases fighting over the lock to the origin directory
52 // [deep down inside ObfuscatedFileUtil].
53 void SetUp(storage::FileSystemContext* file_system_context);
54 void SetUp(const base::FilePath& base_dir,
55 storage::QuotaManagerProxy* quota_manager_proxy);
56 void TearDown();
57
58 base::FilePath GetOriginRootPath();
59 base::FilePath GetLocalPath(const base::FilePath& path);
60 base::FilePath GetLocalPathFromASCII(const std::string& path);
61
62 // Returns empty path if filesystem type is neither temporary nor persistent.
63 base::FilePath GetUsageCachePath() const;
64
65 storage::FileSystemURL CreateURL(const base::FilePath& path) const;
66 storage::FileSystemURL CreateURLFromUTF8(const std::string& utf8) const {
67 return CreateURL(base::FilePath::FromUTF8Unsafe(utf8));
68 }
69
70 // This returns cached usage size returned by QuotaUtil.
71 int64_t GetCachedOriginUsage() const;
72
73 // This doesn't work with OFSFU.
74 int64_t ComputeCurrentOriginUsage();
75
76 int64_t ComputeCurrentDirectoryDatabaseUsage();
77
78 storage::FileSystemOperationRunner* operation_runner();
79 storage::FileSystemOperationContext* NewOperationContext();
80
81 void AddFileChangeObserver(storage::FileChangeObserver* observer);
82 void AddFileUpdateObserver(storage::FileUpdateObserver* observer);
83
84 storage::FileSystemContext* file_system_context() const {
85 return file_system_context_.get();
86 }
87
88 const GURL& origin() const { return origin_; }
89 storage::FileSystemType type() const { return type_; }
90 storage::StorageType storage_type() const {
91 return storage::FileSystemTypeToQuotaStorageType(type_);
92 }
93 storage::FileSystemFileUtil* file_util() const { return file_util_; }
94 storage::FileSystemUsageCache* usage_cache();
95
96 private:
97 void SetUpFileSystem();
98
99 scoped_refptr<storage::FileSystemContext> file_system_context_;
100
101 const GURL origin_;
102 const storage::FileSystemType type_;
103 storage::FileSystemFileUtil* file_util_;
104 };
105
106 } // namespace content
107
108 #endif // CONTENT_PUBLIC_TEST_SANDBOX_FILE_SYSTEM_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « content/public/test/mock_storage_client.cc ('k') | content/public/test/sandbox_file_system_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698