| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 namespace chrome { | 32 namespace chrome { |
| 33 class NativeMediaFileUtilTest; | 33 class NativeMediaFileUtilTest; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace quota { | 36 namespace quota { |
| 37 class QuotaManagerProxy; | 37 class QuotaManagerProxy; |
| 38 class SpecialStoragePolicy; | 38 class SpecialStoragePolicy; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace net { | |
| 42 class URLRequest; | |
| 43 } | |
| 44 | |
| 45 namespace webkit_blob { | 41 namespace webkit_blob { |
| 46 class BlobURLRequestJobTest; | 42 class BlobURLRequestJobTest; |
| 47 class FileStreamReader; | 43 class FileStreamReader; |
| 48 } | 44 } |
| 49 | 45 |
| 50 namespace fileapi { | 46 namespace fileapi { |
| 51 | 47 |
| 52 class AsyncFileUtil; | 48 class AsyncFileUtil; |
| 53 class CopyOrMoveFileValidatorFactory; | 49 class CopyOrMoveFileValidatorFactory; |
| 54 class ExternalFileSystemBackend; | 50 class ExternalFileSystemBackend; |
| 55 class ExternalMountPoints; | 51 class ExternalMountPoints; |
| 56 class FileStreamWriter; | 52 class FileStreamWriter; |
| 57 class FileSystemBackend; | 53 class FileSystemBackend; |
| 58 class FileSystemFileUtil; | 54 class FileSystemFileUtil; |
| 59 class FileSystemOperation; | 55 class FileSystemOperation; |
| 60 class FileSystemOperationRunner; | 56 class FileSystemOperationRunner; |
| 61 class FileSystemOptions; | 57 class FileSystemOptions; |
| 62 class FileSystemQuotaUtil; | 58 class FileSystemQuotaUtil; |
| 63 class FileSystemURL; | 59 class FileSystemURL; |
| 64 class IsolatedFileSystemBackend; | 60 class IsolatedFileSystemBackend; |
| 65 class MountPoints; | 61 class MountPoints; |
| 66 class QuotaReservation; | 62 class QuotaReservation; |
| 67 class SandboxFileSystemBackend; | 63 class SandboxFileSystemBackend; |
| 68 | 64 |
| 69 struct DefaultContextDeleter; | 65 struct DefaultContextDeleter; |
| 70 struct FileSystemInfo; | 66 struct FileSystemInfo; |
| 71 | 67 |
| 72 // An auto mount handler will attempt to mount the file system requested in | |
| 73 // |url_request|. If the URL is for this auto mount handler, it returns true | |
| 74 // and calls |callback| when the attempt is complete. If the auto mounter | |
| 75 // does not recognize the URL, it returns false and does not call |callback|. | |
| 76 // Called on the IO thread. | |
| 77 typedef base::Callback<bool( | |
| 78 const net::URLRequest* url_request, | |
| 79 const FileSystemURL& filesystem_url, | |
| 80 const std::string& storage_domain, | |
| 81 const base::Callback<void(base::File::Error result)>& callback)> | |
| 82 URLRequestAutoMountHandler; | |
| 83 | |
| 84 // This class keeps and provides a file system context for FileSystem API. | 68 // This class keeps and provides a file system context for FileSystem API. |
| 85 // An instance of this class is created and owned by profile. | 69 // An instance of this class is created and owned by profile. |
| 86 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext | 70 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext |
| 87 : public base::RefCountedThreadSafe<FileSystemContext, | 71 : public base::RefCountedThreadSafe<FileSystemContext, |
| 88 DefaultContextDeleter> { | 72 DefaultContextDeleter> { |
| 89 public: | 73 public: |
| 90 // Returns file permission policy we should apply for the given |type|. | 74 // Returns file permission policy we should apply for the given |type|. |
| 91 // The return value must be bitwise-or'd of FilePermissionPolicy. | 75 // The return value must be bitwise-or'd of FilePermissionPolicy. |
| 92 // | 76 // |
| 93 // Note: if a part of a filesystem is returned via 'Isolated' mount point, | 77 // Note: if a part of a filesystem is returned via 'Isolated' mount point, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 104 // | 88 // |
| 105 // |external_mount_points| contains non-system external mount points available | 89 // |external_mount_points| contains non-system external mount points available |
| 106 // in the context. If not NULL, it will be used during URL cracking. | 90 // in the context. If not NULL, it will be used during URL cracking. |
| 107 // |external_mount_points| may be NULL only on platforms different from | 91 // |external_mount_points| may be NULL only on platforms different from |
| 108 // ChromeOS (i.e. platforms that don't use external_mount_point_provider). | 92 // ChromeOS (i.e. platforms that don't use external_mount_point_provider). |
| 109 // | 93 // |
| 110 // |additional_backends| are added to the internal backend map | 94 // |additional_backends| are added to the internal backend map |
| 111 // to serve filesystem requests for non-regular types. | 95 // to serve filesystem requests for non-regular types. |
| 112 // If none is given, this context only handles HTML5 Sandbox FileSystem | 96 // If none is given, this context only handles HTML5 Sandbox FileSystem |
| 113 // and Drag-and-drop Isolated FileSystem requests. | 97 // and Drag-and-drop Isolated FileSystem requests. |
| 114 // | |
| 115 // |auto_mount_handlers| are used to resolve calls to | |
| 116 // AttemptAutoMountForURLRequest. Only external filesystems are auto mounted | |
| 117 // when a filesystem: URL request is made. | |
| 118 FileSystemContext( | 98 FileSystemContext( |
| 119 base::SingleThreadTaskRunner* io_task_runner, | 99 base::SingleThreadTaskRunner* io_task_runner, |
| 120 base::SequencedTaskRunner* file_task_runner, | 100 base::SequencedTaskRunner* file_task_runner, |
| 121 ExternalMountPoints* external_mount_points, | 101 ExternalMountPoints* external_mount_points, |
| 122 quota::SpecialStoragePolicy* special_storage_policy, | 102 quota::SpecialStoragePolicy* special_storage_policy, |
| 123 quota::QuotaManagerProxy* quota_manager_proxy, | 103 quota::QuotaManagerProxy* quota_manager_proxy, |
| 124 ScopedVector<FileSystemBackend> additional_backends, | 104 ScopedVector<FileSystemBackend> additional_backends, |
| 125 const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers, | |
| 126 const base::FilePath& partition_path, | 105 const base::FilePath& partition_path, |
| 127 const FileSystemOptions& options); | 106 const FileSystemOptions& options); |
| 128 | 107 |
| 129 bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url); | 108 bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url); |
| 130 | 109 |
| 131 // Creates a new QuotaReservation for the given |origin_url| and |type|. | 110 // Creates a new QuotaReservation for the given |origin_url| and |type|. |
| 132 // Returns NULL if |type| does not support quota or reservation fails. | 111 // Returns NULL if |type| does not support quota or reservation fails. |
| 133 // This should be run on |default_file_task_runner_| and the returned value | 112 // This should be run on |default_file_task_runner_| and the returned value |
| 134 // should be destroyed on the runner. | 113 // should be destroyed on the runner. |
| 135 scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner( | 114 scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 OpenFileSystemMode mode, | 186 OpenFileSystemMode mode, |
| 208 const OpenFileSystemCallback& callback); | 187 const OpenFileSystemCallback& callback); |
| 209 | 188 |
| 210 // Opens the filesystem for the given |url| as read-only, and then checks the | 189 // Opens the filesystem for the given |url| as read-only, and then checks the |
| 211 // existence of the file entry referred by the URL. This should be called on | 190 // existence of the file entry referred by the URL. This should be called on |
| 212 // the IO thread. | 191 // the IO thread. |
| 213 void ResolveURL( | 192 void ResolveURL( |
| 214 const FileSystemURL& url, | 193 const FileSystemURL& url, |
| 215 const ResolveURLCallback& callback); | 194 const ResolveURLCallback& callback); |
| 216 | 195 |
| 217 // Attempts to mount the filesystem needed to satisfy |url_request| made | |
| 218 // from |storage_domain|. If an appropriate file system is not found, | |
| 219 // callback will return an error. | |
| 220 void AttemptAutoMountForURLRequest(const net::URLRequest* url_request, | |
| 221 const std::string& storage_domain, | |
| 222 const StatusCallback& callback); | |
| 223 | |
| 224 // Deletes the filesystem for the given |origin_url| and |type|. This should | 196 // Deletes the filesystem for the given |origin_url| and |type|. This should |
| 225 // be called on the IO thread. | 197 // be called on the IO thread. |
| 226 void DeleteFileSystem( | 198 void DeleteFileSystem( |
| 227 const GURL& origin_url, | 199 const GURL& origin_url, |
| 228 FileSystemType type, | 200 FileSystemType type, |
| 229 const StatusCallback& callback); | 201 const StatusCallback& callback); |
| 230 | 202 |
| 231 // Creates new FileStreamReader instance to read a file pointed by the given | 203 // Creates new FileStreamReader instance to read a file pointed by the given |
| 232 // filesystem URL |url| starting from |offset|. |expected_modification_time| | 204 // filesystem URL |url| starting from |offset|. |expected_modification_time| |
| 233 // specifies the expected last modification if the value is non-null, the | 205 // specifies the expected last modification if the value is non-null, the |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_; | 336 scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_; |
| 365 | 337 |
| 366 // Regular file system backends. | 338 // Regular file system backends. |
| 367 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; | 339 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; |
| 368 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_; | 340 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_; |
| 369 | 341 |
| 370 // Additional file system backends. | 342 // Additional file system backends. |
| 371 scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_; | 343 scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_; |
| 372 ScopedVector<FileSystemBackend> additional_backends_; | 344 ScopedVector<FileSystemBackend> additional_backends_; |
| 373 | 345 |
| 374 std::vector<URLRequestAutoMountHandler> auto_mount_handlers_; | |
| 375 | |
| 376 // Registered file system backends. | 346 // Registered file system backends. |
| 377 // The map must be constructed in the constructor since it can be accessed | 347 // The map must be constructed in the constructor since it can be accessed |
| 378 // on multiple threads. | 348 // on multiple threads. |
| 379 // This map itself doesn't retain each backend's ownership; ownerships | 349 // This map itself doesn't retain each backend's ownership; ownerships |
| 380 // of the backends are held by additional_backends_ or other scoped_ptr | 350 // of the backends are held by additional_backends_ or other scoped_ptr |
| 381 // backend fields. | 351 // backend fields. |
| 382 FileSystemBackendMap backend_map_; | 352 FileSystemBackendMap backend_map_; |
| 383 | 353 |
| 384 // External mount points visible in the file system context (excluding system | 354 // External mount points visible in the file system context (excluding system |
| 385 // external mount points). | 355 // external mount points). |
| (...skipping 15 matching lines...) Expand all Loading... |
| 401 | 371 |
| 402 struct DefaultContextDeleter { | 372 struct DefaultContextDeleter { |
| 403 static void Destruct(const FileSystemContext* context) { | 373 static void Destruct(const FileSystemContext* context) { |
| 404 context->DeleteOnCorrectThread(); | 374 context->DeleteOnCorrectThread(); |
| 405 } | 375 } |
| 406 }; | 376 }; |
| 407 | 377 |
| 408 } // namespace fileapi | 378 } // namespace fileapi |
| 409 | 379 |
| 410 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 380 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| OLD | NEW |