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

Side by Side Diff: content/child/fileapi/webfilesystem_impl.cc

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/child/fileapi/webfilesystem_impl.h" 5 #include "content/child/fileapi/webfilesystem_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <tuple>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread_local.h" 16 #include "base/threading/thread_local.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "content/child/child_thread_impl.h" 18 #include "content/child/child_thread_impl.h"
18 #include "content/child/file_info_util.h" 19 #include "content/child/file_info_util.h"
19 #include "content/child/fileapi/file_system_dispatcher.h" 20 #include "content/child/fileapi/file_system_dispatcher.h"
20 #include "content/child/fileapi/webfilewriter_impl.h" 21 #include "content/child/fileapi/webfilewriter_impl.h"
21 #include "content/common/fileapi/file_system_messages.h" 22 #include "content/common/fileapi/file_system_messages.h"
22 #include "storage/common/fileapi/directory_entry.h" 23 #include "storage/common/fileapi/directory_entry.h"
23 #include "storage/common/fileapi/file_system_util.h" 24 #include "storage/common/fileapi/file_system_util.h"
24 #include "third_party/WebKit/public/platform/WebFileInfo.h" 25 #include "third_party/WebKit/public/platform/WebFileInfo.h"
25 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" 26 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h"
26 #include "third_party/WebKit/public/platform/WebString.h" 27 #include "third_party/WebKit/public/platform/WebString.h"
27 #include "third_party/WebKit/public/platform/WebURL.h" 28 #include "third_party/WebKit/public/platform/WebURL.h"
28 #include "third_party/WebKit/public/web/WebHeap.h" 29 #include "third_party/WebKit/public/web/WebHeap.h"
29 #include "url/gurl.h" 30 #include "url/gurl.h"
30 31
31 using base::MakeTuple;
32 using blink::WebFileInfo; 32 using blink::WebFileInfo;
33 using blink::WebFileSystemCallbacks; 33 using blink::WebFileSystemCallbacks;
34 using blink::WebFileSystemEntry; 34 using blink::WebFileSystemEntry;
35 using blink::WebString; 35 using blink::WebString;
36 using blink::WebURL; 36 using blink::WebURL;
37 using blink::WebVector; 37 using blink::WebVector;
38 38
39 namespace content { 39 namespace content {
40 40
41 class WebFileSystemImpl::WaitableCallbackResults 41 class WebFileSystemImpl::WaitableCallbackResults
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 void WebFileSystemImpl::openFileSystem( 413 void WebFileSystemImpl::openFileSystem(
414 const blink::WebURL& storage_partition, 414 const blink::WebURL& storage_partition,
415 blink::WebFileSystemType type, 415 blink::WebFileSystemType type,
416 WebFileSystemCallbacks callbacks) { 416 WebFileSystemCallbacks callbacks) {
417 int callbacks_id = RegisterCallbacks(callbacks); 417 int callbacks_id = RegisterCallbacks(callbacks);
418 scoped_refptr<WaitableCallbackResults> waitable_results = 418 scoped_refptr<WaitableCallbackResults> waitable_results =
419 MaybeCreateWaitableResults(callbacks, callbacks_id); 419 MaybeCreateWaitableResults(callbacks, callbacks_id);
420 CallDispatcherOnMainThread( 420 CallDispatcherOnMainThread(
421 main_thread_task_runner_, &FileSystemDispatcher::OpenFileSystem, 421 main_thread_task_runner_, &FileSystemDispatcher::OpenFileSystem,
422 MakeTuple(GURL(storage_partition), 422 std::make_tuple(
423 static_cast<storage::FileSystemType>(type), 423 GURL(storage_partition), static_cast<storage::FileSystemType>(type),
424 base::Bind(&OpenFileSystemCallbackAdapter, 424 base::Bind(&OpenFileSystemCallbackAdapter,
425 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 425 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
426 base::RetainedRef(waitable_results)), 426 base::RetainedRef(waitable_results)),
427 base::Bind(&StatusCallbackAdapter, 427 base::Bind(&StatusCallbackAdapter,
428 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 428 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
429 base::RetainedRef(waitable_results))), 429 base::RetainedRef(waitable_results))),
430 waitable_results.get()); 430 waitable_results.get());
431 } 431 }
432 432
433 void WebFileSystemImpl::resolveURL( 433 void WebFileSystemImpl::resolveURL(
434 const blink::WebURL& filesystem_url, 434 const blink::WebURL& filesystem_url,
435 WebFileSystemCallbacks callbacks) { 435 WebFileSystemCallbacks callbacks) {
436 int callbacks_id = RegisterCallbacks(callbacks); 436 int callbacks_id = RegisterCallbacks(callbacks);
437 scoped_refptr<WaitableCallbackResults> waitable_results = 437 scoped_refptr<WaitableCallbackResults> waitable_results =
438 MaybeCreateWaitableResults(callbacks, callbacks_id); 438 MaybeCreateWaitableResults(callbacks, callbacks_id);
439 CallDispatcherOnMainThread( 439 CallDispatcherOnMainThread(
440 main_thread_task_runner_, &FileSystemDispatcher::ResolveURL, 440 main_thread_task_runner_, &FileSystemDispatcher::ResolveURL,
441 MakeTuple(GURL(filesystem_url), 441 std::make_tuple(
442 base::Bind(&ResolveURLCallbackAdapter, 442 GURL(filesystem_url),
443 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 443 base::Bind(&ResolveURLCallbackAdapter,
444 base::RetainedRef(waitable_results)), 444 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
445 base::Bind(&StatusCallbackAdapter, 445 base::RetainedRef(waitable_results)),
446 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 446 base::Bind(&StatusCallbackAdapter,
447 base::RetainedRef(waitable_results))), 447 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
448 base::RetainedRef(waitable_results))),
448 waitable_results.get()); 449 waitable_results.get());
449 } 450 }
450 451
451 void WebFileSystemImpl::deleteFileSystem( 452 void WebFileSystemImpl::deleteFileSystem(
452 const blink::WebURL& storage_partition, 453 const blink::WebURL& storage_partition,
453 blink::WebFileSystemType type, 454 blink::WebFileSystemType type,
454 WebFileSystemCallbacks callbacks) { 455 WebFileSystemCallbacks callbacks) {
455 int callbacks_id = RegisterCallbacks(callbacks); 456 int callbacks_id = RegisterCallbacks(callbacks);
456 scoped_refptr<WaitableCallbackResults> waitable_results = 457 scoped_refptr<WaitableCallbackResults> waitable_results =
457 MaybeCreateWaitableResults(callbacks, callbacks_id); 458 MaybeCreateWaitableResults(callbacks, callbacks_id);
458 CallDispatcherOnMainThread( 459 CallDispatcherOnMainThread(
459 main_thread_task_runner_, &FileSystemDispatcher::DeleteFileSystem, 460 main_thread_task_runner_, &FileSystemDispatcher::DeleteFileSystem,
460 MakeTuple(GURL(storage_partition), 461 std::make_tuple(
461 static_cast<storage::FileSystemType>(type), 462 GURL(storage_partition), static_cast<storage::FileSystemType>(type),
462 base::Bind(&StatusCallbackAdapter, 463 base::Bind(&StatusCallbackAdapter,
463 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 464 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
464 base::RetainedRef(waitable_results))), 465 base::RetainedRef(waitable_results))),
465 waitable_results.get()); 466 waitable_results.get());
466 } 467 }
467 468
468 void WebFileSystemImpl::move( 469 void WebFileSystemImpl::move(
469 const blink::WebURL& src_path, 470 const blink::WebURL& src_path,
470 const blink::WebURL& dest_path, 471 const blink::WebURL& dest_path,
471 WebFileSystemCallbacks callbacks) { 472 WebFileSystemCallbacks callbacks) {
472 int callbacks_id = RegisterCallbacks(callbacks); 473 int callbacks_id = RegisterCallbacks(callbacks);
473 scoped_refptr<WaitableCallbackResults> waitable_results = 474 scoped_refptr<WaitableCallbackResults> waitable_results =
474 MaybeCreateWaitableResults(callbacks, callbacks_id); 475 MaybeCreateWaitableResults(callbacks, callbacks_id);
475 CallDispatcherOnMainThread( 476 CallDispatcherOnMainThread(
476 main_thread_task_runner_, &FileSystemDispatcher::Move, 477 main_thread_task_runner_, &FileSystemDispatcher::Move,
477 MakeTuple(GURL(src_path), GURL(dest_path), 478 std::make_tuple(
478 base::Bind(&StatusCallbackAdapter, 479 GURL(src_path), GURL(dest_path),
479 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 480 base::Bind(&StatusCallbackAdapter,
480 base::RetainedRef(waitable_results))), 481 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
482 base::RetainedRef(waitable_results))),
481 waitable_results.get()); 483 waitable_results.get());
482 } 484 }
483 485
484 void WebFileSystemImpl::copy( 486 void WebFileSystemImpl::copy(
485 const blink::WebURL& src_path, 487 const blink::WebURL& src_path,
486 const blink::WebURL& dest_path, 488 const blink::WebURL& dest_path,
487 WebFileSystemCallbacks callbacks) { 489 WebFileSystemCallbacks callbacks) {
488 int callbacks_id = RegisterCallbacks(callbacks); 490 int callbacks_id = RegisterCallbacks(callbacks);
489 scoped_refptr<WaitableCallbackResults> waitable_results = 491 scoped_refptr<WaitableCallbackResults> waitable_results =
490 MaybeCreateWaitableResults(callbacks, callbacks_id); 492 MaybeCreateWaitableResults(callbacks, callbacks_id);
491 CallDispatcherOnMainThread( 493 CallDispatcherOnMainThread(
492 main_thread_task_runner_, &FileSystemDispatcher::Copy, 494 main_thread_task_runner_, &FileSystemDispatcher::Copy,
493 MakeTuple(GURL(src_path), GURL(dest_path), 495 std::make_tuple(
494 base::Bind(&StatusCallbackAdapter, 496 GURL(src_path), GURL(dest_path),
495 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 497 base::Bind(&StatusCallbackAdapter,
496 base::RetainedRef(waitable_results))), 498 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
499 base::RetainedRef(waitable_results))),
497 waitable_results.get()); 500 waitable_results.get());
498 } 501 }
499 502
500 void WebFileSystemImpl::remove( 503 void WebFileSystemImpl::remove(
501 const blink::WebURL& path, 504 const blink::WebURL& path,
502 WebFileSystemCallbacks callbacks) { 505 WebFileSystemCallbacks callbacks) {
503 int callbacks_id = RegisterCallbacks(callbacks); 506 int callbacks_id = RegisterCallbacks(callbacks);
504 scoped_refptr<WaitableCallbackResults> waitable_results = 507 scoped_refptr<WaitableCallbackResults> waitable_results =
505 MaybeCreateWaitableResults(callbacks, callbacks_id); 508 MaybeCreateWaitableResults(callbacks, callbacks_id);
506 CallDispatcherOnMainThread( 509 CallDispatcherOnMainThread(
507 main_thread_task_runner_, &FileSystemDispatcher::Remove, 510 main_thread_task_runner_, &FileSystemDispatcher::Remove,
508 MakeTuple(GURL(path), false /* recursive */, 511 std::make_tuple(
509 base::Bind(&StatusCallbackAdapter, 512 GURL(path), false /* recursive */,
510 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 513 base::Bind(&StatusCallbackAdapter,
511 base::RetainedRef(waitable_results))), 514 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
515 base::RetainedRef(waitable_results))),
512 waitable_results.get()); 516 waitable_results.get());
513 } 517 }
514 518
515 void WebFileSystemImpl::removeRecursively( 519 void WebFileSystemImpl::removeRecursively(
516 const blink::WebURL& path, 520 const blink::WebURL& path,
517 WebFileSystemCallbacks callbacks) { 521 WebFileSystemCallbacks callbacks) {
518 int callbacks_id = RegisterCallbacks(callbacks); 522 int callbacks_id = RegisterCallbacks(callbacks);
519 scoped_refptr<WaitableCallbackResults> waitable_results = 523 scoped_refptr<WaitableCallbackResults> waitable_results =
520 MaybeCreateWaitableResults(callbacks, callbacks_id); 524 MaybeCreateWaitableResults(callbacks, callbacks_id);
521 CallDispatcherOnMainThread( 525 CallDispatcherOnMainThread(
522 main_thread_task_runner_, &FileSystemDispatcher::Remove, 526 main_thread_task_runner_, &FileSystemDispatcher::Remove,
523 MakeTuple(GURL(path), true /* recursive */, 527 std::make_tuple(
524 base::Bind(&StatusCallbackAdapter, 528 GURL(path), true /* recursive */,
525 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 529 base::Bind(&StatusCallbackAdapter,
526 base::RetainedRef(waitable_results))), 530 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
531 base::RetainedRef(waitable_results))),
527 waitable_results.get()); 532 waitable_results.get());
528 } 533 }
529 534
530 void WebFileSystemImpl::readMetadata( 535 void WebFileSystemImpl::readMetadata(
531 const blink::WebURL& path, 536 const blink::WebURL& path,
532 WebFileSystemCallbacks callbacks) { 537 WebFileSystemCallbacks callbacks) {
533 int callbacks_id = RegisterCallbacks(callbacks); 538 int callbacks_id = RegisterCallbacks(callbacks);
534 scoped_refptr<WaitableCallbackResults> waitable_results = 539 scoped_refptr<WaitableCallbackResults> waitable_results =
535 MaybeCreateWaitableResults(callbacks, callbacks_id); 540 MaybeCreateWaitableResults(callbacks, callbacks_id);
536 CallDispatcherOnMainThread( 541 CallDispatcherOnMainThread(
537 main_thread_task_runner_, &FileSystemDispatcher::ReadMetadata, 542 main_thread_task_runner_, &FileSystemDispatcher::ReadMetadata,
538 MakeTuple(GURL(path), 543 std::make_tuple(
539 base::Bind(&ReadMetadataCallbackAdapter, 544 GURL(path),
540 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 545 base::Bind(&ReadMetadataCallbackAdapter,
541 base::RetainedRef(waitable_results)), 546 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
542 base::Bind(&StatusCallbackAdapter, 547 base::RetainedRef(waitable_results)),
543 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 548 base::Bind(&StatusCallbackAdapter,
544 base::RetainedRef(waitable_results))), 549 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
550 base::RetainedRef(waitable_results))),
545 waitable_results.get()); 551 waitable_results.get());
546 } 552 }
547 553
548 void WebFileSystemImpl::createFile( 554 void WebFileSystemImpl::createFile(
549 const blink::WebURL& path, 555 const blink::WebURL& path,
550 bool exclusive, 556 bool exclusive,
551 WebFileSystemCallbacks callbacks) { 557 WebFileSystemCallbacks callbacks) {
552 int callbacks_id = RegisterCallbacks(callbacks); 558 int callbacks_id = RegisterCallbacks(callbacks);
553 scoped_refptr<WaitableCallbackResults> waitable_results = 559 scoped_refptr<WaitableCallbackResults> waitable_results =
554 MaybeCreateWaitableResults(callbacks, callbacks_id); 560 MaybeCreateWaitableResults(callbacks, callbacks_id);
555 CallDispatcherOnMainThread( 561 CallDispatcherOnMainThread(
556 main_thread_task_runner_, &FileSystemDispatcher::CreateFile, 562 main_thread_task_runner_, &FileSystemDispatcher::CreateFile,
557 MakeTuple(GURL(path), exclusive, 563 std::make_tuple(
558 base::Bind(&StatusCallbackAdapter, 564 GURL(path), exclusive,
559 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 565 base::Bind(&StatusCallbackAdapter,
560 base::RetainedRef(waitable_results))), 566 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
567 base::RetainedRef(waitable_results))),
561 waitable_results.get()); 568 waitable_results.get());
562 } 569 }
563 570
564 void WebFileSystemImpl::createDirectory( 571 void WebFileSystemImpl::createDirectory(
565 const blink::WebURL& path, 572 const blink::WebURL& path,
566 bool exclusive, 573 bool exclusive,
567 WebFileSystemCallbacks callbacks) { 574 WebFileSystemCallbacks callbacks) {
568 int callbacks_id = RegisterCallbacks(callbacks); 575 int callbacks_id = RegisterCallbacks(callbacks);
569 scoped_refptr<WaitableCallbackResults> waitable_results = 576 scoped_refptr<WaitableCallbackResults> waitable_results =
570 MaybeCreateWaitableResults(callbacks, callbacks_id); 577 MaybeCreateWaitableResults(callbacks, callbacks_id);
571 CallDispatcherOnMainThread( 578 CallDispatcherOnMainThread(
572 main_thread_task_runner_, &FileSystemDispatcher::CreateDirectory, 579 main_thread_task_runner_, &FileSystemDispatcher::CreateDirectory,
573 MakeTuple(GURL(path), exclusive, false /* recursive */, 580 std::make_tuple(
574 base::Bind(&StatusCallbackAdapter, 581 GURL(path), exclusive, false /* recursive */,
575 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 582 base::Bind(&StatusCallbackAdapter,
576 base::RetainedRef(waitable_results))), 583 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
584 base::RetainedRef(waitable_results))),
577 waitable_results.get()); 585 waitable_results.get());
578 } 586 }
579 587
580 void WebFileSystemImpl::fileExists( 588 void WebFileSystemImpl::fileExists(
581 const blink::WebURL& path, 589 const blink::WebURL& path,
582 WebFileSystemCallbacks callbacks) { 590 WebFileSystemCallbacks callbacks) {
583 int callbacks_id = RegisterCallbacks(callbacks); 591 int callbacks_id = RegisterCallbacks(callbacks);
584 scoped_refptr<WaitableCallbackResults> waitable_results = 592 scoped_refptr<WaitableCallbackResults> waitable_results =
585 MaybeCreateWaitableResults(callbacks, callbacks_id); 593 MaybeCreateWaitableResults(callbacks, callbacks_id);
586 CallDispatcherOnMainThread( 594 CallDispatcherOnMainThread(
587 main_thread_task_runner_, &FileSystemDispatcher::Exists, 595 main_thread_task_runner_, &FileSystemDispatcher::Exists,
588 MakeTuple(GURL(path), false /* directory */, 596 std::make_tuple(
589 base::Bind(&StatusCallbackAdapter, 597 GURL(path), false /* directory */,
590 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 598 base::Bind(&StatusCallbackAdapter,
591 base::RetainedRef(waitable_results))), 599 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
600 base::RetainedRef(waitable_results))),
592 waitable_results.get()); 601 waitable_results.get());
593 } 602 }
594 603
595 void WebFileSystemImpl::directoryExists( 604 void WebFileSystemImpl::directoryExists(
596 const blink::WebURL& path, 605 const blink::WebURL& path,
597 WebFileSystemCallbacks callbacks) { 606 WebFileSystemCallbacks callbacks) {
598 int callbacks_id = RegisterCallbacks(callbacks); 607 int callbacks_id = RegisterCallbacks(callbacks);
599 scoped_refptr<WaitableCallbackResults> waitable_results = 608 scoped_refptr<WaitableCallbackResults> waitable_results =
600 MaybeCreateWaitableResults(callbacks, callbacks_id); 609 MaybeCreateWaitableResults(callbacks, callbacks_id);
601 CallDispatcherOnMainThread( 610 CallDispatcherOnMainThread(
602 main_thread_task_runner_, &FileSystemDispatcher::Exists, 611 main_thread_task_runner_, &FileSystemDispatcher::Exists,
603 MakeTuple(GURL(path), true /* directory */, 612 std::make_tuple(
604 base::Bind(&StatusCallbackAdapter, 613 GURL(path), true /* directory */,
605 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 614 base::Bind(&StatusCallbackAdapter,
606 base::RetainedRef(waitable_results))), 615 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
616 base::RetainedRef(waitable_results))),
607 waitable_results.get()); 617 waitable_results.get());
608 } 618 }
609 619
610 int WebFileSystemImpl::readDirectory( 620 int WebFileSystemImpl::readDirectory(
611 const blink::WebURL& path, 621 const blink::WebURL& path,
612 WebFileSystemCallbacks callbacks) { 622 WebFileSystemCallbacks callbacks) {
613 int callbacks_id = RegisterCallbacks(callbacks); 623 int callbacks_id = RegisterCallbacks(callbacks);
614 scoped_refptr<WaitableCallbackResults> waitable_results = 624 scoped_refptr<WaitableCallbackResults> waitable_results =
615 MaybeCreateWaitableResults(callbacks, callbacks_id); 625 MaybeCreateWaitableResults(callbacks, callbacks_id);
616 CallDispatcherOnMainThread( 626 CallDispatcherOnMainThread(
617 main_thread_task_runner_, &FileSystemDispatcher::ReadDirectory, 627 main_thread_task_runner_, &FileSystemDispatcher::ReadDirectory,
618 MakeTuple(GURL(path), 628 std::make_tuple(
619 base::Bind(&ReadDirectoryCallbackAdapter, 629 GURL(path),
620 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 630 base::Bind(&ReadDirectoryCallbackAdapter,
621 base::RetainedRef(waitable_results)), 631 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
622 base::Bind(&StatusCallbackAdapter, 632 base::RetainedRef(waitable_results)),
623 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 633 base::Bind(&StatusCallbackAdapter,
624 base::RetainedRef(waitable_results))), 634 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
635 base::RetainedRef(waitable_results))),
625 waitable_results.get()); 636 waitable_results.get());
626 return callbacks_id; 637 return callbacks_id;
627 } 638 }
628 639
629 void WebFileSystemImpl::createFileWriter( 640 void WebFileSystemImpl::createFileWriter(
630 const WebURL& path, 641 const WebURL& path,
631 blink::WebFileWriterClient* client, 642 blink::WebFileWriterClient* client,
632 WebFileSystemCallbacks callbacks) { 643 WebFileSystemCallbacks callbacks) {
633 int callbacks_id = RegisterCallbacks(callbacks); 644 int callbacks_id = RegisterCallbacks(callbacks);
634 scoped_refptr<WaitableCallbackResults> waitable_results = 645 scoped_refptr<WaitableCallbackResults> waitable_results =
635 MaybeCreateWaitableResults(callbacks, callbacks_id); 646 MaybeCreateWaitableResults(callbacks, callbacks_id);
636 CallDispatcherOnMainThread( 647 CallDispatcherOnMainThread(
637 main_thread_task_runner_, &FileSystemDispatcher::ReadMetadata, 648 main_thread_task_runner_, &FileSystemDispatcher::ReadMetadata,
638 MakeTuple(GURL(path), 649 std::make_tuple(
639 base::Bind(&CreateFileWriterCallbackAdapter, 650 GURL(path),
640 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 651 base::Bind(&CreateFileWriterCallbackAdapter,
641 base::RetainedRef(waitable_results), 652 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
642 main_thread_task_runner_, GURL(path), client), 653 base::RetainedRef(waitable_results),
643 base::Bind(&StatusCallbackAdapter, 654 main_thread_task_runner_, GURL(path), client),
644 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 655 base::Bind(&StatusCallbackAdapter,
645 base::RetainedRef(waitable_results))), 656 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
657 base::RetainedRef(waitable_results))),
646 waitable_results.get()); 658 waitable_results.get());
647 } 659 }
648 660
649 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( 661 void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
650 const blink::WebURL& path, 662 const blink::WebURL& path,
651 WebFileSystemCallbacks callbacks) { 663 WebFileSystemCallbacks callbacks) {
652 int callbacks_id = RegisterCallbacks(callbacks); 664 int callbacks_id = RegisterCallbacks(callbacks);
653 scoped_refptr<WaitableCallbackResults> waitable_results = 665 scoped_refptr<WaitableCallbackResults> waitable_results =
654 MaybeCreateWaitableResults(callbacks, callbacks_id); 666 MaybeCreateWaitableResults(callbacks, callbacks_id);
655 CallDispatcherOnMainThread( 667 CallDispatcherOnMainThread(
656 main_thread_task_runner_, &FileSystemDispatcher::CreateSnapshotFile, 668 main_thread_task_runner_, &FileSystemDispatcher::CreateSnapshotFile,
657 MakeTuple(GURL(path), 669 std::make_tuple(
658 base::Bind(&CreateSnapshotFileCallbackAdapter, 670 GURL(path),
659 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 671 base::Bind(&CreateSnapshotFileCallbackAdapter,
660 base::RetainedRef(waitable_results), 672 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
661 main_thread_task_runner_), 673 base::RetainedRef(waitable_results),
662 base::Bind(&StatusCallbackAdapter, 674 main_thread_task_runner_),
663 base::ThreadTaskRunnerHandle::Get(), callbacks_id, 675 base::Bind(&StatusCallbackAdapter,
664 base::RetainedRef(waitable_results))), 676 base::ThreadTaskRunnerHandle::Get(), callbacks_id,
677 base::RetainedRef(waitable_results))),
665 waitable_results.get()); 678 waitable_results.get());
666 } 679 }
667 680
668 bool WebFileSystemImpl::waitForAdditionalResult(int callbacksId) { 681 bool WebFileSystemImpl::waitForAdditionalResult(int callbacksId) {
669 WaitableCallbackResultsMap::iterator found = 682 WaitableCallbackResultsMap::iterator found =
670 waitable_results_.find(callbacksId); 683 waitable_results_.find(callbacksId);
671 if (found == waitable_results_.end()) 684 if (found == waitable_results_.end())
672 return false; 685 return false;
673 686
674 found->second->WaitAndRun(); 687 found->second->WaitAndRun();
(...skipping 27 matching lines...) Expand all
702 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults( 715 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults(
703 const WebFileSystemCallbacks& callbacks, int callbacks_id) { 716 const WebFileSystemCallbacks& callbacks, int callbacks_id) {
704 if (!callbacks.shouldBlockUntilCompletion()) 717 if (!callbacks.shouldBlockUntilCompletion())
705 return NULL; 718 return NULL;
706 WaitableCallbackResults* results = new WaitableCallbackResults(); 719 WaitableCallbackResults* results = new WaitableCallbackResults();
707 waitable_results_[callbacks_id] = results; 720 waitable_results_[callbacks_id] = results;
708 return results; 721 return results;
709 } 722 }
710 723
711 } // namespace content 724 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blob_storage/blob_transport_controller_unittest.cc ('k') | content/child/resource_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698