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