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_OBFUSCATED_FILE_UTIL_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util_proxy.h" | 12 #include "base/files/file_util_proxy.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
15 #include "base/timer.h" | 15 #include "base/timer.h" |
16 #include "webkit/browser/fileapi/file_system_file_util.h" | 16 #include "webkit/browser/fileapi/file_system_file_util.h" |
17 #include "webkit/browser/fileapi/file_system_url.h" | 17 #include "webkit/browser/fileapi/file_system_url.h" |
18 #include "webkit/browser/fileapi/sandbox_directory_database.h" | 18 #include "webkit/browser/fileapi/sandbox_directory_database.h" |
19 #include "webkit/browser/fileapi/sandbox_origin_database.h" | |
20 #include "webkit/common/blob/shareable_file_reference.h" | 19 #include "webkit/common/blob/shareable_file_reference.h" |
21 #include "webkit/common/fileapi/file_system_types.h" | 20 #include "webkit/common/fileapi/file_system_types.h" |
22 #include "webkit/storage/webkit_storage_export.h" | 21 #include "webkit/storage/webkit_storage_export.h" |
23 | 22 |
24 namespace base { | 23 namespace base { |
25 class Time; | 24 class Time; |
26 } | 25 } |
27 | 26 |
| 27 namespace quota { |
| 28 class SpecialStoragePolicy; |
| 29 } |
| 30 |
28 class GURL; | 31 class GURL; |
29 | 32 |
30 namespace fileapi { | 33 namespace fileapi { |
31 | 34 |
32 class FileSystemOperationContext; | 35 class FileSystemOperationContext; |
| 36 class SandboxOriginDatabaseInterface; |
33 | 37 |
34 // The overall implementation philosophy of this class is that partial failures | 38 // The overall implementation philosophy of this class is that partial failures |
35 // should leave us with an intact database; we'd prefer to leak the occasional | 39 // should leave us with an intact database; we'd prefer to leak the occasional |
36 // backing file than have a database entry whose backing file is missing. When | 40 // backing file than have a database entry whose backing file is missing. When |
37 // doing FSCK operations, if you find a loose backing file with no reference, | 41 // doing FSCK operations, if you find a loose backing file with no reference, |
38 // you may safely delete it. | 42 // you may safely delete it. |
39 // | 43 // |
40 // This class must be deleted on the FILE thread, because that's where | 44 // This class must be deleted on the FILE thread, because that's where |
41 // DropDatabases needs to be called. | 45 // DropDatabases needs to be called. |
42 class WEBKIT_STORAGE_EXPORT_PRIVATE ObfuscatedFileUtil | 46 class WEBKIT_STORAGE_EXPORT_PRIVATE ObfuscatedFileUtil |
43 : public FileSystemFileUtil { | 47 : public FileSystemFileUtil { |
44 public: | 48 public: |
45 // Origin enumerator interface. | 49 // Origin enumerator interface. |
46 // An instance of this interface is assumed to be called on the file thread. | 50 // An instance of this interface is assumed to be called on the file thread. |
47 class AbstractOriginEnumerator { | 51 class AbstractOriginEnumerator { |
48 public: | 52 public: |
49 virtual ~AbstractOriginEnumerator() {} | 53 virtual ~AbstractOriginEnumerator() {} |
50 | 54 |
51 // Returns the next origin. Returns empty if there are no more origins. | 55 // Returns the next origin. Returns empty if there are no more origins. |
52 virtual GURL Next() = 0; | 56 virtual GURL Next() = 0; |
53 | 57 |
54 // Returns the current origin's information. | 58 // Returns the current origin's information. |
55 virtual bool HasFileSystemType(FileSystemType type) const = 0; | 59 virtual bool HasFileSystemType(FileSystemType type) const = 0; |
56 }; | 60 }; |
57 | 61 |
58 explicit ObfuscatedFileUtil(const base::FilePath& file_system_directory); | 62 ObfuscatedFileUtil( |
| 63 quota::SpecialStoragePolicy* special_storage_policy, |
| 64 const base::FilePath& file_system_directory); |
59 virtual ~ObfuscatedFileUtil(); | 65 virtual ~ObfuscatedFileUtil(); |
60 | 66 |
61 // FileSystemFileUtil overrides. | 67 // FileSystemFileUtil overrides. |
62 virtual base::PlatformFileError CreateOrOpen( | 68 virtual base::PlatformFileError CreateOrOpen( |
63 FileSystemOperationContext* context, | 69 FileSystemOperationContext* context, |
64 const FileSystemURL& url, | 70 const FileSystemURL& url, |
65 int file_flags, | 71 int file_flags, |
66 base::PlatformFile* file_handle, | 72 base::PlatformFile* file_handle, |
67 bool* created) OVERRIDE; | 73 bool* created) OVERRIDE; |
68 virtual base::PlatformFileError Close( | 74 virtual base::PlatformFileError Close( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 249 |
244 base::PlatformFileError CreateOrOpenInternal( | 250 base::PlatformFileError CreateOrOpenInternal( |
245 FileSystemOperationContext* context, | 251 FileSystemOperationContext* context, |
246 const FileSystemURL& url, | 252 const FileSystemURL& url, |
247 int file_flags, | 253 int file_flags, |
248 base::PlatformFile* file_handle, | 254 base::PlatformFile* file_handle, |
249 bool* created); | 255 bool* created); |
250 | 256 |
251 typedef std::map<std::string, SandboxDirectoryDatabase*> DirectoryMap; | 257 typedef std::map<std::string, SandboxDirectoryDatabase*> DirectoryMap; |
252 DirectoryMap directories_; | 258 DirectoryMap directories_; |
253 scoped_ptr<SandboxOriginDatabase> origin_database_; | 259 scoped_ptr<SandboxOriginDatabaseInterface> origin_database_; |
| 260 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
254 base::FilePath file_system_directory_; | 261 base::FilePath file_system_directory_; |
255 base::OneShotTimer<ObfuscatedFileUtil> timer_; | 262 base::OneShotTimer<ObfuscatedFileUtil> timer_; |
256 | 263 |
| 264 // If this instance is initialized for an isolated origin, this should |
| 265 // only see a single origin. |
| 266 GURL isolated_origin_; |
| 267 |
257 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtil); | 268 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtil); |
258 }; | 269 }; |
259 | 270 |
260 } // namespace fileapi | 271 } // namespace fileapi |
261 | 272 |
262 #endif // WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ | 273 #endif // WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ |
OLD | NEW |