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

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

Issue 10197007: Change webkit/{fileapi,quota} code to use TaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 7 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
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_dir_url_request_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/fileapi/file_system_context.h" 5 #include "webkit/fileapi/file_system_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/single_thread_task_runner.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "webkit/fileapi/file_system_file_util.h" 11 #include "webkit/fileapi/file_system_file_util.h"
12 #include "webkit/fileapi/file_system_operation_interface.h" 12 #include "webkit/fileapi/file_system_operation_interface.h"
13 #include "webkit/fileapi/file_system_options.h" 13 #include "webkit/fileapi/file_system_options.h"
14 #include "webkit/fileapi/file_system_quota_client.h" 14 #include "webkit/fileapi/file_system_quota_client.h"
15 #include "webkit/fileapi/file_system_util.h" 15 #include "webkit/fileapi/file_system_util.h"
16 #include "webkit/fileapi/isolated_mount_point_provider.h" 16 #include "webkit/fileapi/isolated_mount_point_provider.h"
17 #include "webkit/fileapi/sandbox_mount_point_provider.h" 17 #include "webkit/fileapi/sandbox_mount_point_provider.h"
18 #include "webkit/quota/quota_manager.h" 18 #include "webkit/quota/quota_manager.h"
19 #include "webkit/quota/special_storage_policy.h" 19 #include "webkit/quota/special_storage_policy.h"
20 20
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" 22 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
23 #endif 23 #endif
24 24
25 using quota::QuotaClient; 25 using quota::QuotaClient;
26 26
27 namespace fileapi { 27 namespace fileapi {
28 28
29 namespace { 29 namespace {
30 30
31 QuotaClient* CreateQuotaClient( 31 QuotaClient* CreateQuotaClient(
32 scoped_refptr<base::MessageLoopProxy> file_message_loop,
33 FileSystemContext* context, 32 FileSystemContext* context,
34 bool is_incognito) { 33 bool is_incognito) {
35 return new FileSystemQuotaClient(file_message_loop, context, is_incognito); 34 return new FileSystemQuotaClient(context, is_incognito);
36 } 35 }
37 36
38 void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback, 37 void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback,
39 const GURL& filesystem_root, 38 const GURL& filesystem_root,
40 const std::string& filesystem_name, 39 const std::string& filesystem_name,
41 base::PlatformFileError error) { 40 base::PlatformFileError error) {
42 callback.Run(error, filesystem_name, filesystem_root); 41 callback.Run(error, filesystem_name, filesystem_root);
43 } 42 }
44 43
45 } // anonymous namespace 44 } // anonymous namespace
46 45
47 FileSystemContext::FileSystemContext( 46 FileSystemContext::FileSystemContext(
48 scoped_refptr<base::MessageLoopProxy> file_message_loop, 47 base::SequencedTaskRunner* file_task_runner,
49 scoped_refptr<base::MessageLoopProxy> io_message_loop, 48 base::SingleThreadTaskRunner* io_task_runner,
50 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 49 quota::SpecialStoragePolicy* special_storage_policy,
51 quota::QuotaManagerProxy* quota_manager_proxy, 50 quota::QuotaManagerProxy* quota_manager_proxy,
52 const FilePath& profile_path, 51 const FilePath& profile_path,
53 const FileSystemOptions& options) 52 const FileSystemOptions& options)
54 : file_message_loop_(file_message_loop), 53 : file_task_runner_(file_task_runner),
55 io_message_loop_(io_message_loop), 54 io_task_runner_(io_task_runner),
56 quota_manager_proxy_(quota_manager_proxy), 55 quota_manager_proxy_(quota_manager_proxy),
57 sandbox_provider_( 56 sandbox_provider_(
58 new SandboxMountPointProvider( 57 new SandboxMountPointProvider(
59 file_message_loop, 58 file_task_runner,
60 profile_path, 59 profile_path,
61 options)), 60 options)),
62 isolated_provider_(new IsolatedMountPointProvider) { 61 isolated_provider_(new IsolatedMountPointProvider) {
63 if (quota_manager_proxy) { 62 if (quota_manager_proxy) {
64 quota_manager_proxy->RegisterClient(CreateQuotaClient( 63 quota_manager_proxy->RegisterClient(CreateQuotaClient(
65 file_message_loop, this, options.is_incognito())); 64 this, options.is_incognito()));
66 } 65 }
67 #if defined(OS_CHROMEOS) 66 #if defined(OS_CHROMEOS)
68 external_provider_.reset( 67 external_provider_.reset(
69 new chromeos::CrosMountPointProvider(special_storage_policy)); 68 new chromeos::CrosMountPointProvider(special_storage_policy));
70 #endif 69 #endif
71 } 70 }
72 71
73 bool FileSystemContext::DeleteDataForOriginOnFileThread( 72 bool FileSystemContext::DeleteDataForOriginOnFileThread(
74 const GURL& origin_url) { 73 const GURL& origin_url) {
75 DCHECK(file_message_loop_->BelongsToCurrentThread()); 74 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
76 DCHECK(sandbox_provider()); 75 DCHECK(sandbox_provider());
77 76
78 // Delete temporary and persistent data. 77 // Delete temporary and persistent data.
79 return 78 return
80 sandbox_provider()->DeleteOriginDataOnFileThread( 79 sandbox_provider()->DeleteOriginDataOnFileThread(
81 quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) && 80 quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) &&
82 sandbox_provider()->DeleteOriginDataOnFileThread( 81 sandbox_provider()->DeleteOriginDataOnFileThread(
83 quota_manager_proxy(), origin_url, kFileSystemTypePersistent); 82 quota_manager_proxy(), origin_url, kFileSystemTypePersistent);
84 } 83 }
85 84
86 bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( 85 bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread(
87 const GURL& origin_url, FileSystemType type) { 86 const GURL& origin_url, FileSystemType type) {
88 DCHECK(file_message_loop_->BelongsToCurrentThread()); 87 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
89 if (type == fileapi::kFileSystemTypeTemporary || 88 if (type == fileapi::kFileSystemTypeTemporary ||
90 type == fileapi::kFileSystemTypePersistent) { 89 type == fileapi::kFileSystemTypePersistent) {
91 DCHECK(sandbox_provider()); 90 DCHECK(sandbox_provider());
92 return sandbox_provider()->DeleteOriginDataOnFileThread( 91 return sandbox_provider()->DeleteOriginDataOnFileThread(
93 quota_manager_proxy(), origin_url, type); 92 quota_manager_proxy(), origin_url, type);
94 } 93 }
95 return false; 94 return false;
96 } 95 }
97 96
98 FileSystemQuotaUtil* 97 FileSystemQuotaUtil*
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 156
158 GURL root_url = GetFileSystemRootURI(origin_url, type); 157 GURL root_url = GetFileSystemRootURI(origin_url, type);
159 std::string name = GetFileSystemName(origin_url, type); 158 std::string name = GetFileSystemName(origin_url, type);
160 159
161 mount_point_provider->ValidateFileSystemRoot( 160 mount_point_provider->ValidateFileSystemRoot(
162 origin_url, type, create, 161 origin_url, type, create,
163 base::Bind(&DidOpenFileSystem, callback, root_url, name)); 162 base::Bind(&DidOpenFileSystem, callback, root_url, name));
164 } 163 }
165 164
166 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( 165 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation(
167 const GURL& url, 166 const GURL& url) {
168 base::MessageLoopProxy* file_proxy) {
169 GURL origin_url; 167 GURL origin_url;
170 FileSystemType file_system_type = kFileSystemTypeUnknown; 168 FileSystemType file_system_type = kFileSystemTypeUnknown;
171 FilePath file_path; 169 FilePath file_path;
172 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &file_path)) 170 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &file_path))
173 return NULL; 171 return NULL;
174 FileSystemMountPointProvider* mount_point_provider = 172 FileSystemMountPointProvider* mount_point_provider =
175 GetMountPointProvider(file_system_type); 173 GetMountPointProvider(file_system_type);
176 if (!mount_point_provider) 174 if (!mount_point_provider)
177 return NULL; 175 return NULL;
178 return mount_point_provider->CreateFileSystemOperation( 176 return mount_point_provider->CreateFileSystemOperation(
179 origin_url, file_system_type, file_path, file_proxy, this); 177 origin_url, file_system_type, file_path, this);
180 } 178 }
181 179
182 webkit_blob::FileReader* FileSystemContext::CreateFileReader( 180 webkit_blob::FileReader* FileSystemContext::CreateFileReader(
183 const GURL& url, 181 const GURL& url,
184 int64 offset, 182 int64 offset) {
185 base::MessageLoopProxy* file_proxy) {
186 GURL origin_url; 183 GURL origin_url;
187 FileSystemType file_system_type = kFileSystemTypeUnknown; 184 FileSystemType file_system_type = kFileSystemTypeUnknown;
188 FilePath file_path; 185 FilePath file_path;
189 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &file_path)) 186 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &file_path))
190 return NULL; 187 return NULL;
191 FileSystemMountPointProvider* mount_point_provider = 188 FileSystemMountPointProvider* mount_point_provider =
192 GetMountPointProvider(file_system_type); 189 GetMountPointProvider(file_system_type);
193 if (!mount_point_provider) 190 if (!mount_point_provider)
194 return NULL; 191 return NULL;
195 return mount_point_provider->CreateFileReader(url, offset, file_proxy, this); 192 return mount_point_provider->CreateFileReader(url, offset, this);
196 } 193 }
197 194
198 FileSystemContext::~FileSystemContext() {} 195 FileSystemContext::~FileSystemContext() {}
199 196
200 void FileSystemContext::DeleteOnCorrectThread() const { 197 void FileSystemContext::DeleteOnCorrectThread() const {
201 if (!io_message_loop_->BelongsToCurrentThread() && 198 if (!io_task_runner_->RunsTasksOnCurrentThread() &&
202 io_message_loop_->DeleteSoon(FROM_HERE, this)) { 199 io_task_runner_->DeleteSoon(FROM_HERE, this)) {
203 return; 200 return;
204 } 201 }
205 delete this; 202 delete this;
206 } 203 }
207 204
208 } // namespace fileapi 205 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_dir_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698