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

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

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 #include "webkit/browser/fileapi/file_system_context.h" 5 #include "webkit/browser/fileapi/file_system_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 #include "webkit/browser/blob/file_stream_reader.h" 12 #include "webkit/browser/blob/file_stream_reader.h"
13 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" 13 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
14 #include "webkit/browser/fileapi/external_mount_points.h" 14 #include "webkit/browser/fileapi/external_mount_points.h"
15 #include "webkit/browser/fileapi/file_permission_policy.h" 15 #include "webkit/browser/fileapi/file_permission_policy.h"
16 #include "webkit/browser/fileapi/file_stream_writer.h" 16 #include "webkit/browser/fileapi/file_stream_writer.h"
17 #include "webkit/browser/fileapi/file_system_file_util.h" 17 #include "webkit/browser/fileapi/file_system_file_util.h"
18 #include "webkit/browser/fileapi/file_system_operation.h" 18 #include "webkit/browser/fileapi/file_system_operation.h"
19 #include "webkit/browser/fileapi/file_system_operation_runner.h" 19 #include "webkit/browser/fileapi/file_system_operation_runner.h"
20 #include "webkit/browser/fileapi/file_system_options.h" 20 #include "webkit/browser/fileapi/file_system_options.h"
21 #include "webkit/browser/fileapi/file_system_quota_client.h" 21 #include "webkit/browser/fileapi/file_system_quota_client.h"
22 #include "webkit/browser/fileapi/file_system_task_runners.h"
23 #include "webkit/browser/fileapi/file_system_url.h" 22 #include "webkit/browser/fileapi/file_system_url.h"
24 #include "webkit/browser/fileapi/isolated_context.h" 23 #include "webkit/browser/fileapi/isolated_context.h"
25 #include "webkit/browser/fileapi/isolated_file_system_backend.h" 24 #include "webkit/browser/fileapi/isolated_file_system_backend.h"
26 #include "webkit/browser/fileapi/mount_points.h" 25 #include "webkit/browser/fileapi/mount_points.h"
27 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" 26 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
28 #include "webkit/browser/fileapi/test_file_system_backend.h" 27 #include "webkit/browser/fileapi/test_file_system_backend.h"
29 #include "webkit/browser/quota/quota_manager.h" 28 #include "webkit/browser/quota/quota_manager.h"
30 #include "webkit/browser/quota/special_storage_policy.h" 29 #include "webkit/browser/quota/special_storage_policy.h"
31 #include "webkit/common/fileapi/file_system_util.h" 30 #include "webkit/common/fileapi/file_system_util.h"
32 31
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 case kFileSystemInternalTypeEnumEnd: 90 case kFileSystemInternalTypeEnumEnd:
92 case kFileSystemInternalTypeEnumStart: 91 case kFileSystemInternalTypeEnumStart:
93 case kFileSystemTypeUnknown: 92 case kFileSystemTypeUnknown:
94 return FILE_PERMISSION_ALWAYS_DENY; 93 return FILE_PERMISSION_ALWAYS_DENY;
95 } 94 }
96 NOTREACHED(); 95 NOTREACHED();
97 return FILE_PERMISSION_ALWAYS_DENY; 96 return FILE_PERMISSION_ALWAYS_DENY;
98 } 97 }
99 98
100 FileSystemContext::FileSystemContext( 99 FileSystemContext::FileSystemContext(
101 scoped_ptr<FileSystemTaskRunners> task_runners, 100 base::SingleThreadTaskRunner* io_task_runner,
101 base::SequencedTaskRunner* file_task_runner,
102 ExternalMountPoints* external_mount_points, 102 ExternalMountPoints* external_mount_points,
103 quota::SpecialStoragePolicy* special_storage_policy, 103 quota::SpecialStoragePolicy* special_storage_policy,
104 quota::QuotaManagerProxy* quota_manager_proxy, 104 quota::QuotaManagerProxy* quota_manager_proxy,
105 ScopedVector<FileSystemBackend> additional_backends, 105 ScopedVector<FileSystemBackend> additional_backends,
106 const base::FilePath& partition_path, 106 const base::FilePath& partition_path,
107 const FileSystemOptions& options) 107 const FileSystemOptions& options)
108 : task_runners_(task_runners.Pass()), 108 : io_task_runner_(io_task_runner),
109 default_file_task_runner_(file_task_runner),
109 quota_manager_proxy_(quota_manager_proxy), 110 quota_manager_proxy_(quota_manager_proxy),
110 sandbox_context_(new SandboxContext( 111 sandbox_context_(new SandboxContext(
111 quota_manager_proxy, 112 quota_manager_proxy,
112 task_runners_->file_task_runner(), 113 file_task_runner,
113 partition_path, 114 partition_path,
114 special_storage_policy, 115 special_storage_policy,
115 options)), 116 options)),
116 sandbox_backend_(new SandboxFileSystemBackend( 117 sandbox_backend_(new SandboxFileSystemBackend(
117 sandbox_context_.get())), 118 sandbox_context_.get())),
118 isolated_backend_(new IsolatedFileSystemBackend()), 119 isolated_backend_(new IsolatedFileSystemBackend()),
119 additional_backends_(additional_backends.Pass()), 120 additional_backends_(additional_backends.Pass()),
120 external_mount_points_(external_mount_points), 121 external_mount_points_(external_mount_points),
121 partition_path_(partition_path), 122 partition_path_(partition_path),
122 operation_runner_(new FileSystemOperationRunner(this)) { 123 operation_runner_(new FileSystemOperationRunner(this)) {
123 DCHECK(task_runners_.get());
124
125 if (quota_manager_proxy) { 124 if (quota_manager_proxy) {
126 quota_manager_proxy->RegisterClient(CreateQuotaClient( 125 quota_manager_proxy->RegisterClient(CreateQuotaClient(
127 this, options.is_incognito())); 126 this, options.is_incognito()));
128 } 127 }
129 128
130 RegisterBackend(sandbox_backend_.get()); 129 RegisterBackend(sandbox_backend_.get());
131 RegisterBackend(isolated_backend_.get()); 130 RegisterBackend(isolated_backend_.get());
132 131
133 for (ScopedVector<FileSystemBackend>::const_iterator iter = 132 for (ScopedVector<FileSystemBackend>::const_iterator iter =
134 additional_backends_.begin(); 133 additional_backends_.begin();
(...skipping 12 matching lines...) Expand all
147 // Additional mount points must be added before regular system-wide 146 // Additional mount points must be added before regular system-wide
148 // mount points. 147 // mount points.
149 if (external_mount_points) 148 if (external_mount_points)
150 url_crackers_.push_back(external_mount_points); 149 url_crackers_.push_back(external_mount_points);
151 url_crackers_.push_back(ExternalMountPoints::GetSystemInstance()); 150 url_crackers_.push_back(ExternalMountPoints::GetSystemInstance());
152 url_crackers_.push_back(IsolatedContext::GetInstance()); 151 url_crackers_.push_back(IsolatedContext::GetInstance());
153 } 152 }
154 153
155 bool FileSystemContext::DeleteDataForOriginOnFileThread( 154 bool FileSystemContext::DeleteDataForOriginOnFileThread(
156 const GURL& origin_url) { 155 const GURL& origin_url) {
157 DCHECK(task_runners_->file_task_runner()->RunsTasksOnCurrentThread()); 156 DCHECK(default_file_task_runner()->RunsTasksOnCurrentThread());
158 DCHECK(origin_url == origin_url.GetOrigin()); 157 DCHECK(origin_url == origin_url.GetOrigin());
159 158
160 bool success = true; 159 bool success = true;
161 for (FileSystemBackendMap::iterator iter = backend_map_.begin(); 160 for (FileSystemBackendMap::iterator iter = backend_map_.begin();
162 iter != backend_map_.end(); 161 iter != backend_map_.end();
163 ++iter) { 162 ++iter) {
164 FileSystemBackend* backend = iter->second; 163 FileSystemBackend* backend = iter->second;
165 if (!backend->GetQuotaUtil()) 164 if (!backend->GetQuotaUtil())
166 continue; 165 continue;
167 if (backend->GetQuotaUtil()->DeleteOriginDataOnFileThread( 166 if (backend->GetQuotaUtil()->DeleteOriginDataOnFileThread(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (!backend) { 279 if (!backend) {
281 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 280 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
282 return; 281 return;
283 } 282 }
284 if (!backend->GetQuotaUtil()) { 283 if (!backend->GetQuotaUtil()) {
285 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 284 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
286 return; 285 return;
287 } 286 }
288 287
289 base::PostTaskAndReplyWithResult( 288 base::PostTaskAndReplyWithResult(
290 task_runners()->file_task_runner(), 289 default_file_task_runner(),
291 FROM_HERE, 290 FROM_HERE,
292 // It is safe to pass Unretained(quota_util) since context owns it. 291 // It is safe to pass Unretained(quota_util) since context owns it.
293 base::Bind(&FileSystemQuotaUtil::DeleteOriginDataOnFileThread, 292 base::Bind(&FileSystemQuotaUtil::DeleteOriginDataOnFileThread,
294 base::Unretained(backend->GetQuotaUtil()), 293 base::Unretained(backend->GetQuotaUtil()),
295 make_scoped_refptr(this), 294 make_scoped_refptr(this),
296 base::Unretained(quota_manager_proxy()), 295 base::Unretained(quota_manager_proxy()),
297 origin_url, 296 origin_url,
298 type), 297 type),
299 callback); 298 callback);
300 } 299 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 #if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) 342 #if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
344 void FileSystemContext::EnableTemporaryFileSystemInIncognito() { 343 void FileSystemContext::EnableTemporaryFileSystemInIncognito() {
345 sandbox_backend_->set_enable_temporary_file_system_in_incognito(true); 344 sandbox_backend_->set_enable_temporary_file_system_in_incognito(true);
346 } 345 }
347 #endif 346 #endif
348 347
349 FileSystemContext::~FileSystemContext() { 348 FileSystemContext::~FileSystemContext() {
350 } 349 }
351 350
352 void FileSystemContext::DeleteOnCorrectThread() const { 351 void FileSystemContext::DeleteOnCorrectThread() const {
353 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() && 352 if (!io_task_runner_->RunsTasksOnCurrentThread() &&
354 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) { 353 io_task_runner_->DeleteSoon(FROM_HERE, this)) {
355 return; 354 return;
356 } 355 }
357 delete this; 356 delete this;
358 } 357 }
359 358
360 FileSystemOperation* FileSystemContext::CreateFileSystemOperation( 359 FileSystemOperation* FileSystemContext::CreateFileSystemOperation(
361 const FileSystemURL& url, base::PlatformFileError* error_code) { 360 const FileSystemURL& url, base::PlatformFileError* error_code) {
362 if (!url.is_valid()) { 361 if (!url.is_valid()) {
363 if (error_code) 362 if (error_code)
364 *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL; 363 *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 FileSystemType type = static_cast<FileSystemType>(t); 429 FileSystemType type = static_cast<FileSystemType>(t);
431 if (backend->CanHandleType(type)) { 430 if (backend->CanHandleType(type)) {
432 const bool inserted = backend_map_.insert( 431 const bool inserted = backend_map_.insert(
433 std::make_pair(type, backend)).second; 432 std::make_pair(type, backend)).second;
434 DCHECK(inserted); 433 DCHECK(inserted);
435 } 434 }
436 } 435 }
437 } 436 }
438 437
439 } // namespace fileapi 438 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_context.h ('k') | webkit/browser/fileapi/file_system_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698