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

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

Issue 23856002: SyncFS: Support resolveLocalFileSystemURL on SyncFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 FileSystemBackend* backend = GetFileSystemBackend(type); 265 FileSystemBackend* backend = GetFileSystemBackend(type);
266 if (!backend) { 266 if (!backend) {
267 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); 267 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL());
268 return; 268 return;
269 } 269 }
270 270
271 backend->OpenFileSystem(origin_url, type, mode, 271 backend->OpenFileSystem(origin_url, type, mode,
272 base::Bind(&DidOpenFileSystem, callback)); 272 base::Bind(&DidOpenFileSystem, callback));
273 } 273 }
274 274
275 void FileSystemContext::ResolveURL(
276 const GURL& filesystem_url,
277 const ResolveURLCallback& callback) {
278 DCHECK(!callback.is_null());
279
280 FileSystemURL url = CrackURL(GURL(filesystem_url));
tzik 2013/09/05 09:30:26 extra GURL()?
nhiroki 2013/09/09 09:51:05 Done.
281 if (!url.is_valid()) {
282 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
283 std::string(), GURL(), base::FilePath(), false);
284 return;
285 }
286
287 FileSystemBackend* backend = GetFileSystemBackend(url.type());
288 if (!backend) {
289 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
290 std::string(), GURL(), base::FilePath(), false);
291 return;
292 }
293
294 backend->OpenFileSystem(
295 url.origin(), url.type(),
296 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
297 base::Bind(&FileSystemContext::DidOpenFileSystemForResolveURL,
298 this, url, callback));
299 }
300
275 void FileSystemContext::DeleteFileSystem( 301 void FileSystemContext::DeleteFileSystem(
276 const GURL& origin_url, 302 const GURL& origin_url,
277 FileSystemType type, 303 FileSystemType type,
278 const DeleteFileSystemCallback& callback) { 304 const DeleteFileSystemCallback& callback) {
279 DCHECK(origin_url == origin_url.GetOrigin()); 305 DCHECK(origin_url == origin_url.GetOrigin());
280 FileSystemBackend* backend = GetFileSystemBackend(type); 306 FileSystemBackend* backend = GetFileSystemBackend(type);
281 if (!backend) { 307 if (!backend) {
282 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 308 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
283 return; 309 return;
284 } 310 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 t < kFileSystemInternalTypeEnumEnd; ++t) { 456 t < kFileSystemInternalTypeEnumEnd; ++t) {
431 FileSystemType type = static_cast<FileSystemType>(t); 457 FileSystemType type = static_cast<FileSystemType>(t);
432 if (backend->CanHandleType(type)) { 458 if (backend->CanHandleType(type)) {
433 const bool inserted = backend_map_.insert( 459 const bool inserted = backend_map_.insert(
434 std::make_pair(type, backend)).second; 460 std::make_pair(type, backend)).second;
435 DCHECK(inserted); 461 DCHECK(inserted);
436 } 462 }
437 } 463 }
438 } 464 }
439 465
466 void FileSystemContext::DidOpenFileSystemForResolveURL(
467 const FileSystemURL& url,
468 const FileSystemContext::ResolveURLCallback& callback,
469 const GURL& filesystem_root,
470 const std::string& filesystem_name,
471 base::PlatformFileError error) {
472 if (error != base::PLATFORM_FILE_OK) {
473 callback.Run(error, std::string(), GURL(), base::FilePath(), false);
474 return;
475 }
476 operation_runner()->GetMetadata(
477 url,
478 base::Bind(&FileSystemContext::DidGetMetadataForResolveURL,
479 this, url, callback, filesystem_root, filesystem_name));
480 }
481
482 void FileSystemContext::DidGetMetadataForResolveURL(
483 const FileSystemURL& url,
484 const FileSystemContext::ResolveURLCallback& callback,
485 const GURL& filesystem_root,
486 const std::string& filesystem_name,
487 base::PlatformFileError error,
488 const base::PlatformFileInfo& file_info) {
489 if (error != base::PLATFORM_FILE_OK) {
490 callback.Run(error, std::string(), GURL(), base::FilePath(), false);
491 return;
492 }
493 callback.Run(error, filesystem_name, filesystem_root, url.path(),
494 file_info.is_directory);
495 }
496
440 } // namespace fileapi 497 } // namespace fileapi
OLDNEW
« content/child/fileapi/webfilesystem_impl.h ('K') | « webkit/browser/fileapi/file_system_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698