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

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

Issue 242443004: Remove thread restriction of fileapi::FileSystemContext::ResolveURL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 #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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const FileSystemInfo& info, 50 const FileSystemInfo& info,
51 base::File::Error error, 51 base::File::Error error,
52 const base::File::Info& file_info) { 52 const base::File::Info& file_info) {
53 if (error != base::File::FILE_OK) { 53 if (error != base::File::FILE_OK) {
54 callback.Run(error, FileSystemInfo(), base::FilePath(), false); 54 callback.Run(error, FileSystemInfo(), base::FilePath(), false);
55 return; 55 return;
56 } 56 }
57 callback.Run(error, info, path, file_info.is_directory); 57 callback.Run(error, info, path, file_info.is_directory);
58 } 58 }
59 59
60 void RelayResolveURLCallback(
61 scoped_refptr<base::MessageLoopProxy> message_loop,
62 const FileSystemContext::ResolveURLCallback& callback,
63 base::File::Error result,
64 const FileSystemInfo& info,
65 const base::FilePath& file_path,
66 bool is_directory) {
67 message_loop->PostTask(
68 FROM_HERE,
69 base::Bind(callback, result, info, file_path, is_directory));
70 }
71
60 } // namespace 72 } // namespace
61 73
62 // static 74 // static
63 int FileSystemContext::GetPermissionPolicy(FileSystemType type) { 75 int FileSystemContext::GetPermissionPolicy(FileSystemType type) {
64 switch (type) { 76 switch (type) {
65 case kFileSystemTypeTemporary: 77 case kFileSystemTypeTemporary:
66 case kFileSystemTypePersistent: 78 case kFileSystemTypePersistent:
67 case kFileSystemTypeSyncable: 79 case kFileSystemTypeSyncable:
68 return FILE_PERMISSION_SANDBOX; 80 return FILE_PERMISSION_SANDBOX;
69 81
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 327
316 backend->ResolveURL( 328 backend->ResolveURL(
317 CreateCrackedFileSystemURL(origin_url, type, base::FilePath()), 329 CreateCrackedFileSystemURL(origin_url, type, base::FilePath()),
318 mode, 330 mode,
319 callback); 331 callback);
320 } 332 }
321 333
322 void FileSystemContext::ResolveURL( 334 void FileSystemContext::ResolveURL(
323 const FileSystemURL& url, 335 const FileSystemURL& url,
324 const ResolveURLCallback& callback) { 336 const ResolveURLCallback& callback) {
325 // TODO(nhiroki, kinuko): Remove this thread restriction, so it can be called
326 // on either UI or IO thread.
327 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
328 DCHECK(!callback.is_null()); 337 DCHECK(!callback.is_null());
329 338
339 // If not on IO thread, forward before passing the task to the backend.
340 if (!io_task_runner_->RunsTasksOnCurrentThread()) {
341 ResolveURLCallback relay_callback =
342 base::Bind(&RelayResolveURLCallback,
343 base::MessageLoopProxy::current(), callback);
344 io_task_runner_->PostTask(
345 FROM_HERE,
346 base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback));
347 return;
348 }
349
330 FileSystemBackend* backend = GetFileSystemBackend(url.type()); 350 FileSystemBackend* backend = GetFileSystemBackend(url.type());
331 if (!backend) { 351 if (!backend) {
332 callback.Run(base::File::FILE_ERROR_SECURITY, 352 callback.Run(base::File::FILE_ERROR_SECURITY,
333 FileSystemInfo(), base::FilePath(), false); 353 FileSystemInfo(), base::FilePath(), false);
334 return; 354 return;
335 } 355 }
336 356
337 backend->ResolveURL( 357 backend->ResolveURL(
338 url, 358 url,
339 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, 359 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } else if (parent != child) { 597 } else if (parent != child) {
578 bool result = parent.AppendRelativePath(child, &path); 598 bool result = parent.AppendRelativePath(child, &path);
579 DCHECK(result); 599 DCHECK(result);
580 } 600 }
581 601
582 operation_runner()->GetMetadata( 602 operation_runner()->GetMetadata(
583 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); 603 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info));
584 } 604 }
585 605
586 } // namespace fileapi 606 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698