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

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

Issue 10829147: Make MediaFileUtil run on thread pool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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_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 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/sequenced_task_runner_helpers.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/platform_file.h" 15 #include "base/platform_file.h"
15 #include "base/sequenced_task_runner_helpers.h"
16 #include "webkit/fileapi/fileapi_export.h" 16 #include "webkit/fileapi/fileapi_export.h"
17 #include "webkit/fileapi/file_system_types.h" 17 #include "webkit/fileapi/file_system_types.h"
18 #include "webkit/quota/special_storage_policy.h" 18 #include "webkit/quota/special_storage_policy.h"
19 19
20 class FilePath; 20 class FilePath;
21 21
22 namespace base {
23 class SequencedTaskRunner;
24 class SingleThreadTaskRunner;
25 }
26
27 namespace quota { 22 namespace quota {
28 class QuotaManagerProxy; 23 class QuotaManagerProxy;
29 } 24 }
30 25
31 namespace webkit_blob { 26 namespace webkit_blob {
32 class FileStreamReader; 27 class FileStreamReader;
33 } 28 }
34 29
35 namespace fileapi { 30 namespace fileapi {
36 31
37 class ExternalFileSystemMountPointProvider; 32 class ExternalFileSystemMountPointProvider;
38 class FileSystemFileUtil; 33 class FileSystemFileUtil;
39 class FileSystemMountPointProvider; 34 class FileSystemMountPointProvider;
40 class FileSystemOperationInterface; 35 class FileSystemOperationInterface;
41 class FileSystemOptions; 36 class FileSystemOptions;
42 class FileSystemQuotaUtil; 37 class FileSystemQuotaUtil;
38 class FileSystemTaskRunners;
43 class FileSystemURL; 39 class FileSystemURL;
44 class IsolatedMountPointProvider; 40 class IsolatedMountPointProvider;
45 class SandboxMountPointProvider; 41 class SandboxMountPointProvider;
46 42
47 struct DefaultContextDeleter; 43 struct DefaultContextDeleter;
48 44
49 // This class keeps and provides a file system context for FileSystem API. 45 // This class keeps and provides a file system context for FileSystem API.
50 // An instance of this class is created and owned by profile. 46 // An instance of this class is created and owned by profile.
51 class FILEAPI_EXPORT FileSystemContext 47 class FILEAPI_EXPORT FileSystemContext
52 : public base::RefCountedThreadSafe<FileSystemContext, 48 : public base::RefCountedThreadSafe<FileSystemContext,
53 DefaultContextDeleter> { 49 DefaultContextDeleter> {
54 public: 50 public:
55 // |file_task_runner| is used for all file operations and file related 51 // |file_task_runner| is used for all file operations and file related
kinuko 2012/08/03 23:13:39 nit: can you update the comment as well?
tzik 2012/08/04 00:24:21 Done.
56 // meta operations. 52 // meta operations.
57 // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns 53 // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns
58 // false if the current task is not running on the thread that allows 54 // false if the current task is not running on the thread that allows
59 // blocking file operations (like SequencedWorkerPool implementation does). 55 // blocking file operations (like SequencedWorkerPool implementation does).
60 FileSystemContext( 56 FileSystemContext(
61 base::SequencedTaskRunner* file_task_runner, 57 scoped_ptr<FileSystemTaskRunners> task_runners,
62 base::SingleThreadTaskRunner* io_task_runner,
63 quota::SpecialStoragePolicy* special_storage_policy, 58 quota::SpecialStoragePolicy* special_storage_policy,
64 quota::QuotaManagerProxy* quota_manager_proxy, 59 quota::QuotaManagerProxy* quota_manager_proxy,
65 const FilePath& profile_path, 60 const FilePath& profile_path,
66 const FileSystemOptions& options); 61 const FileSystemOptions& options);
67 62
68 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); 63 bool DeleteDataForOriginOnFileThread(const GURL& origin_url);
69 64
70 quota::QuotaManagerProxy* quota_manager_proxy() const { 65 quota::QuotaManagerProxy* quota_manager_proxy() const {
71 return quota_manager_proxy_.get(); 66 return quota_manager_proxy_.get();
72 } 67 }
73 68
74 base::SequencedTaskRunner* file_task_runner() const {
75 return file_task_runner_.get();
76 }
77
78 // Returns a quota util for a given filesystem type. This may 69 // Returns a quota util for a given filesystem type. This may
79 // return NULL if the type does not support the usage tracking or 70 // return NULL if the type does not support the usage tracking or
80 // it is not a quota-managed storage. 71 // it is not a quota-managed storage.
81 FileSystemQuotaUtil* GetQuotaUtil(FileSystemType type) const; 72 FileSystemQuotaUtil* GetQuotaUtil(FileSystemType type) const;
82 73
83 // Returns the appropriate FileUtil instance for the given |type|. 74 // Returns the appropriate FileUtil instance for the given |type|.
84 // This may return NULL if it is given an invalid or unsupported filesystem 75 // This may return NULL if it is given an invalid or unsupported filesystem
85 // type. 76 // type.
86 FileSystemFileUtil* GetFileUtil(FileSystemType type) const; 77 FileSystemFileUtil* GetFileUtil(FileSystemType type) const;
87 78
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // depending on the filesystem type pointed by the |url|. 134 // depending on the filesystem type pointed by the |url|.
144 webkit_blob::FileStreamReader* CreateFileStreamReader( 135 webkit_blob::FileStreamReader* CreateFileStreamReader(
145 const FileSystemURL& url, 136 const FileSystemURL& url,
146 int64 offset); 137 int64 offset);
147 138
148 // Register a filesystem provider. The ownership of |provider| is 139 // Register a filesystem provider. The ownership of |provider| is
149 // transferred to this instance. 140 // transferred to this instance.
150 void RegisterMountPointProvider(FileSystemType type, 141 void RegisterMountPointProvider(FileSystemType type,
151 FileSystemMountPointProvider* provider); 142 FileSystemMountPointProvider* provider);
152 143
144 FileSystemTaskRunners* task_runners() { return task_runners_.get(); }
145
153 private: 146 private:
154 friend struct DefaultContextDeleter; 147 friend struct DefaultContextDeleter;
155 friend class base::DeleteHelper<FileSystemContext>; 148 friend class base::DeleteHelper<FileSystemContext>;
156 friend class base::RefCountedThreadSafe<FileSystemContext, 149 friend class base::RefCountedThreadSafe<FileSystemContext,
157 DefaultContextDeleter>; 150 DefaultContextDeleter>;
158 ~FileSystemContext(); 151 ~FileSystemContext();
159 152
160 void DeleteOnCorrectThread() const; 153 void DeleteOnCorrectThread() const;
161 154
162 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 155 scoped_ptr<FileSystemTaskRunners> task_runners_;
163 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
164 156
165 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 157 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
166 158
167 // Regular mount point providers. 159 // Regular mount point providers.
168 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; 160 scoped_ptr<SandboxMountPointProvider> sandbox_provider_;
169 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; 161 scoped_ptr<IsolatedMountPointProvider> isolated_provider_;
170 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; 162 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_;
171 163
172 // Registered mount point providers. 164 // Registered mount point providers.
173 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_; 165 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_;
174 166
175 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); 167 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext);
176 }; 168 };
177 169
178 struct DefaultContextDeleter { 170 struct DefaultContextDeleter {
179 static void Destruct(const FileSystemContext* context) { 171 static void Destruct(const FileSystemContext* context) {
180 context->DeleteOnCorrectThread(); 172 context->DeleteOnCorrectThread();
181 } 173 }
182 }; 174 };
183 175
184 } // namespace fileapi 176 } // namespace fileapi
185 177
186 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 178 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698