| 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_FILE_SYSTEM_CONTEXT_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace webkit_blob { | 42 namespace webkit_blob { |
| 43 class BlobURLRequestJobTest; | 43 class BlobURLRequestJobTest; |
| 44 class FileStreamReader; | 44 class FileStreamReader; |
| 45 } | 45 } |
| 46 | 46 |
| 47 namespace fileapi { | 47 namespace fileapi { |
| 48 | 48 |
| 49 class AsyncFileUtil; | 49 class AsyncFileUtil; |
| 50 class CopyOrMoveFileValidatorFactory; | 50 class CopyOrMoveFileValidatorFactory; |
| 51 class ExternalFileSystemMountPointProvider; | 51 class ExternalFileSystemBackend; |
| 52 class ExternalMountPoints; | 52 class ExternalMountPoints; |
| 53 class FileStreamWriter; | 53 class FileStreamWriter; |
| 54 class FileSystemFileUtil; | 54 class FileSystemFileUtil; |
| 55 class FileSystemMountPointProvider; | 55 class FileSystemBackend; |
| 56 class FileSystemOperation; | 56 class FileSystemOperation; |
| 57 class FileSystemOperationRunner; | 57 class FileSystemOperationRunner; |
| 58 class FileSystemOptions; | 58 class FileSystemOptions; |
| 59 class FileSystemQuotaUtil; | 59 class FileSystemQuotaUtil; |
| 60 class FileSystemTaskRunners; | 60 class FileSystemTaskRunners; |
| 61 class FileSystemURL; | 61 class FileSystemURL; |
| 62 class IsolatedMountPointProvider; | 62 class IsolatedMountPointProvider; |
| 63 class MountPoints; | 63 class MountPoints; |
| 64 class SandboxMountPointProvider; | 64 class SandboxMountPointProvider; |
| 65 | 65 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 95 // | 95 // |
| 96 // |additional_providers| are added to the internal provider map | 96 // |additional_providers| are added to the internal provider map |
| 97 // to serve filesystem requests for non-regular types. | 97 // to serve filesystem requests for non-regular types. |
| 98 // If none is given, this context only handles HTML5 Sandbox FileSystem | 98 // If none is given, this context only handles HTML5 Sandbox FileSystem |
| 99 // and Drag-and-drop Isolated FileSystem requests. | 99 // and Drag-and-drop Isolated FileSystem requests. |
| 100 FileSystemContext( | 100 FileSystemContext( |
| 101 scoped_ptr<FileSystemTaskRunners> task_runners, | 101 scoped_ptr<FileSystemTaskRunners> task_runners, |
| 102 ExternalMountPoints* external_mount_points, | 102 ExternalMountPoints* external_mount_points, |
| 103 quota::SpecialStoragePolicy* special_storage_policy, | 103 quota::SpecialStoragePolicy* special_storage_policy, |
| 104 quota::QuotaManagerProxy* quota_manager_proxy, | 104 quota::QuotaManagerProxy* quota_manager_proxy, |
| 105 ScopedVector<FileSystemMountPointProvider> additional_providers, | 105 ScopedVector<FileSystemBackend> additional_providers, |
| 106 const base::FilePath& partition_path, | 106 const base::FilePath& partition_path, |
| 107 const FileSystemOptions& options); | 107 const FileSystemOptions& options); |
| 108 | 108 |
| 109 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); | 109 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); |
| 110 | 110 |
| 111 quota::QuotaManagerProxy* quota_manager_proxy() const { | 111 quota::QuotaManagerProxy* quota_manager_proxy() const { |
| 112 return quota_manager_proxy_.get(); | 112 return quota_manager_proxy_.get(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns a quota util for a given filesystem type. This may | 115 // Returns a quota util for a given filesystem type. This may |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 // Returns the appropriate CopyOrMoveFileValidatorFactory for the given | 128 // Returns the appropriate CopyOrMoveFileValidatorFactory for the given |
| 129 // |type|. If |error_code| is PLATFORM_FILE_OK and the result is NULL, | 129 // |type|. If |error_code| is PLATFORM_FILE_OK and the result is NULL, |
| 130 // then no validator is required. | 130 // then no validator is required. |
| 131 CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | 131 CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( |
| 132 FileSystemType type, base::PlatformFileError* error_code) const; | 132 FileSystemType type, base::PlatformFileError* error_code) const; |
| 133 | 133 |
| 134 // Returns the mount point provider instance for the given |type|. | 134 // Returns the mount point provider instance for the given |type|. |
| 135 // This may return NULL if it is given an invalid or unsupported filesystem | 135 // This may return NULL if it is given an invalid or unsupported filesystem |
| 136 // type. | 136 // type. |
| 137 FileSystemMountPointProvider* GetMountPointProvider( | 137 FileSystemBackend* GetMountPointProvider( |
| 138 FileSystemType type) const; | 138 FileSystemType type) const; |
| 139 | 139 |
| 140 // Returns true for sandboxed filesystems. Currently this does | 140 // Returns true for sandboxed filesystems. Currently this does |
| 141 // the same as GetQuotaUtil(type) != NULL. (In an assumption that | 141 // the same as GetQuotaUtil(type) != NULL. (In an assumption that |
| 142 // all sandboxed filesystems must cooperate with QuotaManager so that | 142 // all sandboxed filesystems must cooperate with QuotaManager so that |
| 143 // they can get deleted) | 143 // they can get deleted) |
| 144 bool IsSandboxFileSystem(FileSystemType type) const; | 144 bool IsSandboxFileSystem(FileSystemType type) const; |
| 145 | 145 |
| 146 // Returns observers for the given filesystem type. | 146 // Returns observers for the given filesystem type. |
| 147 const UpdateObserverList* GetUpdateObservers(FileSystemType type) const; | 147 const UpdateObserverList* GetUpdateObservers(FileSystemType type) const; |
| 148 const AccessObserverList* GetAccessObservers(FileSystemType type) const; | 148 const AccessObserverList* GetAccessObservers(FileSystemType type) const; |
| 149 | 149 |
| 150 // Returns all registered filesystem types. | 150 // Returns all registered filesystem types. |
| 151 void GetFileSystemTypes(std::vector<FileSystemType>* types) const; | 151 void GetFileSystemTypes(std::vector<FileSystemType>* types) const; |
| 152 | 152 |
| 153 // Returns a FileSystemMountPointProvider instance for external filesystem | 153 // Returns a FileSystemBackend instance for external filesystem |
| 154 // type, which is used only by chromeos for now. This is equivalent to | 154 // type, which is used only by chromeos for now. This is equivalent to |
| 155 // calling GetMountPointProvider(kFileSystemTypeExternal). | 155 // calling GetMountPointProvider(kFileSystemTypeExternal). |
| 156 ExternalFileSystemMountPointProvider* external_provider() const; | 156 ExternalFileSystemBackend* external_provider() const; |
| 157 | 157 |
| 158 // Used for OpenFileSystem. | 158 // Used for OpenFileSystem. |
| 159 typedef base::Callback<void(base::PlatformFileError result, | 159 typedef base::Callback<void(base::PlatformFileError result, |
| 160 const std::string& name, | 160 const std::string& name, |
| 161 const GURL& root)> OpenFileSystemCallback; | 161 const GURL& root)> OpenFileSystemCallback; |
| 162 | 162 |
| 163 // Used for DeleteFileSystem. | 163 // Used for DeleteFileSystem. |
| 164 typedef base::Callback<void(base::PlatformFileError result)> | 164 typedef base::Callback<void(base::PlatformFileError result)> |
| 165 DeleteFileSystemCallback; | 165 DeleteFileSystemCallback; |
| 166 | 166 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 FileSystemURL CreateCrackedFileSystemURL(const GURL& origin, | 229 FileSystemURL CreateCrackedFileSystemURL(const GURL& origin, |
| 230 FileSystemType type, | 230 FileSystemType type, |
| 231 const base::FilePath& path) const; | 231 const base::FilePath& path) const; |
| 232 | 232 |
| 233 #if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) | 233 #if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) |
| 234 // Used only on ChromeOS for now. | 234 // Used only on ChromeOS for now. |
| 235 void EnableTemporaryFileSystemInIncognito(); | 235 void EnableTemporaryFileSystemInIncognito(); |
| 236 #endif | 236 #endif |
| 237 | 237 |
| 238 private: | 238 private: |
| 239 typedef std::map<FileSystemType, FileSystemMountPointProvider*> | 239 typedef std::map<FileSystemType, FileSystemBackend*> |
| 240 MountPointProviderMap; | 240 MountPointProviderMap; |
| 241 | 241 |
| 242 // For CreateFileSystemOperation. | 242 // For CreateFileSystemOperation. |
| 243 friend class FileSystemOperationRunner; | 243 friend class FileSystemOperationRunner; |
| 244 | 244 |
| 245 // For sandbox_provider(). | 245 // For sandbox_provider(). |
| 246 friend class SandboxFileSystemTestHelper; | 246 friend class SandboxFileSystemTestHelper; |
| 247 | 247 |
| 248 // Deleters. | 248 // Deleters. |
| 249 friend struct DefaultContextDeleter; | 249 friend struct DefaultContextDeleter; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 269 // created by cracking |url|. The url is cracked using MountPoints registered | 269 // created by cracking |url|. The url is cracked using MountPoints registered |
| 270 // as |url_crackers_|. If the url cannot be cracked, returns invalid | 270 // as |url_crackers_|. If the url cannot be cracked, returns invalid |
| 271 // FileSystemURL. | 271 // FileSystemURL. |
| 272 // | 272 // |
| 273 // If the original url does not point to an isolated or external filesystem, | 273 // If the original url does not point to an isolated or external filesystem, |
| 274 // returns the original url, without attempting to crack it. | 274 // returns the original url, without attempting to crack it. |
| 275 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const; | 275 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const; |
| 276 | 276 |
| 277 // For initial provider_map construction. This must be called only from | 277 // For initial provider_map construction. This must be called only from |
| 278 // the constructor. | 278 // the constructor. |
| 279 void RegisterMountPointProvider(FileSystemMountPointProvider* provider); | 279 void RegisterMountPointProvider(FileSystemBackend* provider); |
| 280 | 280 |
| 281 // Returns a FileSystemMountPointProvider, used only by test code. | 281 // Returns a FileSystemBackend, used only by test code. |
| 282 SandboxMountPointProvider* sandbox_provider() const { | 282 SandboxMountPointProvider* sandbox_provider() const { |
| 283 return sandbox_provider_.get(); | 283 return sandbox_provider_.get(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 scoped_ptr<FileSystemTaskRunners> task_runners_; | 286 scoped_ptr<FileSystemTaskRunners> task_runners_; |
| 287 | 287 |
| 288 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 288 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 289 | 289 |
| 290 // Regular mount point providers. | 290 // Regular mount point providers. |
| 291 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 291 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
| 292 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; | 292 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; |
| 293 | 293 |
| 294 // Additional mount point providers. | 294 // Additional mount point providers. |
| 295 ScopedVector<FileSystemMountPointProvider> additional_providers_; | 295 ScopedVector<FileSystemBackend> additional_providers_; |
| 296 | 296 |
| 297 // Registered mount point providers. | 297 // Registered mount point providers. |
| 298 // The map must be constructed in the constructor since it can be accessed | 298 // The map must be constructed in the constructor since it can be accessed |
| 299 // on multiple threads. | 299 // on multiple threads. |
| 300 // This map itself doesn't retain each provider's ownership; ownerships | 300 // This map itself doesn't retain each provider's ownership; ownerships |
| 301 // of the providers are held by additional_providers_ or other scoped_ptr | 301 // of the providers are held by additional_providers_ or other scoped_ptr |
| 302 // provider fields. | 302 // provider fields. |
| 303 MountPointProviderMap provider_map_; | 303 MountPointProviderMap provider_map_; |
| 304 | 304 |
| 305 // External mount points visible in the file system context (excluding system | 305 // External mount points visible in the file system context (excluding system |
| (...skipping 18 matching lines...) Expand all Loading... |
| 324 | 324 |
| 325 struct DefaultContextDeleter { | 325 struct DefaultContextDeleter { |
| 326 static void Destruct(const FileSystemContext* context) { | 326 static void Destruct(const FileSystemContext* context) { |
| 327 context->DeleteOnCorrectThread(); | 327 context->DeleteOnCorrectThread(); |
| 328 } | 328 } |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 } // namespace fileapi | 331 } // namespace fileapi |
| 332 | 332 |
| 333 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 333 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| OLD | NEW |