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

Side by Side Diff: storage/browser/fileapi/sandbox_file_system_backend_delegate.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "webkit/browser/fileapi/file_system_backend.h" 20 #include "storage/browser/fileapi/file_system_backend.h"
21 #include "webkit/browser/fileapi/file_system_options.h" 21 #include "storage/browser/fileapi/file_system_options.h"
22 #include "webkit/browser/fileapi/file_system_quota_util.h" 22 #include "storage/browser/fileapi/file_system_quota_util.h"
23 #include "webkit/browser/webkit_storage_browser_export.h" 23 #include "storage/common/storage_export.h"
24 24
25 namespace base { 25 namespace base {
26 class SequencedTaskRunner; 26 class SequencedTaskRunner;
27 } 27 }
28 28
29 namespace content { 29 namespace content {
30 class SandboxFileSystemBackendDelegateTest; 30 class SandboxFileSystemBackendDelegateTest;
31 class SandboxFileSystemTestHelper; 31 class SandboxFileSystemTestHelper;
32 } 32 }
33 33
34 namespace quota { 34 namespace quota {
35 class QuotaManagerProxy; 35 class QuotaManagerProxy;
36 class SpecialStoragePolicy; 36 class SpecialStoragePolicy;
37 } 37 }
38 38
39 namespace webkit_blob { 39 namespace storage {
40 class FileStreamReader; 40 class FileStreamReader;
41 } 41 }
42 42
43 namespace fileapi { 43 namespace storage {
44 44
45 class AsyncFileUtil; 45 class AsyncFileUtil;
46 class FileStreamWriter; 46 class FileStreamWriter;
47 class FileSystemFileUtil; 47 class FileSystemFileUtil;
48 class FileSystemOperationContext; 48 class FileSystemOperationContext;
49 class FileSystemURL; 49 class FileSystemURL;
50 class FileSystemUsageCache; 50 class FileSystemUsageCache;
51 class ObfuscatedFileUtil; 51 class ObfuscatedFileUtil;
52 class QuotaReservationManager; 52 class QuotaReservationManager;
53 class SandboxFileSystemBackend; 53 class SandboxFileSystemBackend;
54 class SandboxQuotaObserver; 54 class SandboxQuotaObserver;
55 55
56 // Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend. 56 // Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend.
57 // An instance of this class is created and owned by FileSystemContext. 57 // An instance of this class is created and owned by FileSystemContext.
58 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate 58 class STORAGE_EXPORT SandboxFileSystemBackendDelegate
59 : public FileSystemQuotaUtil { 59 : public FileSystemQuotaUtil {
60 public: 60 public:
61 typedef FileSystemBackend::OpenFileSystemCallback OpenFileSystemCallback; 61 typedef FileSystemBackend::OpenFileSystemCallback OpenFileSystemCallback;
62 62
63 // The FileSystem directory name. 63 // The FileSystem directory name.
64 static const base::FilePath::CharType kFileSystemDirectory[]; 64 static const base::FilePath::CharType kFileSystemDirectory[];
65 65
66 // Origin enumerator interface. 66 // Origin enumerator interface.
67 // An instance of this interface is assumed to be called on the file thread. 67 // An instance of this interface is assumed to be called on the file thread.
68 class OriginEnumerator { 68 class OriginEnumerator {
(...skipping 22 matching lines...) Expand all
91 // Returns an origin enumerator of sandbox filesystem. 91 // Returns an origin enumerator of sandbox filesystem.
92 // This method can only be called on the file thread. 92 // This method can only be called on the file thread.
93 OriginEnumerator* CreateOriginEnumerator(); 93 OriginEnumerator* CreateOriginEnumerator();
94 94
95 // Gets a base directory path of the sandboxed filesystem that is 95 // Gets a base directory path of the sandboxed filesystem that is
96 // specified by |origin_url| and |type|. 96 // specified by |origin_url| and |type|.
97 // (The path is similar to the origin's root path but doesn't contain 97 // (The path is similar to the origin's root path but doesn't contain
98 // the 'unique' part.) 98 // the 'unique' part.)
99 // Returns an empty path if the given type is invalid. 99 // Returns an empty path if the given type is invalid.
100 // This method can only be called on the file thread. 100 // This method can only be called on the file thread.
101 base::FilePath GetBaseDirectoryForOriginAndType( 101 base::FilePath GetBaseDirectoryForOriginAndType(const GURL& origin_url,
102 const GURL& origin_url, 102 FileSystemType type,
103 FileSystemType type, 103 bool create);
104 bool create);
105 104
106 // FileSystemBackend helpers. 105 // FileSystemBackend helpers.
107 void OpenFileSystem( 106 void OpenFileSystem(const GURL& origin_url,
108 const GURL& origin_url, 107 FileSystemType type,
109 FileSystemType type, 108 OpenFileSystemMode mode,
110 OpenFileSystemMode mode, 109 const OpenFileSystemCallback& callback,
111 const OpenFileSystemCallback& callback, 110 const GURL& root_url);
112 const GURL& root_url);
113 scoped_ptr<FileSystemOperationContext> CreateFileSystemOperationContext( 111 scoped_ptr<FileSystemOperationContext> CreateFileSystemOperationContext(
114 const FileSystemURL& url, 112 const FileSystemURL& url,
115 FileSystemContext* context, 113 FileSystemContext* context,
116 base::File::Error* error_code) const; 114 base::File::Error* error_code) const;
117 scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( 115 scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
118 const FileSystemURL& url, 116 const FileSystemURL& url,
119 int64 offset, 117 int64 offset,
120 const base::Time& expected_modification_time, 118 const base::Time& expected_modification_time,
121 FileSystemContext* context) const; 119 FileSystemContext* context) const;
122 scoped_ptr<FileStreamWriter> CreateFileStreamWriter( 120 scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
123 const FileSystemURL& url, 121 const FileSystemURL& url,
124 int64 offset, 122 int64 offset,
125 FileSystemContext* context, 123 FileSystemContext* context,
126 FileSystemType type) const; 124 FileSystemType type) const;
127 125
128 // FileSystemQuotaUtil overrides. 126 // FileSystemQuotaUtil overrides.
129 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( 127 virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
130 FileSystemContext* context, 128 FileSystemContext* context,
131 quota::QuotaManagerProxy* proxy, 129 quota::QuotaManagerProxy* proxy,
132 const GURL& origin_url, 130 const GURL& origin_url,
133 FileSystemType type) OVERRIDE; 131 FileSystemType type) OVERRIDE;
134 virtual void GetOriginsForTypeOnFileTaskRunner( 132 virtual void GetOriginsForTypeOnFileTaskRunner(
135 FileSystemType type, 133 FileSystemType type,
136 std::set<GURL>* origins) OVERRIDE; 134 std::set<GURL>* origins) OVERRIDE;
137 virtual void GetOriginsForHostOnFileTaskRunner( 135 virtual void GetOriginsForHostOnFileTaskRunner(
138 FileSystemType type, 136 FileSystemType type,
139 const std::string& host, 137 const std::string& host,
140 std::set<GURL>* origins) OVERRIDE; 138 std::set<GURL>* origins) OVERRIDE;
141 virtual int64 GetOriginUsageOnFileTaskRunner( 139 virtual int64 GetOriginUsageOnFileTaskRunner(FileSystemContext* context,
142 FileSystemContext* context, 140 const GURL& origin_url,
143 const GURL& origin_url, 141 FileSystemType type) OVERRIDE;
144 FileSystemType type) OVERRIDE;
145 virtual scoped_refptr<QuotaReservation> 142 virtual scoped_refptr<QuotaReservation>
146 CreateQuotaReservationOnFileTaskRunner( 143 CreateQuotaReservationOnFileTaskRunner(const GURL& origin_url,
147 const GURL& origin_url, 144 FileSystemType type) OVERRIDE;
148 FileSystemType type) OVERRIDE;
149 virtual void AddFileUpdateObserver( 145 virtual void AddFileUpdateObserver(
150 FileSystemType type, 146 FileSystemType type,
151 FileUpdateObserver* observer, 147 FileUpdateObserver* observer,
152 base::SequencedTaskRunner* task_runner) OVERRIDE; 148 base::SequencedTaskRunner* task_runner) OVERRIDE;
153 virtual void AddFileChangeObserver( 149 virtual void AddFileChangeObserver(
154 FileSystemType type, 150 FileSystemType type,
155 FileChangeObserver* observer, 151 FileChangeObserver* observer,
156 base::SequencedTaskRunner* task_runner) OVERRIDE; 152 base::SequencedTaskRunner* task_runner) OVERRIDE;
157 virtual void AddFileAccessObserver( 153 virtual void AddFileAccessObserver(
158 FileSystemType type, 154 FileSystemType type,
159 FileAccessObserver* observer, 155 FileAccessObserver* observer,
160 base::SequencedTaskRunner* task_runner) OVERRIDE; 156 base::SequencedTaskRunner* task_runner) OVERRIDE;
161 virtual const UpdateObserverList* GetUpdateObservers( 157 virtual const UpdateObserverList* GetUpdateObservers(
162 FileSystemType type) const OVERRIDE; 158 FileSystemType type) const OVERRIDE;
163 virtual const ChangeObserverList* GetChangeObservers( 159 virtual const ChangeObserverList* GetChangeObservers(
164 FileSystemType type) const OVERRIDE; 160 FileSystemType type) const OVERRIDE;
165 virtual const AccessObserverList* GetAccessObservers( 161 virtual const AccessObserverList* GetAccessObservers(
166 FileSystemType type) const OVERRIDE; 162 FileSystemType type) const OVERRIDE;
167 163
168 // Registers quota observer for file updates on filesystem of |type|. 164 // Registers quota observer for file updates on filesystem of |type|.
169 void RegisterQuotaUpdateObserver(FileSystemType type); 165 void RegisterQuotaUpdateObserver(FileSystemType type);
170 166
171 void InvalidateUsageCache(const GURL& origin_url, 167 void InvalidateUsageCache(const GURL& origin_url, FileSystemType type);
172 FileSystemType type); 168 void StickyInvalidateUsageCache(const GURL& origin_url, FileSystemType type);
173 void StickyInvalidateUsageCache(const GURL& origin_url,
174 FileSystemType type);
175 169
176 void CollectOpenFileSystemMetrics(base::File::Error error_code); 170 void CollectOpenFileSystemMetrics(base::File::Error error_code);
177 171
178 base::SequencedTaskRunner* file_task_runner() { 172 base::SequencedTaskRunner* file_task_runner() {
179 return file_task_runner_.get(); 173 return file_task_runner_.get();
180 } 174 }
181 175
182 AsyncFileUtil* file_util() { return sandbox_file_util_.get(); } 176 AsyncFileUtil* file_util() { return sandbox_file_util_.get(); }
183 FileSystemUsageCache* usage_cache() { return file_system_usage_cache_.get(); } 177 FileSystemUsageCache* usage_cache() { return file_system_usage_cache_.get(); }
184 SandboxQuotaObserver* quota_observer() { return quota_observer_.get(); } 178 SandboxQuotaObserver* quota_observer() { return quota_observer_.get(); }
(...skipping 16 matching lines...) Expand all
201 195
202 // Performs API-specific validity checks on the given path |url|. 196 // Performs API-specific validity checks on the given path |url|.
203 // Returns true if access to |url| is valid in this filesystem. 197 // Returns true if access to |url| is valid in this filesystem.
204 bool IsAccessValid(const FileSystemURL& url) const; 198 bool IsAccessValid(const FileSystemURL& url) const;
205 199
206 // Returns true if the given |url|'s scheme is allowed to access 200 // Returns true if the given |url|'s scheme is allowed to access
207 // filesystem. 201 // filesystem.
208 bool IsAllowedScheme(const GURL& url) const; 202 bool IsAllowedScheme(const GURL& url) const;
209 203
210 // Returns a path to the usage cache file. 204 // Returns a path to the usage cache file.
211 base::FilePath GetUsageCachePathForOriginAndType( 205 base::FilePath GetUsageCachePathForOriginAndType(const GURL& origin_url,
212 const GURL& origin_url, 206 FileSystemType type);
213 FileSystemType type);
214 207
215 // Returns a path to the usage cache file (static version). 208 // Returns a path to the usage cache file (static version).
216 static base::FilePath GetUsageCachePathForOriginAndType( 209 static base::FilePath GetUsageCachePathForOriginAndType(
217 ObfuscatedFileUtil* sandbox_file_util, 210 ObfuscatedFileUtil* sandbox_file_util,
218 const GURL& origin_url, 211 const GURL& origin_url,
219 FileSystemType type, 212 FileSystemType type,
220 base::File::Error* error_out); 213 base::File::Error* error_out);
221 214
222 int64 RecalculateUsage(FileSystemContext* context, 215 int64 RecalculateUsage(FileSystemContext* context,
223 const GURL& origin, 216 const GURL& origin,
(...skipping 24 matching lines...) Expand all
248 std::map<FileSystemType, ChangeObserverList> change_observers_; 241 std::map<FileSystemType, ChangeObserverList> change_observers_;
249 std::map<FileSystemType, AccessObserverList> access_observers_; 242 std::map<FileSystemType, AccessObserverList> access_observers_;
250 243
251 base::Time next_release_time_for_open_filesystem_stat_; 244 base::Time next_release_time_for_open_filesystem_stat_;
252 245
253 base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_; 246 base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_;
254 247
255 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate); 248 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate);
256 }; 249 };
257 250
258 } // namespace fileapi 251 } // namespace storage
259 252
260 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ 253 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698