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

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

Issue 20989003: Deprecate FileSystemTaskRunners (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 4 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>
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/memory/scoped_vector.h"
16 #include "base/platform_file.h" 16 #include "base/platform_file.h"
17 #include "base/sequenced_task_runner_helpers.h" 17 #include "base/sequenced_task_runner_helpers.h"
18 #include "webkit/browser/fileapi/file_system_url.h" 18 #include "webkit/browser/fileapi/file_system_url.h"
19 #include "webkit/browser/fileapi/open_file_system_mode.h" 19 #include "webkit/browser/fileapi/open_file_system_mode.h"
20 #include "webkit/browser/fileapi/sandbox_context.h" 20 #include "webkit/browser/fileapi/sandbox_context.h"
21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" 21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
22 #include "webkit/browser/webkit_storage_browser_export.h" 22 #include "webkit/browser/webkit_storage_browser_export.h"
23 #include "webkit/common/fileapi/file_system_types.h" 23 #include "webkit/common/fileapi/file_system_types.h"
24 24
25 namespace base { 25 namespace base {
26 class FilePath; 26 class FilePath;
27 class SequencedTaskRunner;
28 class SingleThreadTaskRunner;
27 } 29 }
28 30
29 namespace chrome { 31 namespace chrome {
30 class NativeMediaFileUtilTest; 32 class NativeMediaFileUtilTest;
31 } 33 }
32 34
33 namespace quota { 35 namespace quota {
34 class QuotaManagerProxy; 36 class QuotaManagerProxy;
35 class SpecialStoragePolicy; 37 class SpecialStoragePolicy;
36 } 38 }
37 39
38 namespace webkit_blob { 40 namespace webkit_blob {
39 class BlobURLRequestJobTest; 41 class BlobURLRequestJobTest;
40 class FileStreamReader; 42 class FileStreamReader;
41 } 43 }
42 44
43 namespace fileapi { 45 namespace fileapi {
44 46
45 class AsyncFileUtil; 47 class AsyncFileUtil;
46 class CopyOrMoveFileValidatorFactory; 48 class CopyOrMoveFileValidatorFactory;
47 class ExternalFileSystemBackend; 49 class ExternalFileSystemBackend;
48 class ExternalMountPoints; 50 class ExternalMountPoints;
49 class FileStreamWriter; 51 class FileStreamWriter;
50 class FileSystemFileUtil; 52 class FileSystemFileUtil;
51 class FileSystemBackend; 53 class FileSystemBackend;
52 class FileSystemOperation; 54 class FileSystemOperation;
53 class FileSystemOperationRunner; 55 class FileSystemOperationRunner;
54 class FileSystemOptions; 56 class FileSystemOptions;
55 class FileSystemQuotaUtil; 57 class FileSystemQuotaUtil;
56 class FileSystemTaskRunners;
57 class FileSystemURL; 58 class FileSystemURL;
58 class IsolatedFileSystemBackend; 59 class IsolatedFileSystemBackend;
59 class MountPoints; 60 class MountPoints;
60 class SandboxFileSystemBackend; 61 class SandboxFileSystemBackend;
61 62
62 struct DefaultContextDeleter; 63 struct DefaultContextDeleter;
63 64
64 // This class keeps and provides a file system context for FileSystem API. 65 // This class keeps and provides a file system context for FileSystem API.
65 // An instance of this class is created and owned by profile. 66 // An instance of this class is created and owned by profile.
66 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext 67 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
67 : public base::RefCountedThreadSafe<FileSystemContext, 68 : public base::RefCountedThreadSafe<FileSystemContext,
68 DefaultContextDeleter> { 69 DefaultContextDeleter> {
69 public: 70 public:
70 // Returns file permission policy we should apply for the given |type|. 71 // Returns file permission policy we should apply for the given |type|.
71 // The return value must be bitwise-or'd of FilePermissionPolicy. 72 // The return value must be bitwise-or'd of FilePermissionPolicy.
72 // 73 //
73 // Note: if a part of a filesystem is returned via 'Isolated' mount point, 74 // Note: if a part of a filesystem is returned via 'Isolated' mount point,
74 // its per-filesystem permission overrides the underlying filesystem's 75 // its per-filesystem permission overrides the underlying filesystem's
75 // permission policy. 76 // permission policy.
76 static int GetPermissionPolicy(FileSystemType type); 77 static int GetPermissionPolicy(FileSystemType type);
77 78
78 // task_runners->file_task_runner() is used as default TaskRunner. 79 // file_task_runner is used as default TaskRunner.
79 // Unless a FileSystemBackend is overridden in CreateFileSystemOperation, 80 // Unless a FileSystemBackend is overridden in CreateFileSystemOperation,
80 // it is used for all file operations and file related meta operations. 81 // it is used for all file operations and file related meta operations.
81 // The code assumes that 82 // The code assumes that file_task_runner->RunsTasksOnCurrentThread()
82 // task_runners->file_task_runner()->RunsTasksOnCurrentThread()
83 // returns false if the current task is not running on the thread that allows 83 // returns false if the current task is not running on the thread that allows
84 // blocking file operations (like SequencedWorkerPool implementation does). 84 // blocking file operations (like SequencedWorkerPool implementation does).
85 // 85 //
86 // |external_mount_points| contains non-system external mount points available 86 // |external_mount_points| contains non-system external mount points available
87 // in the context. If not NULL, it will be used during URL cracking. 87 // in the context. If not NULL, it will be used during URL cracking.
88 // |external_mount_points| may be NULL only on platforms different from 88 // |external_mount_points| may be NULL only on platforms different from
89 // ChromeOS (i.e. platforms that don't use external_mount_point_provider). 89 // ChromeOS (i.e. platforms that don't use external_mount_point_provider).
90 // 90 //
91 // |additional_backends| are added to the internal backend map 91 // |additional_backends| are added to the internal backend map
92 // to serve filesystem requests for non-regular types. 92 // to serve filesystem requests for non-regular types.
93 // If none is given, this context only handles HTML5 Sandbox FileSystem 93 // If none is given, this context only handles HTML5 Sandbox FileSystem
94 // and Drag-and-drop Isolated FileSystem requests. 94 // and Drag-and-drop Isolated FileSystem requests.
95 FileSystemContext( 95 FileSystemContext(
96 scoped_ptr<FileSystemTaskRunners> task_runners, 96 base::SingleThreadTaskRunner* io_task_runner,
97 base::SequencedTaskRunner* file_task_runner,
97 ExternalMountPoints* external_mount_points, 98 ExternalMountPoints* external_mount_points,
98 quota::SpecialStoragePolicy* special_storage_policy, 99 quota::SpecialStoragePolicy* special_storage_policy,
99 quota::QuotaManagerProxy* quota_manager_proxy, 100 quota::QuotaManagerProxy* quota_manager_proxy,
100 ScopedVector<FileSystemBackend> additional_backends, 101 ScopedVector<FileSystemBackend> additional_backends,
101 const base::FilePath& partition_path, 102 const base::FilePath& partition_path,
102 const FileSystemOptions& options); 103 const FileSystemOptions& options);
103 104
104 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); 105 bool DeleteDataForOriginOnFileThread(const GURL& origin_url);
105 106
106 quota::QuotaManagerProxy* quota_manager_proxy() const { 107 quota::QuotaManagerProxy* quota_manager_proxy() const {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 195
195 // Creates new FileStreamWriter instance to write into a file pointed by 196 // Creates new FileStreamWriter instance to write into a file pointed by
196 // |url| from |offset|. 197 // |url| from |offset|.
197 scoped_ptr<FileStreamWriter> CreateFileStreamWriter( 198 scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
198 const FileSystemURL& url, 199 const FileSystemURL& url,
199 int64 offset); 200 int64 offset);
200 201
201 // Creates a new FileSystemOperationRunner. 202 // Creates a new FileSystemOperationRunner.
202 scoped_ptr<FileSystemOperationRunner> CreateFileSystemOperationRunner(); 203 scoped_ptr<FileSystemOperationRunner> CreateFileSystemOperationRunner();
203 204
204 FileSystemTaskRunners* task_runners() { return task_runners_.get(); } 205 base::SequencedTaskRunner* default_file_task_runner() {
206 return default_file_task_runner_.get();
207 }
205 208
206 FileSystemOperationRunner* operation_runner() { 209 FileSystemOperationRunner* operation_runner() {
207 return operation_runner_.get(); 210 return operation_runner_.get();
208 } 211 }
209 212
210 const base::FilePath& partition_path() const { return partition_path_; } 213 const base::FilePath& partition_path() const { return partition_path_; }
211 214
212 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from |url|. 215 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from |url|.
213 FileSystemURL CrackURL(const GURL& url) const; 216 FileSystemURL CrackURL(const GURL& url) const;
214 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from method 217 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from method
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 268
266 // For initial backend_map construction. This must be called only from 269 // For initial backend_map construction. This must be called only from
267 // the constructor. 270 // the constructor.
268 void RegisterBackend(FileSystemBackend* backend); 271 void RegisterBackend(FileSystemBackend* backend);
269 272
270 // Returns a FileSystemBackend, used only by test code. 273 // Returns a FileSystemBackend, used only by test code.
271 SandboxFileSystemBackend* sandbox_backend() const { 274 SandboxFileSystemBackend* sandbox_backend() const {
272 return sandbox_backend_.get(); 275 return sandbox_backend_.get();
273 } 276 }
274 277
275 scoped_ptr<FileSystemTaskRunners> task_runners_; 278 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
279 scoped_refptr<base::SequencedTaskRunner> default_file_task_runner_;
276 280
277 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 281 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
278 282
279 scoped_ptr<SandboxContext> sandbox_context_; 283 scoped_ptr<SandboxContext> sandbox_context_;
280 284
281 // Regular file system backends. 285 // Regular file system backends.
282 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; 286 scoped_ptr<SandboxFileSystemBackend> sandbox_backend_;
283 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_; 287 scoped_ptr<IsolatedFileSystemBackend> isolated_backend_;
284 288
285 // Additional file system backends. 289 // Additional file system backends.
(...skipping 25 matching lines...) Expand all
311 315
312 struct DefaultContextDeleter { 316 struct DefaultContextDeleter {
313 static void Destruct(const FileSystemContext* context) { 317 static void Destruct(const FileSystemContext* context) {
314 context->DeleteOnCorrectThread(); 318 context->DeleteOnCorrectThread();
315 } 319 }
316 }; 320 };
317 321
318 } // namespace fileapi 322 } // namespace fileapi
319 323
320 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 324 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.cc ('k') | webkit/browser/fileapi/file_system_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698