| 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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util_proxy.h" | 16 #include "base/files/file_util_proxy.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "webkit/browser/fileapi/file_system_file_util.h" | 19 #include "storage/browser/fileapi/file_system_file_util.h" |
| 20 #include "webkit/browser/fileapi/file_system_url.h" | 20 #include "storage/browser/fileapi/file_system_url.h" |
| 21 #include "webkit/browser/fileapi/sandbox_directory_database.h" | 21 #include "storage/browser/fileapi/sandbox_directory_database.h" |
| 22 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" | 22 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h" |
| 23 #include "webkit/browser/webkit_storage_browser_export.h" | 23 #include "storage/common/storage_export.h" |
| 24 #include "webkit/common/blob/shareable_file_reference.h" | 24 #include "storage/common/blob/shareable_file_reference.h" |
| 25 #include "webkit/common/fileapi/file_system_types.h" | 25 #include "storage/common/fileapi/file_system_types.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class SequencedTaskRunner; | 28 class SequencedTaskRunner; |
| 29 class TimeTicks; | 29 class TimeTicks; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 class ObfuscatedFileUtilTest; | 33 class ObfuscatedFileUtilTest; |
| 34 class QuotaBackendImplTest; | 34 class QuotaBackendImplTest; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace quota { | 37 namespace quota { |
| 38 class SpecialStoragePolicy; | 38 class SpecialStoragePolicy; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class GURL; | 41 class GURL; |
| 42 | 42 |
| 43 namespace fileapi { | 43 namespace storage { |
| 44 | 44 |
| 45 class FileSystemOperationContext; | 45 class FileSystemOperationContext; |
| 46 class SandboxOriginDatabaseInterface; | 46 class SandboxOriginDatabaseInterface; |
| 47 class TimedTaskHelper; | 47 class TimedTaskHelper; |
| 48 | 48 |
| 49 // This file util stores directory information in LevelDB to obfuscate | 49 // This file util stores directory information in LevelDB to obfuscate |
| 50 // and to neutralize virtual file paths given by arbitrary apps. | 50 // and to neutralize virtual file paths given by arbitrary apps. |
| 51 // Files are stored with two-level isolation: per-origin and per-type. | 51 // Files are stored with two-level isolation: per-origin and per-type. |
| 52 // The isolation is done by storing data in separate directory partitions. | 52 // The isolation is done by storing data in separate directory partitions. |
| 53 // For example, a file in Temporary file system for origin 'www.example.com' | 53 // For example, a file in Temporary file system for origin 'www.example.com' |
| 54 // is stored in a different partition for a file in Persistent file system | 54 // is stored in a different partition for a file in Persistent file system |
| 55 // for the same origin, or for Temporary file system for another origin. | 55 // for the same origin, or for Temporary file system for another origin. |
| 56 // | 56 // |
| 57 // * Per-origin directory name information is stored in a separate LevelDB, | 57 // * Per-origin directory name information is stored in a separate LevelDB, |
| 58 // which is maintained by SandboxOriginDatabase. | 58 // which is maintained by SandboxOriginDatabase. |
| 59 // * Per-type directory name information is given by | 59 // * Per-type directory name information is given by |
| 60 // GetTypeStringForURLCallback that is given in CTOR. | 60 // GetTypeStringForURLCallback that is given in CTOR. |
| 61 // We use a small static mapping (e.g. 't' for Temporary type) for | 61 // We use a small static mapping (e.g. 't' for Temporary type) for |
| 62 // regular sandbox filesystems. | 62 // regular sandbox filesystems. |
| 63 // | 63 // |
| 64 // The overall implementation philosophy of this class is that partial failures | 64 // The overall implementation philosophy of this class is that partial failures |
| 65 // should leave us with an intact database; we'd prefer to leak the occasional | 65 // should leave us with an intact database; we'd prefer to leak the occasional |
| 66 // backing file than have a database entry whose backing file is missing. When | 66 // backing file than have a database entry whose backing file is missing. When |
| 67 // doing FSCK operations, if you find a loose backing file with no reference, | 67 // doing FSCK operations, if you find a loose backing file with no reference, |
| 68 // you may safely delete it. | 68 // you may safely delete it. |
| 69 // | 69 // |
| 70 // This class must be deleted on the FILE thread, because that's where | 70 // This class must be deleted on the FILE thread, because that's where |
| 71 // DropDatabases needs to be called. | 71 // DropDatabases needs to be called. |
| 72 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil | 72 class STORAGE_EXPORT_PRIVATE ObfuscatedFileUtil : public FileSystemFileUtil { |
| 73 : public FileSystemFileUtil { | |
| 74 public: | 73 public: |
| 75 // Origin enumerator interface. | 74 // Origin enumerator interface. |
| 76 // An instance of this interface is assumed to be called on the file thread. | 75 // An instance of this interface is assumed to be called on the file thread. |
| 77 class AbstractOriginEnumerator { | 76 class AbstractOriginEnumerator { |
| 78 public: | 77 public: |
| 79 virtual ~AbstractOriginEnumerator() {} | 78 virtual ~AbstractOriginEnumerator() {} |
| 80 | 79 |
| 81 // Returns the next origin. Returns empty if there are no more origins. | 80 // Returns the next origin. Returns empty if there are no more origins. |
| 82 virtual GURL Next() = 0; | 81 virtual GURL Next() = 0; |
| 83 | 82 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 // to provide per-type isolation in the sandboxed filesystem directory. | 93 // to provide per-type isolation in the sandboxed filesystem directory. |
| 95 // Note that this method is called on file_task_runner. | 94 // Note that this method is called on file_task_runner. |
| 96 // | 95 // |
| 97 // |known_type_strings| are known type string names that this file system | 96 // |known_type_strings| are known type string names that this file system |
| 98 // should care about. | 97 // should care about. |
| 99 // This info is used to determine whether we could delete the entire | 98 // This info is used to determine whether we could delete the entire |
| 100 // origin directory or not in DeleteDirectoryForOriginAndType. If no directory | 99 // origin directory or not in DeleteDirectoryForOriginAndType. If no directory |
| 101 // for any known type exists the origin directory may get deleted when | 100 // for any known type exists the origin directory may get deleted when |
| 102 // one origin/type pair is deleted. | 101 // one origin/type pair is deleted. |
| 103 // | 102 // |
| 104 ObfuscatedFileUtil( | 103 ObfuscatedFileUtil(quota::SpecialStoragePolicy* special_storage_policy, |
| 105 quota::SpecialStoragePolicy* special_storage_policy, | 104 const base::FilePath& file_system_directory, |
| 106 const base::FilePath& file_system_directory, | 105 leveldb::Env* env_override, |
| 107 leveldb::Env* env_override, | 106 base::SequencedTaskRunner* file_task_runner, |
| 108 base::SequencedTaskRunner* file_task_runner, | 107 const GetTypeStringForURLCallback& get_type_string_for_url, |
| 109 const GetTypeStringForURLCallback& get_type_string_for_url, | 108 const std::set<std::string>& known_type_strings, |
| 110 const std::set<std::string>& known_type_strings, | 109 SandboxFileSystemBackendDelegate* sandbox_delegate); |
| 111 SandboxFileSystemBackendDelegate* sandbox_delegate); | |
| 112 virtual ~ObfuscatedFileUtil(); | 110 virtual ~ObfuscatedFileUtil(); |
| 113 | 111 |
| 114 // FileSystemFileUtil overrides. | 112 // FileSystemFileUtil overrides. |
| 115 virtual base::File CreateOrOpen( | 113 virtual base::File CreateOrOpen(FileSystemOperationContext* context, |
| 114 const FileSystemURL& url, |
| 115 int file_flags) OVERRIDE; |
| 116 virtual base::File::Error EnsureFileExists( |
| 116 FileSystemOperationContext* context, | 117 FileSystemOperationContext* context, |
| 117 const FileSystemURL& url, | 118 const FileSystemURL& url, |
| 118 int file_flags) OVERRIDE; | 119 bool* created) OVERRIDE; |
| 119 virtual base::File::Error EnsureFileExists( | 120 virtual base::File::Error CreateDirectory(FileSystemOperationContext* context, |
| 120 FileSystemOperationContext* context, | 121 const FileSystemURL& url, |
| 121 const FileSystemURL& url, bool* created) OVERRIDE; | 122 bool exclusive, |
| 122 virtual base::File::Error CreateDirectory( | 123 bool recursive) OVERRIDE; |
| 123 FileSystemOperationContext* context, | 124 virtual base::File::Error GetFileInfo(FileSystemOperationContext* context, |
| 124 const FileSystemURL& url, | 125 const FileSystemURL& url, |
| 125 bool exclusive, | 126 base::File::Info* file_info, |
| 126 bool recursive) OVERRIDE; | 127 base::FilePath* platform_file) OVERRIDE; |
| 127 virtual base::File::Error GetFileInfo( | |
| 128 FileSystemOperationContext* context, | |
| 129 const FileSystemURL& url, | |
| 130 base::File::Info* file_info, | |
| 131 base::FilePath* platform_file) OVERRIDE; | |
| 132 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( | 128 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( |
| 133 FileSystemOperationContext* context, | 129 FileSystemOperationContext* context, |
| 134 const FileSystemURL& root_url) OVERRIDE; | 130 const FileSystemURL& root_url) OVERRIDE; |
| 135 virtual base::File::Error GetLocalFilePath( | 131 virtual base::File::Error GetLocalFilePath( |
| 136 FileSystemOperationContext* context, | 132 FileSystemOperationContext* context, |
| 137 const FileSystemURL& file_system_url, | 133 const FileSystemURL& file_system_url, |
| 138 base::FilePath* local_path) OVERRIDE; | 134 base::FilePath* local_path) OVERRIDE; |
| 139 virtual base::File::Error Touch( | 135 virtual base::File::Error Touch( |
| 140 FileSystemOperationContext* context, | 136 FileSystemOperationContext* context, |
| 141 const FileSystemURL& url, | 137 const FileSystemURL& url, |
| 142 const base::Time& last_access_time, | 138 const base::Time& last_access_time, |
| 143 const base::Time& last_modified_time) OVERRIDE; | 139 const base::Time& last_modified_time) OVERRIDE; |
| 144 virtual base::File::Error Truncate( | 140 virtual base::File::Error Truncate(FileSystemOperationContext* context, |
| 141 const FileSystemURL& url, |
| 142 int64 length) OVERRIDE; |
| 143 virtual base::File::Error CopyOrMoveFile(FileSystemOperationContext* context, |
| 144 const FileSystemURL& src_url, |
| 145 const FileSystemURL& dest_url, |
| 146 CopyOrMoveOption option, |
| 147 bool copy) OVERRIDE; |
| 148 virtual base::File::Error CopyInForeignFile( |
| 145 FileSystemOperationContext* context, | 149 FileSystemOperationContext* context, |
| 146 const FileSystemURL& url, | 150 const base::FilePath& src_file_path, |
| 147 int64 length) OVERRIDE; | 151 const FileSystemURL& dest_url) OVERRIDE; |
| 148 virtual base::File::Error CopyOrMoveFile( | 152 virtual base::File::Error DeleteFile(FileSystemOperationContext* context, |
| 149 FileSystemOperationContext* context, | 153 const FileSystemURL& url) OVERRIDE; |
| 150 const FileSystemURL& src_url, | 154 virtual base::File::Error DeleteDirectory(FileSystemOperationContext* context, |
| 151 const FileSystemURL& dest_url, | 155 const FileSystemURL& url) OVERRIDE; |
| 152 CopyOrMoveOption option, | 156 virtual storage::ScopedFile CreateSnapshotFile( |
| 153 bool copy) OVERRIDE; | |
| 154 virtual base::File::Error CopyInForeignFile( | |
| 155 FileSystemOperationContext* context, | |
| 156 const base::FilePath& src_file_path, | |
| 157 const FileSystemURL& dest_url) OVERRIDE; | |
| 158 virtual base::File::Error DeleteFile( | |
| 159 FileSystemOperationContext* context, | |
| 160 const FileSystemURL& url) OVERRIDE; | |
| 161 virtual base::File::Error DeleteDirectory( | |
| 162 FileSystemOperationContext* context, | |
| 163 const FileSystemURL& url) OVERRIDE; | |
| 164 virtual webkit_blob::ScopedFile CreateSnapshotFile( | |
| 165 FileSystemOperationContext* context, | 157 FileSystemOperationContext* context, |
| 166 const FileSystemURL& url, | 158 const FileSystemURL& url, |
| 167 base::File::Error* error, | 159 base::File::Error* error, |
| 168 base::File::Info* file_info, | 160 base::File::Info* file_info, |
| 169 base::FilePath* platform_path) OVERRIDE; | 161 base::FilePath* platform_path) OVERRIDE; |
| 170 | 162 |
| 171 // Same as the other CreateFileEnumerator, but with recursive support. | 163 // Same as the other CreateFileEnumerator, but with recursive support. |
| 172 scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( | 164 scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( |
| 173 FileSystemOperationContext* context, | 165 FileSystemOperationContext* context, |
| 174 const FileSystemURL& root_url, | 166 const FileSystemURL& root_url, |
| 175 bool recursive); | 167 bool recursive); |
| 176 | 168 |
| 177 // Returns true if the directory |url| is empty. | 169 // Returns true if the directory |url| is empty. |
| 178 bool IsDirectoryEmpty( | 170 bool IsDirectoryEmpty(FileSystemOperationContext* context, |
| 179 FileSystemOperationContext* context, | 171 const FileSystemURL& url); |
| 180 const FileSystemURL& url); | |
| 181 | 172 |
| 182 // Gets the topmost directory specific to this origin and type. This will | 173 // Gets the topmost directory specific to this origin and type. This will |
| 183 // contain both the directory database's files and all the backing file | 174 // contain both the directory database's files and all the backing file |
| 184 // subdirectories. | 175 // subdirectories. |
| 185 // Returns the topmost origin directory if |type_string| is empty. | 176 // Returns the topmost origin directory if |type_string| is empty. |
| 186 // Returns an empty path if the directory is undefined. | 177 // Returns an empty path if the directory is undefined. |
| 187 // If the directory is defined, it will be returned, even if | 178 // If the directory is defined, it will be returned, even if |
| 188 // there is a file system error (e.g. the directory doesn't exist on disk and | 179 // there is a file system error (e.g. the directory doesn't exist on disk and |
| 189 // |create| is false). Callers should always check |error_code| to make sure | 180 // |create| is false). Callers should always check |error_code| to make sure |
| 190 // the returned path is usable. | 181 // the returned path is usable. |
| 191 base::FilePath GetDirectoryForOriginAndType( | 182 base::FilePath GetDirectoryForOriginAndType(const GURL& origin, |
| 192 const GURL& origin, | 183 const std::string& type_string, |
| 193 const std::string& type_string, | 184 bool create, |
| 194 bool create, | 185 base::File::Error* error_code); |
| 195 base::File::Error* error_code); | |
| 196 | 186 |
| 197 // Deletes the topmost directory specific to this origin and type. This will | 187 // Deletes the topmost directory specific to this origin and type. This will |
| 198 // delete its directory database. | 188 // delete its directory database. |
| 199 // Deletes the topmost origin directory if |type_string| is empty. | 189 // Deletes the topmost origin directory if |type_string| is empty. |
| 200 bool DeleteDirectoryForOriginAndType( | 190 bool DeleteDirectoryForOriginAndType(const GURL& origin, |
| 201 const GURL& origin, | 191 const std::string& type_string); |
| 202 const std::string& type_string); | |
| 203 | 192 |
| 204 // This method and all methods of its returned class must be called only on | 193 // This method and all methods of its returned class must be called only on |
| 205 // the FILE thread. The caller is responsible for deleting the returned | 194 // the FILE thread. The caller is responsible for deleting the returned |
| 206 // object. | 195 // object. |
| 207 AbstractOriginEnumerator* CreateOriginEnumerator(); | 196 AbstractOriginEnumerator* CreateOriginEnumerator(); |
| 208 | 197 |
| 209 // Deletes a directory database from the database list in the ObfuscatedFSFU | 198 // Deletes a directory database from the database list in the ObfuscatedFSFU |
| 210 // and destroys the database on the disk. | 199 // and destroys the database on the disk. |
| 211 bool DestroyDirectoryDatabase(const GURL& origin, | 200 bool DestroyDirectoryDatabase(const GURL& origin, |
| 212 const std::string& type_string); | 201 const std::string& type_string); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 235 | 224 |
| 236 // Helper method to create an obfuscated file util for regular | 225 // Helper method to create an obfuscated file util for regular |
| 237 // (temporary, persistent) file systems. Used only for testing. | 226 // (temporary, persistent) file systems. Used only for testing. |
| 238 // Note: this is implemented in sandbox_file_system_backend_delegate.cc. | 227 // Note: this is implemented in sandbox_file_system_backend_delegate.cc. |
| 239 static ObfuscatedFileUtil* CreateForTesting( | 228 static ObfuscatedFileUtil* CreateForTesting( |
| 240 quota::SpecialStoragePolicy* special_storage_policy, | 229 quota::SpecialStoragePolicy* special_storage_policy, |
| 241 const base::FilePath& file_system_directory, | 230 const base::FilePath& file_system_directory, |
| 242 leveldb::Env* env_override, | 231 leveldb::Env* env_override, |
| 243 base::SequencedTaskRunner* file_task_runner); | 232 base::SequencedTaskRunner* file_task_runner); |
| 244 | 233 |
| 245 base::FilePath GetDirectoryForURL( | 234 base::FilePath GetDirectoryForURL(const FileSystemURL& url, |
| 246 const FileSystemURL& url, | 235 bool create, |
| 247 bool create, | 236 base::File::Error* error_code); |
| 248 base::File::Error* error_code); | |
| 249 | 237 |
| 250 // This just calls get_type_string_for_url_ callback that is given in ctor. | 238 // This just calls get_type_string_for_url_ callback that is given in ctor. |
| 251 std::string CallGetTypeStringForURL(const FileSystemURL& url); | 239 std::string CallGetTypeStringForURL(const FileSystemURL& url); |
| 252 | 240 |
| 253 base::File::Error GetFileInfoInternal( | 241 base::File::Error GetFileInfoInternal(SandboxDirectoryDatabase* db, |
| 254 SandboxDirectoryDatabase* db, | 242 FileSystemOperationContext* context, |
| 255 FileSystemOperationContext* context, | 243 const FileSystemURL& url, |
| 256 const FileSystemURL& url, | 244 FileId file_id, |
| 257 FileId file_id, | 245 FileInfo* local_info, |
| 258 FileInfo* local_info, | 246 base::File::Info* file_info, |
| 259 base::File::Info* file_info, | 247 base::FilePath* platform_file_path); |
| 260 base::FilePath* platform_file_path); | |
| 261 | 248 |
| 262 // Creates a new file, both the underlying backing file and the entry in the | 249 // Creates a new file, both the underlying backing file and the entry in the |
| 263 // database. |dest_file_info| is an in-out parameter. Supply the name and | 250 // database. |dest_file_info| is an in-out parameter. Supply the name and |
| 264 // parent_id; data_path is ignored. On success, data_path will | 251 // parent_id; data_path is ignored. On success, data_path will |
| 265 // always be set to the relative path [from the root of the type-specific | 252 // always be set to the relative path [from the root of the type-specific |
| 266 // filesystem directory] of a NEW backing file. Returns the new file. | 253 // filesystem directory] of a NEW backing file. Returns the new file. |
| 267 base::File CreateAndOpenFile( | 254 base::File CreateAndOpenFile(FileSystemOperationContext* context, |
| 268 FileSystemOperationContext* context, | 255 const FileSystemURL& dest_url, |
| 269 const FileSystemURL& dest_url, | 256 FileInfo* dest_file_info, |
| 270 FileInfo* dest_file_info, | 257 int file_flags); |
| 271 int file_flags); | |
| 272 | 258 |
| 273 // The same as CreateAndOpenFile except that a file is not returned and if a | 259 // The same as CreateAndOpenFile except that a file is not returned and if a |
| 274 // path is provided in |source_path|, it will be used as a source from which | 260 // path is provided in |source_path|, it will be used as a source from which |
| 275 // to COPY data. | 261 // to COPY data. |
| 276 base::File::Error CreateFile( | 262 base::File::Error CreateFile(FileSystemOperationContext* context, |
| 277 FileSystemOperationContext* context, | 263 const base::FilePath& source_file_path, |
| 278 const base::FilePath& source_file_path, | 264 const FileSystemURL& dest_url, |
| 279 const FileSystemURL& dest_url, | 265 FileInfo* dest_file_info); |
| 280 FileInfo* dest_file_info); | |
| 281 | 266 |
| 282 // Updates |db| and |dest_file_info| at the end of creating a new file. | 267 // Updates |db| and |dest_file_info| at the end of creating a new file. |
| 283 base::File::Error CommitCreateFile( | 268 base::File::Error CommitCreateFile(const base::FilePath& root, |
| 284 const base::FilePath& root, | 269 const base::FilePath& local_path, |
| 285 const base::FilePath& local_path, | 270 SandboxDirectoryDatabase* db, |
| 286 SandboxDirectoryDatabase* db, | 271 FileInfo* dest_file_info); |
| 287 FileInfo* dest_file_info); | |
| 288 | 272 |
| 289 // This converts from a relative path [as is stored in the FileInfo.data_path | 273 // This converts from a relative path [as is stored in the FileInfo.data_path |
| 290 // field] to an absolute platform path that can be given to the native | 274 // field] to an absolute platform path that can be given to the native |
| 291 // filesystem. | 275 // filesystem. |
| 292 base::FilePath DataPathToLocalPath( | 276 base::FilePath DataPathToLocalPath(const FileSystemURL& url, |
| 293 const FileSystemURL& url, | 277 const base::FilePath& data_file_path); |
| 294 const base::FilePath& data_file_path); | |
| 295 | 278 |
| 296 std::string GetDirectoryDatabaseKey(const GURL& origin, | 279 std::string GetDirectoryDatabaseKey(const GURL& origin, |
| 297 const std::string& type_string); | 280 const std::string& type_string); |
| 298 | 281 |
| 299 // This returns NULL if |create| flag is false and a filesystem does not | 282 // This returns NULL if |create| flag is false and a filesystem does not |
| 300 // exist for the given |url|. | 283 // exist for the given |url|. |
| 301 // For read operations |create| should be false. | 284 // For read operations |create| should be false. |
| 302 SandboxDirectoryDatabase* GetDirectoryDatabase(const FileSystemURL& url, | 285 SandboxDirectoryDatabase* GetDirectoryDatabase(const FileSystemURL& url, |
| 303 bool create); | 286 bool create); |
| 304 | 287 |
| 305 // Gets the topmost directory specific to this origin. This will | 288 // Gets the topmost directory specific to this origin. This will |
| 306 // contain both the filesystem type subdirectories. | 289 // contain both the filesystem type subdirectories. |
| 307 base::FilePath GetDirectoryForOrigin(const GURL& origin, | 290 base::FilePath GetDirectoryForOrigin(const GURL& origin, |
| 308 bool create, | 291 bool create, |
| 309 base::File::Error* error_code); | 292 base::File::Error* error_code); |
| 310 | 293 |
| 311 void InvalidateUsageCache(FileSystemOperationContext* context, | 294 void InvalidateUsageCache(FileSystemOperationContext* context, |
| 312 const GURL& origin, | 295 const GURL& origin, |
| 313 FileSystemType type); | 296 FileSystemType type); |
| 314 | 297 |
| 315 void MarkUsed(); | 298 void MarkUsed(); |
| 316 void DropDatabases(); | 299 void DropDatabases(); |
| 317 | 300 |
| 318 // Initializes the origin database. |origin_hint| may be used as a hint | 301 // Initializes the origin database. |origin_hint| may be used as a hint |
| 319 // for initializing database if it's not empty. | 302 // for initializing database if it's not empty. |
| 320 bool InitOriginDatabase(const GURL& origin_hint, bool create); | 303 bool InitOriginDatabase(const GURL& origin_hint, bool create); |
| 321 | 304 |
| 322 base::File::Error GenerateNewLocalPath( | 305 base::File::Error GenerateNewLocalPath(SandboxDirectoryDatabase* db, |
| 323 SandboxDirectoryDatabase* db, | 306 FileSystemOperationContext* context, |
| 324 FileSystemOperationContext* context, | 307 const FileSystemURL& url, |
| 325 const FileSystemURL& url, | 308 base::FilePath* root, |
| 326 base::FilePath* root, | 309 base::FilePath* local_path); |
| 327 base::FilePath* local_path); | |
| 328 | 310 |
| 329 base::File CreateOrOpenInternal( | 311 base::File CreateOrOpenInternal(FileSystemOperationContext* context, |
| 330 FileSystemOperationContext* context, | 312 const FileSystemURL& url, |
| 331 const FileSystemURL& url, | 313 int file_flags); |
| 332 int file_flags); | |
| 333 | 314 |
| 334 bool HasIsolatedStorage(const GURL& origin); | 315 bool HasIsolatedStorage(const GURL& origin); |
| 335 | 316 |
| 336 typedef std::map<std::string, SandboxDirectoryDatabase*> DirectoryMap; | 317 typedef std::map<std::string, SandboxDirectoryDatabase*> DirectoryMap; |
| 337 DirectoryMap directories_; | 318 DirectoryMap directories_; |
| 338 scoped_ptr<SandboxOriginDatabaseInterface> origin_database_; | 319 scoped_ptr<SandboxOriginDatabaseInterface> origin_database_; |
| 339 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 320 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 340 base::FilePath file_system_directory_; | 321 base::FilePath file_system_directory_; |
| 341 leveldb::Env* env_override_; | 322 leveldb::Env* env_override_; |
| 342 | 323 |
| 343 // Used to delete database after a certain period of inactivity. | 324 // Used to delete database after a certain period of inactivity. |
| 344 int64 db_flush_delay_seconds_; | 325 int64 db_flush_delay_seconds_; |
| 345 | 326 |
| 346 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 327 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 347 scoped_ptr<TimedTaskHelper> timer_; | 328 scoped_ptr<TimedTaskHelper> timer_; |
| 348 | 329 |
| 349 GetTypeStringForURLCallback get_type_string_for_url_; | 330 GetTypeStringForURLCallback get_type_string_for_url_; |
| 350 std::set<std::string> known_type_strings_; | 331 std::set<std::string> known_type_strings_; |
| 351 | 332 |
| 352 // Not owned. | 333 // Not owned. |
| 353 SandboxFileSystemBackendDelegate* sandbox_delegate_; | 334 SandboxFileSystemBackendDelegate* sandbox_delegate_; |
| 354 | 335 |
| 355 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtil); | 336 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtil); |
| 356 }; | 337 }; |
| 357 | 338 |
| 358 } // namespace fileapi | 339 } // namespace storage |
| 359 | 340 |
| 360 #endif // WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ | 341 #endif // WEBKIT_BROWSER_FILEAPI_OBFUSCATED_FILE_UTIL_H_ |
| OLD | NEW |