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