OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 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 WEBKIT_BROWSER_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | 18 #include "webkit/browser/fileapi/file_system_backend.h" |
19 #include "webkit/browser/fileapi/file_system_options.h" | 19 #include "webkit/browser/fileapi/file_system_options.h" |
20 #include "webkit/browser/fileapi/file_system_quota_util.h" | 20 #include "webkit/browser/fileapi/file_system_quota_util.h" |
21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | 21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
22 #include "webkit/browser/quota/special_storage_policy.h" | 22 #include "webkit/browser/quota/special_storage_policy.h" |
23 #include "webkit/browser/webkit_storage_browser_export.h" | 23 #include "webkit/browser/webkit_storage_browser_export.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class SequencedTaskRunner; | 26 class SequencedTaskRunner; |
27 } | 27 } |
28 | 28 |
(...skipping 13 matching lines...) Expand all Loading... |
42 class FileSystemUsageCache; | 42 class FileSystemUsageCache; |
43 class LocalFileSystemOperation; | 43 class LocalFileSystemOperation; |
44 class ObfuscatedFileUtil; | 44 class ObfuscatedFileUtil; |
45 class SandboxQuotaObserver; | 45 class SandboxQuotaObserver; |
46 | 46 |
47 // An interface to construct or crack sandboxed filesystem paths for | 47 // An interface to construct or crack sandboxed filesystem paths for |
48 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's | 48 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's |
49 // profile directory in a sandboxed way. | 49 // profile directory in a sandboxed way. |
50 // This interface also lets one enumerate and remove storage for the origins | 50 // This interface also lets one enumerate and remove storage for the origins |
51 // that use the filesystem. | 51 // that use the filesystem. |
52 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxMountPointProvider | 52 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend |
53 : public FileSystemMountPointProvider, | 53 : public FileSystemBackend, |
54 public FileSystemQuotaUtil { | 54 public FileSystemQuotaUtil { |
55 public: | 55 public: |
56 // Origin enumerator interface. | 56 // Origin enumerator interface. |
57 // An instance of this interface is assumed to be called on the file thread. | 57 // An instance of this interface is assumed to be called on the file thread. |
58 class OriginEnumerator { | 58 class OriginEnumerator { |
59 public: | 59 public: |
60 virtual ~OriginEnumerator() {} | 60 virtual ~OriginEnumerator() {} |
61 | 61 |
62 // Returns the next origin. Returns empty if there are no more origins. | 62 // Returns the next origin. Returns empty if there are no more origins. |
63 virtual GURL Next() = 0; | 63 virtual GURL Next() = 0; |
64 | 64 |
65 // Returns the current origin's information. | 65 // Returns the current origin's information. |
66 virtual bool HasFileSystemType(FileSystemType type) const = 0; | 66 virtual bool HasFileSystemType(FileSystemType type) const = 0; |
67 }; | 67 }; |
68 | 68 |
69 // The FileSystem directory name. | 69 // The FileSystem directory name. |
70 static const base::FilePath::CharType kFileSystemDirectory[]; | 70 static const base::FilePath::CharType kFileSystemDirectory[]; |
71 | 71 |
72 // |file_task_runner| is used to validate the root directory and delete the | 72 // |file_task_runner| is used to validate the root directory and delete the |
73 // obfuscated file util. | 73 // obfuscated file util. |
74 SandboxMountPointProvider( | 74 SandboxFileSystemBackend( |
75 quota::QuotaManagerProxy* quota_manager_proxy, | 75 quota::QuotaManagerProxy* quota_manager_proxy, |
76 base::SequencedTaskRunner* file_task_runner, | 76 base::SequencedTaskRunner* file_task_runner, |
77 const base::FilePath& profile_path, | 77 const base::FilePath& profile_path, |
78 const FileSystemOptions& file_system_options, | 78 const FileSystemOptions& file_system_options, |
79 quota::SpecialStoragePolicy* special_storage_policy); | 79 quota::SpecialStoragePolicy* special_storage_policy); |
80 virtual ~SandboxMountPointProvider(); | 80 virtual ~SandboxFileSystemBackend(); |
81 | 81 |
82 // FileSystemMountPointProvider overrides. | 82 // FileSystemBackend overrides. |
83 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | 83 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; |
84 virtual void OpenFileSystem( | 84 virtual void OpenFileSystem( |
85 const GURL& origin_url, | 85 const GURL& origin_url, |
86 FileSystemType type, | 86 FileSystemType type, |
87 OpenFileSystemMode mode, | 87 OpenFileSystemMode mode, |
88 const OpenFileSystemCallback& callback) OVERRIDE; | 88 const OpenFileSystemCallback& callback) OVERRIDE; |
89 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; | 89 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; |
90 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | 90 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; |
91 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | 91 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( |
92 FileSystemType type, | 92 FileSystemType type, |
93 base::PlatformFileError* error_code) OVERRIDE; | 93 base::PlatformFileError* error_code) OVERRIDE; |
94 virtual FileSystemOperation* CreateFileSystemOperation( | 94 virtual FileSystemOperation* CreateFileSystemOperation( |
95 const FileSystemURL& url, | 95 const FileSystemURL& url, |
96 FileSystemContext* context, | 96 FileSystemContext* context, |
97 base::PlatformFileError* error_code) const OVERRIDE; | 97 base::PlatformFileError* error_code) const OVERRIDE; |
98 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 98 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
99 const FileSystemURL& url, | 99 const FileSystemURL& url, |
100 int64 offset, | 100 int64 offset, |
101 const base::Time& expected_modification_time, | 101 const base::Time& expected_modification_time, |
102 FileSystemContext* context) const OVERRIDE; | 102 FileSystemContext* context) const OVERRIDE; |
103 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( | 103 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( |
104 const FileSystemURL& url, | 104 const FileSystemURL& url, |
105 int64 offset, | 105 int64 offset, |
106 FileSystemContext* context) const OVERRIDE; | 106 FileSystemContext* context) const OVERRIDE; |
107 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 107 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
108 | 108 |
109 // Returns an origin enumerator of this provider. | 109 // Returns an origin enumerator of this backend. |
110 // This method can only be called on the file thread. | 110 // This method can only be called on the file thread. |
111 OriginEnumerator* CreateOriginEnumerator(); | 111 OriginEnumerator* CreateOriginEnumerator(); |
112 | 112 |
113 // Gets a base directory path of the sandboxed filesystem that is | 113 // Gets a base directory path of the sandboxed filesystem that is |
114 // specified by |origin_url| and |type|. | 114 // specified by |origin_url| and |type|. |
115 // (The path is similar to the origin's root path but doesn't contain | 115 // (The path is similar to the origin's root path but doesn't contain |
116 // the 'unique' part.) | 116 // the 'unique' part.) |
117 // Returns an empty path if the given type is invalid. | 117 // Returns an empty path if the given type is invalid. |
118 // This method can only be called on the file thread. | 118 // This method can only be called on the file thread. |
119 base::FilePath GetBaseDirectoryForOriginAndType( | 119 base::FilePath GetBaseDirectoryForOriginAndType( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Returns true if access to |url| is valid in this filesystem. | 161 // Returns true if access to |url| is valid in this filesystem. |
162 bool IsAccessValid(const FileSystemURL& url) const; | 162 bool IsAccessValid(const FileSystemURL& url) const; |
163 | 163 |
164 void set_enable_temporary_file_system_in_incognito(bool enable) { | 164 void set_enable_temporary_file_system_in_incognito(bool enable) { |
165 enable_temporary_file_system_in_incognito_ = enable; | 165 enable_temporary_file_system_in_incognito_ = enable; |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 friend class SandboxQuotaObserver; | 169 friend class SandboxQuotaObserver; |
170 friend class SandboxFileSystemTestHelper; | 170 friend class SandboxFileSystemTestHelper; |
171 friend class SandboxMountPointProviderMigrationTest; | 171 friend class SandboxFileSystemBackendMigrationTest; |
172 friend class SandboxMountPointProviderOriginEnumeratorTest; | 172 friend class SandboxFileSystemBackendOriginEnumeratorTest; |
173 | 173 |
174 // Returns a path to the usage cache file. | 174 // Returns a path to the usage cache file. |
175 base::FilePath GetUsageCachePathForOriginAndType( | 175 base::FilePath GetUsageCachePathForOriginAndType( |
176 const GURL& origin_url, | 176 const GURL& origin_url, |
177 FileSystemType type); | 177 FileSystemType type); |
178 | 178 |
179 // Returns a path to the usage cache file (static version). | 179 // Returns a path to the usage cache file (static version). |
180 static base::FilePath GetUsageCachePathForOriginAndType( | 180 static base::FilePath GetUsageCachePathForOriginAndType( |
181 ObfuscatedFileUtil* sandbox_file_util, | 181 ObfuscatedFileUtil* sandbox_file_util, |
182 const GURL& origin_url, | 182 const GURL& origin_url, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_; | 233 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_; |
234 | 234 |
235 // Indicates if the usage tracking for FileSystem is enabled or not. | 235 // Indicates if the usage tracking for FileSystem is enabled or not. |
236 // The usage tracking is enabled by default and can be disabled by | 236 // The usage tracking is enabled by default and can be disabled by |
237 // a command-line switch (--disable-file-system-usage-tracking). | 237 // a command-line switch (--disable-file-system-usage-tracking). |
238 bool enable_usage_tracking_; | 238 bool enable_usage_tracking_; |
239 | 239 |
240 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 240 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
241 | 241 |
242 base::WeakPtrFactory<SandboxMountPointProvider> weak_factory_; | 242 base::WeakPtrFactory<SandboxFileSystemBackend> weak_factory_; |
243 | 243 |
244 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 244 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); |
245 }; | 245 }; |
246 | 246 |
247 } // namespace fileapi | 247 } // namespace fileapi |
248 | 248 |
249 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 249 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |