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

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

Issue 14096022: Make MountPointProvider pluggable from outside webkit/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix etc Created 7 years, 8 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_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 6 #define WEBKIT_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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h"
15 #include "base/platform_file.h" 16 #include "base/platform_file.h"
16 #include "base/sequenced_task_runner_helpers.h" 17 #include "base/sequenced_task_runner_helpers.h"
17 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
18 #include "webkit/fileapi/file_system_url.h" 19 #include "webkit/fileapi/file_system_url.h"
19 #include "webkit/fileapi/task_runner_bound_observer_list.h" 20 #include "webkit/fileapi/task_runner_bound_observer_list.h"
20 #include "webkit/storage/webkit_storage_export.h" 21 #include "webkit/storage/webkit_storage_export.h"
21 22
22 namespace base { 23 namespace base {
23 class FilePath; 24 class FilePath;
24 } 25 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // The code assumes that 71 // The code assumes that
71 // task_runners->file_task_runner()->RunsTasksOnCurrentThread() 72 // task_runners->file_task_runner()->RunsTasksOnCurrentThread()
72 // returns false if the current task is not running on the thread that allows 73 // returns false if the current task is not running on the thread that allows
73 // blocking file operations (like SequencedWorkerPool implementation does). 74 // blocking file operations (like SequencedWorkerPool implementation does).
74 // 75 //
75 // |external_mount_points| contains non-system external mount points available 76 // |external_mount_points| contains non-system external mount points available
76 // in the context. If not NULL, it will be used during URL cracking. On 77 // in the context. If not NULL, it will be used during URL cracking. On
77 // ChromeOS, it will be passed to external_mount_point_provider. 78 // ChromeOS, it will be passed to external_mount_point_provider.
78 // |external_mount_points| may be NULL only on platforms different from 79 // |external_mount_points| may be NULL only on platforms different from
79 // ChromeOS (i.e. platforms that don't use external_mount_point_provider). 80 // ChromeOS (i.e. platforms that don't use external_mount_point_provider).
81 //
82 // |additional_providers| are added to the internal provider map
83 // to serve filesystem requests for non-regular types.
84 // If none is given, this context only handles HTML5 Sandbox FileSystem
85 // and Drag-and-drop Isolated FileSystem requests.
80 FileSystemContext( 86 FileSystemContext(
81 scoped_ptr<FileSystemTaskRunners> task_runners, 87 scoped_ptr<FileSystemTaskRunners> task_runners,
82 ExternalMountPoints* external_mount_points, 88 ExternalMountPoints* external_mount_points,
83 quota::SpecialStoragePolicy* special_storage_policy, 89 quota::SpecialStoragePolicy* special_storage_policy,
84 quota::QuotaManagerProxy* quota_manager_proxy, 90 quota::QuotaManagerProxy* quota_manager_proxy,
91 ScopedVector<FileSystemMountPointProvider> additional_providers,
85 const base::FilePath& partition_path, 92 const base::FilePath& partition_path,
86 const FileSystemOptions& options); 93 const FileSystemOptions& options);
87 94
88 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); 95 bool DeleteDataForOriginOnFileThread(const GURL& origin_url);
89 96
90 quota::QuotaManagerProxy* quota_manager_proxy() const { 97 quota::QuotaManagerProxy* quota_manager_proxy() const {
91 return quota_manager_proxy_.get(); 98 return quota_manager_proxy_.get();
92 } 99 }
93 100
94 // Returns a quota util for a given filesystem type. This may 101 // Returns a quota util for a given filesystem type. This may
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const FileSystemURL& url, 192 const FileSystemURL& url,
186 int64 offset, 193 int64 offset,
187 const base::Time& expected_modification_time); 194 const base::Time& expected_modification_time);
188 195
189 // Creates new FileStreamWriter instance to write into a file pointed by 196 // Creates new FileStreamWriter instance to write into a file pointed by
190 // |url| from |offset|. 197 // |url| from |offset|.
191 scoped_ptr<FileStreamWriter> CreateFileStreamWriter( 198 scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
192 const FileSystemURL& url, 199 const FileSystemURL& url,
193 int64 offset); 200 int64 offset);
194 201
195 // Register a filesystem provider. The ownership of |provider| is
196 // transferred to this instance.
197 void RegisterMountPointProvider(FileSystemType type,
198 FileSystemMountPointProvider* provider);
199
200 FileSystemTaskRunners* task_runners() { return task_runners_.get(); } 202 FileSystemTaskRunners* task_runners() { return task_runners_.get(); }
201 203
202 sync_file_system::LocalFileChangeTracker* change_tracker() { 204 sync_file_system::LocalFileChangeTracker* change_tracker() {
203 return change_tracker_.get(); 205 return change_tracker_.get();
204 } 206 }
205 void SetLocalFileChangeTracker( 207 void SetLocalFileChangeTracker(
206 scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker); 208 scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker);
207 209
208 sync_file_system::LocalFileSyncContext* sync_context() { 210 sync_file_system::LocalFileSyncContext* sync_context() {
209 return sync_context_.get(); 211 return sync_context_.get();
210 } 212 }
211 void set_sync_context(sync_file_system::LocalFileSyncContext* sync_context); 213 void set_sync_context(sync_file_system::LocalFileSyncContext* sync_context);
212 214
213 const base::FilePath& partition_path() const { return partition_path_; } 215 const base::FilePath& partition_path() const { return partition_path_; }
214 216
215 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from |url|. 217 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from |url|.
216 FileSystemURL CrackURL(const GURL& url) const; 218 FileSystemURL CrackURL(const GURL& url) const;
217 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from method 219 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from method
218 // arguments. 220 // arguments.
219 FileSystemURL CreateCrackedFileSystemURL(const GURL& origin, 221 FileSystemURL CreateCrackedFileSystemURL(const GURL& origin,
220 FileSystemType type, 222 FileSystemType type,
221 const base::FilePath& path) const; 223 const base::FilePath& path) const;
222 224
223 private: 225 private:
226 typedef std::map<FileSystemType, FileSystemMountPointProvider*>
227 MountPointProviderMap;
228
224 // Friended for GetFileUtil. 229 // Friended for GetFileUtil.
225 // These classes know the target filesystem (i.e. sandbox filesystem) 230 // These classes know the target filesystem (i.e. sandbox filesystem)
226 // supports synchronous FileUtil. 231 // supports synchronous FileUtil.
227 friend class LocalFileSystemOperation; 232 friend class LocalFileSystemOperation;
228 friend class sync_file_system::LocalFileChangeTracker; 233 friend class sync_file_system::LocalFileChangeTracker;
229 friend class sync_file_system::LocalFileSyncContext; 234 friend class sync_file_system::LocalFileSyncContext;
230 235
231 // Friended for GetFileUtil. 236 // Friended for GetFileUtil.
232 // Test classes that rely on synchronous FileUtils. 237 // Test classes that rely on synchronous FileUtils.
233 friend class webkit_blob::BlobURLRequestJobTest; 238 friend class webkit_blob::BlobURLRequestJobTest;
(...skipping 19 matching lines...) Expand all
253 // 258 //
254 // If the original url does not point to an isolated or external filesystem, 259 // If the original url does not point to an isolated or external filesystem,
255 // returns the original url, without attempting to crack it. 260 // returns the original url, without attempting to crack it.
256 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const; 261 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const;
257 262
258 // Returns the appropriate FileUtil instance for the given |type|. 263 // Returns the appropriate FileUtil instance for the given |type|.
259 // This may return NULL if it is given an invalid type or the filesystem 264 // This may return NULL if it is given an invalid type or the filesystem
260 // does not support synchronous file operations. 265 // does not support synchronous file operations.
261 FileSystemFileUtil* GetFileUtil(FileSystemType type) const; 266 FileSystemFileUtil* GetFileUtil(FileSystemType type) const;
262 267
268 // For initial provider_map construction. This must be called only from
269 // the constructor.
270 void RegisterMountPointProvider(FileSystemMountPointProvider* provider);
271
263 scoped_ptr<FileSystemTaskRunners> task_runners_; 272 scoped_ptr<FileSystemTaskRunners> task_runners_;
264 273
265 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 274 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
266 275
267 // Regular mount point providers. 276 // Regular mount point providers.
268 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; 277 scoped_ptr<SandboxMountPointProvider> sandbox_provider_;
269 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; 278 scoped_ptr<IsolatedMountPointProvider> isolated_provider_;
270 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; 279 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_;
271 280
281 // Additional mount point providers.
282 ScopedVector<FileSystemMountPointProvider> additional_providers_;
283
272 // Registered mount point providers. 284 // Registered mount point providers.
273 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_; 285 // The map must be constructed in the constructor since it can be accessed
274 286 // on multiple threads.
287 // The ownership of each provider is held by mount_point_providers_.
288 MountPointProviderMap provider_map_;
275 // External mount points visible in the file system context (excluding system 289 // External mount points visible in the file system context (excluding system
276 // external mount points). 290 // external mount points).
277 scoped_refptr<ExternalMountPoints> external_mount_points_; 291 scoped_refptr<ExternalMountPoints> external_mount_points_;
278 292
279 // MountPoints used to crack FileSystemURLs. The MountPoints are ordered 293 // MountPoints used to crack FileSystemURLs. The MountPoints are ordered
280 // in order they should try to crack a FileSystemURL. 294 // in order they should try to crack a FileSystemURL.
281 std::vector<MountPoints*> url_crackers_; 295 std::vector<MountPoints*> url_crackers_;
282 296
283 // The base path of the storage partition for this context. 297 // The base path of the storage partition for this context.
284 const base::FilePath partition_path_; 298 const base::FilePath partition_path_;
285 299
286 // For syncable file systems. 300 // For syncable file systems.
287 scoped_ptr<sync_file_system::LocalFileChangeTracker> change_tracker_; 301 scoped_ptr<sync_file_system::LocalFileChangeTracker> change_tracker_;
288 scoped_refptr<sync_file_system::LocalFileSyncContext> sync_context_; 302 scoped_refptr<sync_file_system::LocalFileSyncContext> sync_context_;
289 303
290 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); 304 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext);
291 }; 305 };
292 306
293 struct DefaultContextDeleter { 307 struct DefaultContextDeleter {
294 static void Destruct(const FileSystemContext* context) { 308 static void Destruct(const FileSystemContext* context) {
295 context->DeleteOnCorrectThread(); 309 context->DeleteOnCorrectThread();
296 } 310 }
297 }; 311 };
298 312
299 } // namespace fileapi 313 } // namespace fileapi
300 314
301 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 315 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/copy_or_move_file_validator_unittest.cc ('k') | webkit/fileapi/file_system_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698