Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: webkit/browser/fileapi/file_system_context.h

Issue 195923002: Add mechanism to auto mount file systems in response to a URL request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update test code Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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|.
kinuko 2014/03/12 05:50:40 nit: would be nice to also note that it's called o
vandebo (ex-Chrome) 2014/03/12 18:35:54 Done.
76 typedef base::Callback<bool(
77 const net::URLRequest* url_request,
78 const FileSystemURL& filesystem_url,
79 const std::string& storage_domain,
80 const base::Callback<void(base::File::Error result)>& callback)>
81 URLRequestAutoMountHandler;
82
68 // This class keeps and provides a file system context for FileSystem API. 83 // This class keeps and provides a file system context for FileSystem API.
69 // An instance of this class is created and owned by profile. 84 // An instance of this class is created and owned by profile.
70 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext 85 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
71 : public base::RefCountedThreadSafe<FileSystemContext, 86 : public base::RefCountedThreadSafe<FileSystemContext,
72 DefaultContextDeleter> { 87 DefaultContextDeleter> {
73 public: 88 public:
74 // Returns file permission policy we should apply for the given |type|. 89 // Returns file permission policy we should apply for the given |type|.
75 // The return value must be bitwise-or'd of FilePermissionPolicy. 90 // The return value must be bitwise-or'd of FilePermissionPolicy.
76 // 91 //
77 // Note: if a part of a filesystem is returned via 'Isolated' mount point, 92 // Note: if a part of a filesystem is returned via 'Isolated' mount point,
(...skipping 10 matching lines...) Expand all
88 // 103 //
89 // |external_mount_points| contains non-system external mount points available 104 // |external_mount_points| contains non-system external mount points available
90 // in the context. If not NULL, it will be used during URL cracking. 105 // 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 106 // |external_mount_points| may be NULL only on platforms different from
92 // ChromeOS (i.e. platforms that don't use external_mount_point_provider). 107 // ChromeOS (i.e. platforms that don't use external_mount_point_provider).
93 // 108 //
94 // |additional_backends| are added to the internal backend map 109 // |additional_backends| are added to the internal backend map
95 // to serve filesystem requests for non-regular types. 110 // to serve filesystem requests for non-regular types.
96 // If none is given, this context only handles HTML5 Sandbox FileSystem 111 // If none is given, this context only handles HTML5 Sandbox FileSystem
97 // and Drag-and-drop Isolated FileSystem requests. 112 // and Drag-and-drop Isolated FileSystem requests.
113 //
114 // |auto_mount_handlers| are used to resolve calls to
115 // AttemptAutoMountForURLRequest. Only external filesystems can be auto
116 // mounted.
98 FileSystemContext( 117 FileSystemContext(
99 base::SingleThreadTaskRunner* io_task_runner, 118 base::SingleThreadTaskRunner* io_task_runner,
100 base::SequencedTaskRunner* file_task_runner, 119 base::SequencedTaskRunner* file_task_runner,
101 ExternalMountPoints* external_mount_points, 120 ExternalMountPoints* external_mount_points,
102 quota::SpecialStoragePolicy* special_storage_policy, 121 quota::SpecialStoragePolicy* special_storage_policy,
103 quota::QuotaManagerProxy* quota_manager_proxy, 122 quota::QuotaManagerProxy* quota_manager_proxy,
104 ScopedVector<FileSystemBackend> additional_backends, 123 ScopedVector<FileSystemBackend> additional_backends,
124 std::vector<URLRequestAutoMountHandler> auto_mount_handlers,
105 const base::FilePath& partition_path, 125 const base::FilePath& partition_path,
106 const FileSystemOptions& options); 126 const FileSystemOptions& options);
107 127
108 bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url); 128 bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url);
109 129
110 // Creates a new QuotaReservation for the given |origin_url| and |type|. 130 // Creates a new QuotaReservation for the given |origin_url| and |type|.
111 // Returns NULL if |type| does not support quota or reservation fails. 131 // 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 132 // This should be run on |default_file_task_runner_| and the returned value
113 // should be destroyed on the runner. 133 // should be destroyed on the runner.
114 scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner( 134 scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 OpenFileSystemMode mode, 206 OpenFileSystemMode mode,
187 const OpenFileSystemCallback& callback); 207 const OpenFileSystemCallback& callback);
188 208
189 // Opens the filesystem for the given |url| as read-only, and then checks the 209 // 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 210 // existence of the file entry referred by the URL. This should be called on
191 // the IO thread. 211 // the IO thread.
192 void ResolveURL( 212 void ResolveURL(
193 const FileSystemURL& url, 213 const FileSystemURL& url,
194 const ResolveURLCallback& callback); 214 const ResolveURLCallback& callback);
195 215
216 // Attempts to mount the filesystem needed to satisfy |url_request| made
217 // from |storage_domain|. If an appropriate file system is not found,
218 // callback will return an error.
219 void AttemptAutoMountForURLRequest(const net::URLRequest* url_request,
220 const std::string& storage_domain,
221 const StatusCallback& callback);
222
196 // Deletes the filesystem for the given |origin_url| and |type|. This should 223 // Deletes the filesystem for the given |origin_url| and |type|. This should
197 // be called on the IO thread. 224 // be called on the IO thread.
198 void DeleteFileSystem( 225 void DeleteFileSystem(
199 const GURL& origin_url, 226 const GURL& origin_url,
200 FileSystemType type, 227 FileSystemType type,
201 const StatusCallback& callback); 228 const StatusCallback& callback);
202 229
203 // Creates new FileStreamReader instance to read a file pointed by the given 230 // Creates new FileStreamReader instance to read a file pointed by the given
204 // filesystem URL |url| starting from |offset|. |expected_modification_time| 231 // filesystem URL |url| starting from |offset|. |expected_modification_time|
205 // specifies the expected last modification if the value is non-null, the 232 // specifies the expected last modification if the value is non-null, the
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_; 363 scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_;
337 364
338 // Regular file system backends. 365 // Regular file system backends.
339 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; 366 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_;
340 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_; 367 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_;
341 368
342 // Additional file system backends. 369 // Additional file system backends.
343 scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_; 370 scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_;
344 ScopedVector<FileSystemBackend> additional_backends_; 371 ScopedVector<FileSystemBackend> additional_backends_;
345 372
373 std::vector<URLRequestAutoMountHandler> auto_mount_handlers_;
374
346 // Registered file system backends. 375 // Registered file system backends.
347 // The map must be constructed in the constructor since it can be accessed 376 // The map must be constructed in the constructor since it can be accessed
348 // on multiple threads. 377 // on multiple threads.
349 // This map itself doesn't retain each backend's ownership; ownerships 378 // This map itself doesn't retain each backend's ownership; ownerships
350 // of the backends are held by additional_backends_ or other scoped_ptr 379 // of the backends are held by additional_backends_ or other scoped_ptr
351 // backend fields. 380 // backend fields.
352 FileSystemBackendMap backend_map_; 381 FileSystemBackendMap backend_map_;
353 382
354 // External mount points visible in the file system context (excluding system 383 // External mount points visible in the file system context (excluding system
355 // external mount points). 384 // external mount points).
(...skipping 15 matching lines...) Expand all
371 400
372 struct DefaultContextDeleter { 401 struct DefaultContextDeleter {
373 static void Destruct(const FileSystemContext* context) { 402 static void Destruct(const FileSystemContext* context) {
374 context->DeleteOnCorrectThread(); 403 context->DeleteOnCorrectThread();
375 } 404 }
376 }; 405 };
377 406
378 } // namespace fileapi 407 } // namespace fileapi
379 408
380 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 409 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698