| 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_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 virtual ~OriginEnumerator() {} | 52 virtual ~OriginEnumerator() {} |
| 53 | 53 |
| 54 // Returns the next origin. Returns empty if there are no more origins. | 54 // Returns the next origin. Returns empty if there are no more origins. |
| 55 virtual GURL Next() = 0; | 55 virtual GURL Next() = 0; |
| 56 | 56 |
| 57 // Returns the current origin's information. | 57 // Returns the current origin's information. |
| 58 virtual bool HasFileSystemType(FileSystemType type) const = 0; | 58 virtual bool HasFileSystemType(FileSystemType type) const = 0; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // The FileSystem directory name. | 61 // The FileSystem directory name. |
| 62 static const FilePath::CharType kFileSystemDirectory[]; | 62 static const base::FilePath::CharType kFileSystemDirectory[]; |
| 63 | 63 |
| 64 static bool CanHandleType(FileSystemType type); | 64 static bool CanHandleType(FileSystemType type); |
| 65 | 65 |
| 66 // |file_task_runner| is used to validate the root directory and delete the | 66 // |file_task_runner| is used to validate the root directory and delete the |
| 67 // obfuscated file util. | 67 // obfuscated file util. |
| 68 SandboxMountPointProvider( | 68 SandboxMountPointProvider( |
| 69 quota::QuotaManagerProxy* quota_manager_proxy, | 69 quota::QuotaManagerProxy* quota_manager_proxy, |
| 70 base::SequencedTaskRunner* file_task_runner, | 70 base::SequencedTaskRunner* file_task_runner, |
| 71 const FilePath& profile_path, | 71 const base::FilePath& profile_path, |
| 72 const FileSystemOptions& file_system_options); | 72 const FileSystemOptions& file_system_options); |
| 73 virtual ~SandboxMountPointProvider(); | 73 virtual ~SandboxMountPointProvider(); |
| 74 | 74 |
| 75 // FileSystemMountPointProvider overrides. | 75 // FileSystemMountPointProvider overrides. |
| 76 virtual void ValidateFileSystemRoot( | 76 virtual void ValidateFileSystemRoot( |
| 77 const GURL& origin_url, | 77 const GURL& origin_url, |
| 78 FileSystemType type, | 78 FileSystemType type, |
| 79 bool create, | 79 bool create, |
| 80 const ValidateFileSystemCallback& callback) OVERRIDE; | 80 const ValidateFileSystemCallback& callback) OVERRIDE; |
| 81 virtual FilePath GetFileSystemRootPathOnFileThread( | 81 virtual base::FilePath GetFileSystemRootPathOnFileThread( |
| 82 const FileSystemURL& url, | 82 const FileSystemURL& url, |
| 83 bool create) OVERRIDE; | 83 bool create) OVERRIDE; |
| 84 virtual bool IsAccessAllowed(const FileSystemURL& url) OVERRIDE; | 84 virtual bool IsAccessAllowed(const FileSystemURL& url) OVERRIDE; |
| 85 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | 85 virtual bool IsRestrictedFileName(const base::FilePath& filename) const OVERRI
DE; |
| 86 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; | 86 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) OVERRIDE; |
| 87 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | 87 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; |
| 88 virtual FilePermissionPolicy GetPermissionPolicy( | 88 virtual FilePermissionPolicy GetPermissionPolicy( |
| 89 const FileSystemURL& url, | 89 const FileSystemURL& url, |
| 90 int permissions) const OVERRIDE; | 90 int permissions) const OVERRIDE; |
| 91 virtual FileSystemOperation* CreateFileSystemOperation( | 91 virtual FileSystemOperation* CreateFileSystemOperation( |
| 92 const FileSystemURL& url, | 92 const FileSystemURL& url, |
| 93 FileSystemContext* context, | 93 FileSystemContext* context, |
| 94 base::PlatformFileError* error_code) const OVERRIDE; | 94 base::PlatformFileError* error_code) const OVERRIDE; |
| 95 virtual webkit_blob::FileStreamReader* CreateFileStreamReader( | 95 virtual webkit_blob::FileStreamReader* CreateFileStreamReader( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 111 // Returns an origin enumerator of this provider. | 111 // Returns an origin enumerator of this provider. |
| 112 // This method can only be called on the file thread. | 112 // This method can only be called on the file thread. |
| 113 OriginEnumerator* CreateOriginEnumerator(); | 113 OriginEnumerator* CreateOriginEnumerator(); |
| 114 | 114 |
| 115 // Gets a base directory path of the sandboxed filesystem that is | 115 // Gets a base directory path of the sandboxed filesystem that is |
| 116 // specified by |origin_url| and |type|. | 116 // specified by |origin_url| and |type|. |
| 117 // (The path is similar to the origin's root path but doesn't contain | 117 // (The path is similar to the origin's root path but doesn't contain |
| 118 // the 'unique' part.) | 118 // the 'unique' part.) |
| 119 // Returns an empty path if the given type is invalid. | 119 // Returns an empty path if the given type is invalid. |
| 120 // This method can only be called on the file thread. | 120 // This method can only be called on the file thread. |
| 121 FilePath GetBaseDirectoryForOriginAndType( | 121 base::FilePath GetBaseDirectoryForOriginAndType( |
| 122 const GURL& origin_url, | 122 const GURL& origin_url, |
| 123 FileSystemType type, | 123 FileSystemType type, |
| 124 bool create); | 124 bool create); |
| 125 | 125 |
| 126 // Deletes the data on the origin and reports the amount of deleted data | 126 // Deletes the data on the origin and reports the amount of deleted data |
| 127 // to the quota manager via |proxy|. | 127 // to the quota manager via |proxy|. |
| 128 base::PlatformFileError DeleteOriginDataOnFileThread( | 128 base::PlatformFileError DeleteOriginDataOnFileThread( |
| 129 FileSystemContext* context, | 129 FileSystemContext* context, |
| 130 quota::QuotaManagerProxy* proxy, | 130 quota::QuotaManagerProxy* proxy, |
| 131 const GURL& origin_url, | 131 const GURL& origin_url, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 friend class LocalFileSystemTestOriginHelper; | 167 friend class LocalFileSystemTestOriginHelper; |
| 168 friend class SandboxMountPointProviderMigrationTest; | 168 friend class SandboxMountPointProviderMigrationTest; |
| 169 friend class SandboxMountPointProviderOriginEnumeratorTest; | 169 friend class SandboxMountPointProviderOriginEnumeratorTest; |
| 170 | 170 |
| 171 // Temporarily allowing them to access enable_sync_directory_operation_ | 171 // Temporarily allowing them to access enable_sync_directory_operation_ |
| 172 friend class CannedSyncableFileSystem; | 172 friend class CannedSyncableFileSystem; |
| 173 friend class ObfuscatedFileUtil; | 173 friend class ObfuscatedFileUtil; |
| 174 friend class SyncableFileSystemOperation; | 174 friend class SyncableFileSystemOperation; |
| 175 | 175 |
| 176 // Returns a path to the usage cache file. | 176 // Returns a path to the usage cache file. |
| 177 FilePath GetUsageCachePathForOriginAndType( | 177 base::FilePath GetUsageCachePathForOriginAndType( |
| 178 const GURL& origin_url, | 178 const GURL& origin_url, |
| 179 FileSystemType type); | 179 FileSystemType type); |
| 180 | 180 |
| 181 // Returns a path to the usage cache file (static version). | 181 // Returns a path to the usage cache file (static version). |
| 182 static FilePath GetUsageCachePathForOriginAndType( | 182 static base::FilePath GetUsageCachePathForOriginAndType( |
| 183 ObfuscatedFileUtil* sandbox_file_util, | 183 ObfuscatedFileUtil* sandbox_file_util, |
| 184 const GURL& origin_url, | 184 const GURL& origin_url, |
| 185 FileSystemType type, | 185 FileSystemType type, |
| 186 base::PlatformFileError* error_out); | 186 base::PlatformFileError* error_out); |
| 187 | 187 |
| 188 // Returns true if the given |url|'s scheme is allowed to access | 188 // Returns true if the given |url|'s scheme is allowed to access |
| 189 // filesystem. | 189 // filesystem. |
| 190 bool IsAllowedScheme(const GURL& url) const; | 190 bool IsAllowedScheme(const GURL& url) const; |
| 191 | 191 |
| 192 // Enables or disables directory operations in Syncable FileSystem. | 192 // Enables or disables directory operations in Syncable FileSystem. |
| 193 void set_enable_sync_directory_operation(bool flag) { | 193 void set_enable_sync_directory_operation(bool flag) { |
| 194 enable_sync_directory_operation_ = flag; | 194 enable_sync_directory_operation_ = flag; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool is_sync_directory_operation_enabled() const { | 197 bool is_sync_directory_operation_enabled() const { |
| 198 return enable_sync_directory_operation_; | 198 return enable_sync_directory_operation_; |
| 199 } | 199 } |
| 200 | 200 |
| 201 ObfuscatedFileUtil* sandbox_sync_file_util(); | 201 ObfuscatedFileUtil* sandbox_sync_file_util(); |
| 202 | 202 |
| 203 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 203 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 204 | 204 |
| 205 const FilePath profile_path_; | 205 const base::FilePath profile_path_; |
| 206 | 206 |
| 207 FileSystemOptions file_system_options_; | 207 FileSystemOptions file_system_options_; |
| 208 | 208 |
| 209 scoped_ptr<AsyncFileUtilAdapter> sandbox_file_util_; | 209 scoped_ptr<AsyncFileUtilAdapter> sandbox_file_util_; |
| 210 | 210 |
| 211 scoped_ptr<SandboxQuotaObserver> quota_observer_; | 211 scoped_ptr<SandboxQuotaObserver> quota_observer_; |
| 212 | 212 |
| 213 // Acccessed only on the file thread. | 213 // Acccessed only on the file thread. |
| 214 std::set<GURL> visited_origins_; | 214 std::set<GURL> visited_origins_; |
| 215 | 215 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 232 bool enable_sync_directory_operation_; | 232 bool enable_sync_directory_operation_; |
| 233 | 233 |
| 234 base::WeakPtrFactory<SandboxMountPointProvider> weak_factory_; | 234 base::WeakPtrFactory<SandboxMountPointProvider> weak_factory_; |
| 235 | 235 |
| 236 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 236 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 } // namespace fileapi | 239 } // namespace fileapi |
| 240 | 240 |
| 241 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 241 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |