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_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_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> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SandboxFileSystemBackend( | 69 SandboxFileSystemBackend( |
70 SandboxContext* sandbox_context, | 70 SandboxContext* sandbox_context, |
| 71 base::SequencedTaskRunner* file_task_runner, |
71 const FileSystemOptions& file_system_options); | 72 const FileSystemOptions& file_system_options); |
72 virtual ~SandboxFileSystemBackend(); | 73 virtual ~SandboxFileSystemBackend(); |
73 | 74 |
74 // FileSystemBackend overrides. | 75 // FileSystemBackend overrides. |
75 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | 76 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; |
76 virtual void InitializeFileSystem( | 77 virtual void InitializeFileSystem( |
77 const GURL& origin_url, | 78 const GURL& origin_url, |
78 FileSystemType type, | 79 FileSystemType type, |
79 OpenFileSystemMode mode, | 80 OpenFileSystemMode mode, |
80 FileSystemContext* context, | 81 FileSystemContext* context, |
81 const InitializeFileSystemCallback& callback) OVERRIDE; | 82 const InitializeFileSystemCallback& callback) OVERRIDE; |
82 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; | 83 virtual FileSystemFileUtil* GetFileUtil( |
83 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | 84 FileSystemType type, |
| 85 const FileSystemContext* context) OVERRIDE; |
| 86 virtual AsyncFileUtil* GetAsyncFileUtil( |
| 87 FileSystemType type, |
| 88 const FileSystemContext* context) OVERRIDE; |
84 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | 89 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( |
85 FileSystemType type, | 90 FileSystemType type, |
86 base::PlatformFileError* error_code) OVERRIDE; | 91 base::PlatformFileError* error_code) OVERRIDE; |
87 virtual FileSystemOperation* CreateFileSystemOperation( | 92 virtual FileSystemOperation* CreateFileSystemOperation( |
88 const FileSystemURL& url, | 93 const FileSystemURL& url, |
89 FileSystemContext* context, | 94 FileSystemContext* context, |
90 base::PlatformFileError* error_code) const OVERRIDE; | 95 base::PlatformFileError* error_code) const OVERRIDE; |
91 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 96 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
92 const FileSystemURL& url, | 97 const FileSystemURL& url, |
93 int64 offset, | 98 int64 offset, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void CollectOpenFileSystemMetrics(base::PlatformFileError error_code); | 164 void CollectOpenFileSystemMetrics(base::PlatformFileError error_code); |
160 | 165 |
161 // Performs API-specific validity checks on the given path |url|. | 166 // Performs API-specific validity checks on the given path |url|. |
162 // Returns true if access to |url| is valid in this filesystem. | 167 // Returns true if access to |url| is valid in this filesystem. |
163 bool IsAccessValid(const FileSystemURL& url) const; | 168 bool IsAccessValid(const FileSystemURL& url) const; |
164 | 169 |
165 void set_enable_temporary_file_system_in_incognito(bool enable) { | 170 void set_enable_temporary_file_system_in_incognito(bool enable) { |
166 enable_temporary_file_system_in_incognito_ = enable; | 171 enable_temporary_file_system_in_incognito_ = enable; |
167 } | 172 } |
168 | 173 |
| 174 protected: |
| 175 SandboxContext* sandbox_context_; // Not owned. |
| 176 |
| 177 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 178 |
| 179 // Observers. |
| 180 UpdateObserverList update_observers_; |
| 181 ChangeObserverList change_observers_; |
| 182 AccessObserverList access_observers_; |
| 183 |
| 184 // Indicates if the usage tracking for FileSystem is enabled or not. |
| 185 // The usage tracking is enabled by default and can be disabled by |
| 186 // a command-line switch (--disable-file-system-usage-tracking). |
| 187 bool enable_usage_tracking_; |
| 188 |
169 private: | 189 private: |
170 friend class SandboxQuotaObserver; | 190 friend class SandboxQuotaObserver; |
171 friend class SandboxFileSystemTestHelper; | 191 friend class SandboxFileSystemTestHelper; |
172 friend class SandboxFileSystemBackendMigrationTest; | 192 friend class SandboxFileSystemBackendMigrationTest; |
173 friend class SandboxFileSystemBackendOriginEnumeratorTest; | 193 friend class SandboxFileSystemBackendOriginEnumeratorTest; |
174 | 194 |
175 // Returns a path to the usage cache file. | 195 // Returns a path to the usage cache file. |
176 base::FilePath GetUsageCachePathForOriginAndType( | 196 base::FilePath GetUsageCachePathForOriginAndType( |
177 const GURL& origin_url, | 197 const GURL& origin_url, |
178 FileSystemType type); | 198 FileSystemType type); |
(...skipping 15 matching lines...) Expand all Loading... |
194 static void InvalidateUsageCacheOnFileThread( | 214 static void InvalidateUsageCacheOnFileThread( |
195 ObfuscatedFileUtil* file_util, | 215 ObfuscatedFileUtil* file_util, |
196 const GURL& origin, | 216 const GURL& origin, |
197 FileSystemType type, | 217 FileSystemType type, |
198 FileSystemUsageCache* usage_cache); | 218 FileSystemUsageCache* usage_cache); |
199 | 219 |
200 int64 RecalculateUsage(FileSystemContext* context, | 220 int64 RecalculateUsage(FileSystemContext* context, |
201 const GURL& origin, | 221 const GURL& origin, |
202 FileSystemType type); | 222 FileSystemType type); |
203 | 223 |
204 SandboxContext* sandbox_context_; // Not owned. | |
205 | |
206 FileSystemOptions file_system_options_; | 224 FileSystemOptions file_system_options_; |
207 bool enable_temporary_file_system_in_incognito_; | 225 bool enable_temporary_file_system_in_incognito_; |
208 | 226 |
209 // Acccessed only on the file thread. | 227 // Acccessed only on the file thread. |
210 std::set<GURL> visited_origins_; | 228 std::set<GURL> visited_origins_; |
211 | 229 |
212 // Observers. | |
213 UpdateObserverList update_observers_; | |
214 ChangeObserverList change_observers_; | |
215 AccessObserverList access_observers_; | |
216 | |
217 // Observers for syncable file systems. | |
218 UpdateObserverList syncable_update_observers_; | |
219 ChangeObserverList syncable_change_observers_; | |
220 | |
221 base::Time next_release_time_for_open_filesystem_stat_; | 230 base::Time next_release_time_for_open_filesystem_stat_; |
222 | 231 |
223 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_; | 232 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_; |
224 | 233 |
225 // Indicates if the usage tracking for FileSystem is enabled or not. | |
226 // The usage tracking is enabled by default and can be disabled by | |
227 // a command-line switch (--disable-file-system-usage-tracking). | |
228 bool enable_usage_tracking_; | |
229 | |
230 base::WeakPtrFactory<SandboxFileSystemBackend> weak_factory_; | 234 base::WeakPtrFactory<SandboxFileSystemBackend> weak_factory_; |
231 | 235 |
232 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); | 236 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); |
233 }; | 237 }; |
234 | 238 |
235 } // namespace fileapi | 239 } // namespace fileapi |
236 | 240 |
237 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ | 241 #endif /// WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |