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

Side by Side Diff: content/browser/cache_storage/cache_storage_cache.cc

Issue 1132683003: CacheStorage: Merge CacheStorage::CacheStorageError and CacheStorageCache::ErrorType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/cache_storage/cache_storage_cache.h" 5 #include "content/browser/cache_storage/cache_storage_cache.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return weak_ptr_factory_.GetWeakPtr(); 401 return weak_ptr_factory_.GetWeakPtr();
402 } 402 }
403 403
404 void CacheStorageCache::Put(scoped_ptr<ServiceWorkerFetchRequest> request, 404 void CacheStorageCache::Put(scoped_ptr<ServiceWorkerFetchRequest> request,
405 scoped_ptr<ServiceWorkerResponse> response, 405 scoped_ptr<ServiceWorkerResponse> response,
406 const ErrorCallback& callback) { 406 const ErrorCallback& callback) {
407 scoped_ptr<storage::BlobDataHandle> blob_data_handle; 407 scoped_ptr<storage::BlobDataHandle> blob_data_handle;
408 408
409 if (!response->blob_uuid.empty()) { 409 if (!response->blob_uuid.empty()) {
410 if (!blob_storage_context_) { 410 if (!blob_storage_context_) {
411 callback.Run(ERROR_TYPE_STORAGE); 411 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
412 return; 412 return;
413 } 413 }
414 blob_data_handle = 414 blob_data_handle =
415 blob_storage_context_->GetBlobDataFromUUID(response->blob_uuid); 415 blob_storage_context_->GetBlobDataFromUUID(response->blob_uuid);
416 if (!blob_data_handle) { 416 if (!blob_data_handle) {
417 callback.Run(ERROR_TYPE_STORAGE); 417 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
418 return; 418 return;
419 } 419 }
420 } 420 }
421 421
422 ErrorCallback pending_callback = 422 ErrorCallback pending_callback =
423 base::Bind(&CacheStorageCache::PendingErrorCallback, 423 base::Bind(&CacheStorageCache::PendingErrorCallback,
424 weak_ptr_factory_.GetWeakPtr(), callback); 424 weak_ptr_factory_.GetWeakPtr(), callback);
425 425
426 scoped_ptr<PutContext> put_context(new PutContext( 426 scoped_ptr<PutContext> put_context(new PutContext(
427 origin_, request.Pass(), response.Pass(), blob_data_handle.Pass(), 427 origin_, request.Pass(), response.Pass(), blob_data_handle.Pass(),
428 pending_callback, request_context_, quota_manager_proxy_)); 428 pending_callback, request_context_, quota_manager_proxy_));
429 429
430 if (backend_state_ == BACKEND_UNINITIALIZED) 430 if (backend_state_ == BACKEND_UNINITIALIZED)
431 InitBackend(); 431 InitBackend();
432 432
433 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::PutImpl, 433 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::PutImpl,
434 weak_ptr_factory_.GetWeakPtr(), 434 weak_ptr_factory_.GetWeakPtr(),
435 base::Passed(put_context.Pass()))); 435 base::Passed(put_context.Pass())));
436 } 436 }
437 437
438 void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request, 438 void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request,
439 const ResponseCallback& callback) { 439 const ResponseCallback& callback) {
440 switch (backend_state_) { 440 switch (backend_state_) {
441 case BACKEND_UNINITIALIZED: 441 case BACKEND_UNINITIALIZED:
442 InitBackend(); 442 InitBackend();
443 break; 443 break;
444 case BACKEND_CLOSED: 444 case BACKEND_CLOSED:
445 callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), 445 callback.Run(CACHE_STORAGE_ERROR_STORAGE,
446 scoped_ptr<ServiceWorkerResponse>(),
446 scoped_ptr<storage::BlobDataHandle>()); 447 scoped_ptr<storage::BlobDataHandle>());
447 return; 448 return;
448 case BACKEND_OPEN: 449 case BACKEND_OPEN:
449 DCHECK(backend_); 450 DCHECK(backend_);
450 break; 451 break;
451 } 452 }
452 453
453 ResponseCallback pending_callback = 454 ResponseCallback pending_callback =
454 base::Bind(&CacheStorageCache::PendingResponseCallback, 455 base::Bind(&CacheStorageCache::PendingResponseCallback,
455 weak_ptr_factory_.GetWeakPtr(), callback); 456 weak_ptr_factory_.GetWeakPtr(), callback);
456 scheduler_->ScheduleOperation( 457 scheduler_->ScheduleOperation(
457 base::Bind(&CacheStorageCache::MatchImpl, weak_ptr_factory_.GetWeakPtr(), 458 base::Bind(&CacheStorageCache::MatchImpl, weak_ptr_factory_.GetWeakPtr(),
458 base::Passed(request.Pass()), pending_callback)); 459 base::Passed(request.Pass()), pending_callback));
459 } 460 }
460 461
461 void CacheStorageCache::Delete(scoped_ptr<ServiceWorkerFetchRequest> request, 462 void CacheStorageCache::Delete(scoped_ptr<ServiceWorkerFetchRequest> request,
462 const ErrorCallback& callback) { 463 const ErrorCallback& callback) {
463 switch (backend_state_) { 464 switch (backend_state_) {
464 case BACKEND_UNINITIALIZED: 465 case BACKEND_UNINITIALIZED:
465 InitBackend(); 466 InitBackend();
466 break; 467 break;
467 case BACKEND_CLOSED: 468 case BACKEND_CLOSED:
468 callback.Run(ERROR_TYPE_STORAGE); 469 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
469 return; 470 return;
470 case BACKEND_OPEN: 471 case BACKEND_OPEN:
471 DCHECK(backend_); 472 DCHECK(backend_);
472 break; 473 break;
473 } 474 }
474 ErrorCallback pending_callback = 475 ErrorCallback pending_callback =
475 base::Bind(&CacheStorageCache::PendingErrorCallback, 476 base::Bind(&CacheStorageCache::PendingErrorCallback,
476 weak_ptr_factory_.GetWeakPtr(), callback); 477 weak_ptr_factory_.GetWeakPtr(), callback);
477 scheduler_->ScheduleOperation( 478 scheduler_->ScheduleOperation(
478 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(), 479 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(),
479 base::Passed(request.Pass()), pending_callback)); 480 base::Passed(request.Pass()), pending_callback));
480 } 481 }
481 482
482 void CacheStorageCache::Keys(const RequestsCallback& callback) { 483 void CacheStorageCache::Keys(const RequestsCallback& callback) {
483 switch (backend_state_) { 484 switch (backend_state_) {
484 case BACKEND_UNINITIALIZED: 485 case BACKEND_UNINITIALIZED:
485 InitBackend(); 486 InitBackend();
486 break; 487 break;
487 case BACKEND_CLOSED: 488 case BACKEND_CLOSED:
488 callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<Requests>()); 489 callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>());
489 return; 490 return;
490 case BACKEND_OPEN: 491 case BACKEND_OPEN:
491 DCHECK(backend_); 492 DCHECK(backend_);
492 break; 493 break;
493 } 494 }
494 495
495 RequestsCallback pending_callback = 496 RequestsCallback pending_callback =
496 base::Bind(&CacheStorageCache::PendingRequestsCallback, 497 base::Bind(&CacheStorageCache::PendingRequestsCallback,
497 weak_ptr_factory_.GetWeakPtr(), callback); 498 weak_ptr_factory_.GetWeakPtr(), callback);
498 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::KeysImpl, 499 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::KeysImpl,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 scheduler_(new CacheStorageScheduler()), 557 scheduler_(new CacheStorageScheduler()),
557 initializing_(false), 558 initializing_(false),
558 memory_only_(path.empty()), 559 memory_only_(path.empty()),
559 weak_ptr_factory_(this) { 560 weak_ptr_factory_(this) {
560 } 561 }
561 562
562 void CacheStorageCache::MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, 563 void CacheStorageCache::MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request,
563 const ResponseCallback& callback) { 564 const ResponseCallback& callback) {
564 DCHECK(backend_state_ != BACKEND_UNINITIALIZED); 565 DCHECK(backend_state_ != BACKEND_UNINITIALIZED);
565 if (backend_state_ != BACKEND_OPEN) { 566 if (backend_state_ != BACKEND_OPEN) {
566 callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), 567 callback.Run(CACHE_STORAGE_ERROR_STORAGE,
568 scoped_ptr<ServiceWorkerResponse>(),
567 scoped_ptr<storage::BlobDataHandle>()); 569 scoped_ptr<storage::BlobDataHandle>());
568 return; 570 return;
569 } 571 }
570 572
571 scoped_ptr<MatchContext> match_context( 573 scoped_ptr<MatchContext> match_context(
572 new MatchContext(request.Pass(), callback, blob_storage_context_)); 574 new MatchContext(request.Pass(), callback, blob_storage_context_));
573 575
574 disk_cache::Entry** entry_ptr = &match_context->entry; 576 disk_cache::Entry** entry_ptr = &match_context->entry;
575 ServiceWorkerFetchRequest* request_ptr = match_context->request.get(); 577 ServiceWorkerFetchRequest* request_ptr = match_context->request.get();
576 578
577 net::CompletionCallback open_entry_callback = base::Bind( 579 net::CompletionCallback open_entry_callback = base::Bind(
578 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), 580 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(),
579 base::Passed(match_context.Pass())); 581 base::Passed(match_context.Pass()));
580 582
581 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr, 583 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr,
582 open_entry_callback); 584 open_entry_callback);
583 if (rv != net::ERR_IO_PENDING) 585 if (rv != net::ERR_IO_PENDING)
584 open_entry_callback.Run(rv); 586 open_entry_callback.Run(rv);
585 } 587 }
586 588
587 void CacheStorageCache::MatchDidOpenEntry( 589 void CacheStorageCache::MatchDidOpenEntry(
588 scoped_ptr<MatchContext> match_context, 590 scoped_ptr<MatchContext> match_context,
589 int rv) { 591 int rv) {
590 if (rv != net::OK) { 592 if (rv != net::OK) {
591 match_context->original_callback.Run( 593 match_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND,
592 CacheStorageCache::ERROR_TYPE_NOT_FOUND, 594 scoped_ptr<ServiceWorkerResponse>(),
593 scoped_ptr<ServiceWorkerResponse>(), 595 scoped_ptr<storage::BlobDataHandle>());
594 scoped_ptr<storage::BlobDataHandle>());
595 return; 596 return;
596 } 597 }
597 598
598 // Copy the entry pointer before passing it in base::Bind. 599 // Copy the entry pointer before passing it in base::Bind.
599 disk_cache::Entry* tmp_entry_ptr = match_context->entry; 600 disk_cache::Entry* tmp_entry_ptr = match_context->entry;
600 DCHECK(tmp_entry_ptr); 601 DCHECK(tmp_entry_ptr);
601 602
602 MetadataCallback headers_callback = base::Bind( 603 MetadataCallback headers_callback = base::Bind(
603 &CacheStorageCache::MatchDidReadMetadata, weak_ptr_factory_.GetWeakPtr(), 604 &CacheStorageCache::MatchDidReadMetadata, weak_ptr_factory_.GetWeakPtr(),
604 base::Passed(match_context.Pass())); 605 base::Passed(match_context.Pass()));
605 606
606 ReadMetadata(tmp_entry_ptr, headers_callback); 607 ReadMetadata(tmp_entry_ptr, headers_callback);
607 } 608 }
608 609
609 void CacheStorageCache::MatchDidReadMetadata( 610 void CacheStorageCache::MatchDidReadMetadata(
610 scoped_ptr<MatchContext> match_context, 611 scoped_ptr<MatchContext> match_context,
611 scoped_ptr<CacheMetadata> metadata) { 612 scoped_ptr<CacheMetadata> metadata) {
612 if (!metadata) { 613 if (!metadata) {
613 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, 614 match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
614 scoped_ptr<ServiceWorkerResponse>(), 615 scoped_ptr<ServiceWorkerResponse>(),
615 scoped_ptr<storage::BlobDataHandle>()); 616 scoped_ptr<storage::BlobDataHandle>());
616 return; 617 return;
617 } 618 }
618 619
619 match_context->response.reset(new ServiceWorkerResponse( 620 match_context->response.reset(new ServiceWorkerResponse(
620 match_context->request->url, metadata->response().status_code(), 621 match_context->request->url, metadata->response().status_code(),
621 metadata->response().status_text(), 622 metadata->response().status_text(),
622 ProtoResponseTypeToWebResponseType(metadata->response().response_type()), 623 ProtoResponseTypeToWebResponseType(metadata->response().response_type()),
623 ServiceWorkerHeaderMap(), "", 0, GURL())); 624 ServiceWorkerHeaderMap(), "", 0, GURL()));
(...skipping 13 matching lines...) Expand all
637 ServiceWorkerHeaderMap cached_request_headers; 638 ServiceWorkerHeaderMap cached_request_headers;
638 for (int i = 0; i < metadata->request().headers_size(); ++i) { 639 for (int i = 0; i < metadata->request().headers_size(); ++i) {
639 const CacheHeaderMap header = metadata->request().headers(i); 640 const CacheHeaderMap header = metadata->request().headers(i);
640 DCHECK(header.name().find('\0') == std::string::npos); 641 DCHECK(header.name().find('\0') == std::string::npos);
641 DCHECK(header.value().find('\0') == std::string::npos); 642 DCHECK(header.value().find('\0') == std::string::npos);
642 cached_request_headers[header.name()] = header.value(); 643 cached_request_headers[header.name()] = header.value();
643 } 644 }
644 645
645 if (!VaryMatches(match_context->request->headers, cached_request_headers, 646 if (!VaryMatches(match_context->request->headers, cached_request_headers,
646 response->headers)) { 647 response->headers)) {
647 match_context->original_callback.Run( 648 match_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND,
648 CacheStorageCache::ERROR_TYPE_NOT_FOUND, 649 scoped_ptr<ServiceWorkerResponse>(),
649 scoped_ptr<ServiceWorkerResponse>(), 650 scoped_ptr<storage::BlobDataHandle>());
650 scoped_ptr<storage::BlobDataHandle>());
651 return; 651 return;
652 } 652 }
653 653
654 if (match_context->entry->GetDataSize(INDEX_RESPONSE_BODY) == 0) { 654 if (match_context->entry->GetDataSize(INDEX_RESPONSE_BODY) == 0) {
655 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_OK, 655 match_context->original_callback.Run(CACHE_STORAGE_OK,
656 match_context->response.Pass(), 656 match_context->response.Pass(),
657 scoped_ptr<storage::BlobDataHandle>()); 657 scoped_ptr<storage::BlobDataHandle>());
658 return; 658 return;
659 } 659 }
660 660
661 // Stream the response body into a blob. 661 // Stream the response body into a blob.
662 if (!match_context->blob_storage_context) { 662 if (!match_context->blob_storage_context) {
663 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, 663 match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
664 scoped_ptr<ServiceWorkerResponse>(), 664 scoped_ptr<ServiceWorkerResponse>(),
665 scoped_ptr<storage::BlobDataHandle>()); 665 scoped_ptr<storage::BlobDataHandle>());
666 return; 666 return;
667 } 667 }
668 668
669 response->blob_uuid = base::GenerateGUID(); 669 response->blob_uuid = base::GenerateGUID();
670 670
671 match_context->blob_data.reset( 671 match_context->blob_data.reset(
672 new storage::BlobDataBuilder(response->blob_uuid)); 672 new storage::BlobDataBuilder(response->blob_uuid));
673 match_context->response_body_buffer = new net::IOBufferWithSize(kBufferSize); 673 match_context->response_body_buffer = new net::IOBufferWithSize(kBufferSize);
(...skipping 11 matching lines...) Expand all
685 response_body_buffer->size(), read_callback); 685 response_body_buffer->size(), read_callback);
686 686
687 if (read_rv != net::ERR_IO_PENDING) 687 if (read_rv != net::ERR_IO_PENDING)
688 read_callback.Run(read_rv); 688 read_callback.Run(read_rv);
689 } 689 }
690 690
691 void CacheStorageCache::MatchDidReadResponseBodyData( 691 void CacheStorageCache::MatchDidReadResponseBodyData(
692 scoped_ptr<MatchContext> match_context, 692 scoped_ptr<MatchContext> match_context,
693 int rv) { 693 int rv) {
694 if (rv < 0) { 694 if (rv < 0) {
695 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, 695 match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
696 scoped_ptr<ServiceWorkerResponse>(), 696 scoped_ptr<ServiceWorkerResponse>(),
697 scoped_ptr<storage::BlobDataHandle>()); 697 scoped_ptr<storage::BlobDataHandle>());
698 return; 698 return;
699 } 699 }
700 700
701 if (rv == 0) { 701 if (rv == 0) {
702 match_context->response->blob_uuid = match_context->blob_data->uuid(); 702 match_context->response->blob_uuid = match_context->blob_data->uuid();
703 match_context->response->blob_size = match_context->total_bytes_read; 703 match_context->response->blob_size = match_context->total_bytes_read;
704 MatchDoneWithBody(match_context.Pass()); 704 MatchDoneWithBody(match_context.Pass());
705 return; 705 return;
(...skipping 18 matching lines...) Expand all
724 int read_rv = tmp_entry_ptr->ReadData(INDEX_RESPONSE_BODY, total_bytes_read, 724 int read_rv = tmp_entry_ptr->ReadData(INDEX_RESPONSE_BODY, total_bytes_read,
725 buffer, buffer->size(), read_callback); 725 buffer, buffer->size(), read_callback);
726 726
727 if (read_rv != net::ERR_IO_PENDING) 727 if (read_rv != net::ERR_IO_PENDING)
728 read_callback.Run(read_rv); 728 read_callback.Run(read_rv);
729 } 729 }
730 730
731 void CacheStorageCache::MatchDoneWithBody( 731 void CacheStorageCache::MatchDoneWithBody(
732 scoped_ptr<MatchContext> match_context) { 732 scoped_ptr<MatchContext> match_context) {
733 if (!match_context->blob_storage_context) { 733 if (!match_context->blob_storage_context) {
734 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, 734 match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
735 scoped_ptr<ServiceWorkerResponse>(), 735 scoped_ptr<ServiceWorkerResponse>(),
736 scoped_ptr<storage::BlobDataHandle>()); 736 scoped_ptr<storage::BlobDataHandle>());
737 return; 737 return;
738 } 738 }
739 739
740 scoped_ptr<storage::BlobDataHandle> blob_data_handle( 740 scoped_ptr<storage::BlobDataHandle> blob_data_handle(
741 match_context->blob_storage_context->AddFinishedBlob( 741 match_context->blob_storage_context->AddFinishedBlob(
742 match_context->blob_data.get())); 742 match_context->blob_data.get()));
743 743
744 match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_OK, 744 match_context->original_callback.Run(CACHE_STORAGE_OK,
745 match_context->response.Pass(), 745 match_context->response.Pass(),
746 blob_data_handle.Pass()); 746 blob_data_handle.Pass());
747 } 747 }
748 748
749 void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { 749 void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) {
750 DCHECK(backend_state_ != BACKEND_UNINITIALIZED); 750 DCHECK(backend_state_ != BACKEND_UNINITIALIZED);
751 if (backend_state_ != BACKEND_OPEN) { 751 if (backend_state_ != BACKEND_OPEN) {
752 put_context->callback.Run(ERROR_TYPE_STORAGE); 752 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
753 return; 753 return;
754 } 754 }
755 755
756 scoped_ptr<ServiceWorkerFetchRequest> request_copy( 756 scoped_ptr<ServiceWorkerFetchRequest> request_copy(
757 new ServiceWorkerFetchRequest(*put_context->request)); 757 new ServiceWorkerFetchRequest(*put_context->request));
758 758
759 DeleteImpl(request_copy.Pass(), base::Bind(&CacheStorageCache::PutDidDelete, 759 DeleteImpl(request_copy.Pass(), base::Bind(&CacheStorageCache::PutDidDelete,
760 weak_ptr_factory_.GetWeakPtr(), 760 weak_ptr_factory_.GetWeakPtr(),
761 base::Passed(put_context.Pass()))); 761 base::Passed(put_context.Pass())));
762 } 762 }
763 763
764 void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, 764 void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context,
765 ErrorType delete_error) { 765 CacheStorageError delete_error) {
766 if (backend_state_ != BACKEND_OPEN) { 766 if (backend_state_ != BACKEND_OPEN) {
767 put_context->callback.Run(ERROR_TYPE_STORAGE); 767 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
768 return; 768 return;
769 } 769 }
770 770
771 disk_cache::Entry** entry_ptr = &put_context->cache_entry; 771 disk_cache::Entry** entry_ptr = &put_context->cache_entry;
772 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); 772 ServiceWorkerFetchRequest* request_ptr = put_context->request.get();
773 disk_cache::Backend* backend_ptr = backend_.get(); 773 disk_cache::Backend* backend_ptr = backend_.get();
774 774
775 net::CompletionCallback create_entry_callback = base::Bind( 775 net::CompletionCallback create_entry_callback = base::Bind(
776 &CacheStorageCache::PutDidCreateEntry, weak_ptr_factory_.GetWeakPtr(), 776 &CacheStorageCache::PutDidCreateEntry, weak_ptr_factory_.GetWeakPtr(),
777 base::Passed(put_context.Pass())); 777 base::Passed(put_context.Pass()));
778 778
779 int create_rv = backend_ptr->CreateEntry(request_ptr->url.spec(), entry_ptr, 779 int create_rv = backend_ptr->CreateEntry(request_ptr->url.spec(), entry_ptr,
780 create_entry_callback); 780 create_entry_callback);
781 781
782 if (create_rv != net::ERR_IO_PENDING) 782 if (create_rv != net::ERR_IO_PENDING)
783 create_entry_callback.Run(create_rv); 783 create_entry_callback.Run(create_rv);
784 } 784 }
785 785
786 void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context, 786 void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context,
787 int rv) { 787 int rv) {
788 if (rv != net::OK) { 788 if (rv != net::OK) {
789 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_EXISTS); 789 put_context->callback.Run(CACHE_STORAGE_ERROR_EXISTS);
790 return; 790 return;
791 } 791 }
792 792
793 DCHECK(put_context->cache_entry); 793 DCHECK(put_context->cache_entry);
794 794
795 CacheMetadata metadata; 795 CacheMetadata metadata;
796 CacheRequest* request_metadata = metadata.mutable_request(); 796 CacheRequest* request_metadata = metadata.mutable_request();
797 request_metadata->set_method(put_context->request->method); 797 request_metadata->set_method(put_context->request->method);
798 for (ServiceWorkerHeaderMap::const_iterator it = 798 for (ServiceWorkerHeaderMap::const_iterator it =
799 put_context->request->headers.begin(); 799 put_context->request->headers.begin();
(...skipping 16 matching lines...) Expand all
816 it != put_context->response->headers.end(); ++it) { 816 it != put_context->response->headers.end(); ++it) {
817 DCHECK(it->first.find('\0') == std::string::npos); 817 DCHECK(it->first.find('\0') == std::string::npos);
818 DCHECK(it->second.find('\0') == std::string::npos); 818 DCHECK(it->second.find('\0') == std::string::npos);
819 CacheHeaderMap* header_map = response_metadata->add_headers(); 819 CacheHeaderMap* header_map = response_metadata->add_headers();
820 header_map->set_name(it->first); 820 header_map->set_name(it->first);
821 header_map->set_value(it->second); 821 header_map->set_value(it->second);
822 } 822 }
823 823
824 scoped_ptr<std::string> serialized(new std::string()); 824 scoped_ptr<std::string> serialized(new std::string());
825 if (!metadata.SerializeToString(serialized.get())) { 825 if (!metadata.SerializeToString(serialized.get())) {
826 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); 826 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
827 return; 827 return;
828 } 828 }
829 829
830 scoped_refptr<net::StringIOBuffer> buffer( 830 scoped_refptr<net::StringIOBuffer> buffer(
831 new net::StringIOBuffer(serialized.Pass())); 831 new net::StringIOBuffer(serialized.Pass()));
832 832
833 // Get a temporary copy of the entry pointer before passing it in base::Bind. 833 // Get a temporary copy of the entry pointer before passing it in base::Bind.
834 disk_cache::Entry* tmp_entry_ptr = put_context->cache_entry; 834 disk_cache::Entry* tmp_entry_ptr = put_context->cache_entry;
835 835
836 net::CompletionCallback write_headers_callback = base::Bind( 836 net::CompletionCallback write_headers_callback = base::Bind(
837 &CacheStorageCache::PutDidWriteHeaders, weak_ptr_factory_.GetWeakPtr(), 837 &CacheStorageCache::PutDidWriteHeaders, weak_ptr_factory_.GetWeakPtr(),
838 base::Passed(put_context.Pass()), buffer->size()); 838 base::Passed(put_context.Pass()), buffer->size());
839 839
840 rv = tmp_entry_ptr->WriteData(INDEX_HEADERS, 0 /* offset */, buffer.get(), 840 rv = tmp_entry_ptr->WriteData(INDEX_HEADERS, 0 /* offset */, buffer.get(),
841 buffer->size(), write_headers_callback, 841 buffer->size(), write_headers_callback,
842 true /* truncate */); 842 true /* truncate */);
843 843
844 if (rv != net::ERR_IO_PENDING) 844 if (rv != net::ERR_IO_PENDING)
845 write_headers_callback.Run(rv); 845 write_headers_callback.Run(rv);
846 } 846 }
847 847
848 void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, 848 void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context,
849 int expected_bytes, 849 int expected_bytes,
850 int rv) { 850 int rv) {
851 if (rv != expected_bytes) { 851 if (rv != expected_bytes) {
852 put_context->cache_entry->Doom(); 852 put_context->cache_entry->Doom();
853 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); 853 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
854 return; 854 return;
855 } 855 }
856 856
857 // The metadata is written, now for the response content. The data is streamed 857 // The metadata is written, now for the response content. The data is streamed
858 // from the blob into the cache entry. 858 // from the blob into the cache entry.
859 859
860 if (put_context->response->blob_uuid.empty()) { 860 if (put_context->response->blob_uuid.empty()) {
861 if (put_context->quota_manager_proxy.get()) { 861 if (put_context->quota_manager_proxy.get()) {
862 put_context->quota_manager_proxy->NotifyStorageModified( 862 put_context->quota_manager_proxy->NotifyStorageModified(
863 storage::QuotaClient::kServiceWorkerCache, put_context->origin, 863 storage::QuotaClient::kServiceWorkerCache, put_context->origin,
864 storage::kStorageTypeTemporary, 864 storage::kStorageTypeTemporary,
865 put_context->cache_entry->GetDataSize(INDEX_HEADERS)); 865 put_context->cache_entry->GetDataSize(INDEX_HEADERS));
866 } 866 }
867 867
868 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); 868 put_context->callback.Run(CACHE_STORAGE_OK);
869 return; 869 return;
870 } 870 }
871 871
872 DCHECK(put_context->blob_data_handle); 872 DCHECK(put_context->blob_data_handle);
873 873
874 disk_cache::ScopedEntryPtr entry(put_context->cache_entry); 874 disk_cache::ScopedEntryPtr entry(put_context->cache_entry);
875 put_context->cache_entry = NULL; 875 put_context->cache_entry = NULL;
876 scoped_ptr<BlobReader> reader(new BlobReader()); 876 scoped_ptr<BlobReader> reader(new BlobReader());
877 BlobReader* reader_ptr = reader.get(); 877 BlobReader* reader_ptr = reader.get();
878 878
(...skipping 13 matching lines...) Expand all
892 void CacheStorageCache::PutDidWriteBlobToCache( 892 void CacheStorageCache::PutDidWriteBlobToCache(
893 scoped_ptr<PutContext> put_context, 893 scoped_ptr<PutContext> put_context,
894 scoped_ptr<BlobReader> blob_reader, 894 scoped_ptr<BlobReader> blob_reader,
895 disk_cache::ScopedEntryPtr entry, 895 disk_cache::ScopedEntryPtr entry,
896 bool success) { 896 bool success) {
897 DCHECK(entry); 897 DCHECK(entry);
898 put_context->cache_entry = entry.release(); 898 put_context->cache_entry = entry.release();
899 899
900 if (!success) { 900 if (!success) {
901 put_context->cache_entry->Doom(); 901 put_context->cache_entry->Doom();
902 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); 902 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
903 return; 903 return;
904 } 904 }
905 905
906 if (put_context->quota_manager_proxy.get()) { 906 if (put_context->quota_manager_proxy.get()) {
907 put_context->quota_manager_proxy->NotifyStorageModified( 907 put_context->quota_manager_proxy->NotifyStorageModified(
908 storage::QuotaClient::kServiceWorkerCache, put_context->origin, 908 storage::QuotaClient::kServiceWorkerCache, put_context->origin,
909 storage::kStorageTypeTemporary, 909 storage::kStorageTypeTemporary,
910 put_context->cache_entry->GetDataSize(INDEX_HEADERS) + 910 put_context->cache_entry->GetDataSize(INDEX_HEADERS) +
911 put_context->cache_entry->GetDataSize(INDEX_RESPONSE_BODY)); 911 put_context->cache_entry->GetDataSize(INDEX_RESPONSE_BODY));
912 } 912 }
913 913
914 put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); 914 put_context->callback.Run(CACHE_STORAGE_OK);
915 } 915 }
916 916
917 void CacheStorageCache::DeleteImpl( 917 void CacheStorageCache::DeleteImpl(
918 scoped_ptr<ServiceWorkerFetchRequest> request, 918 scoped_ptr<ServiceWorkerFetchRequest> request,
919 const ErrorCallback& callback) { 919 const ErrorCallback& callback) {
920 DCHECK(backend_state_ != BACKEND_UNINITIALIZED); 920 DCHECK(backend_state_ != BACKEND_UNINITIALIZED);
921 if (backend_state_ != BACKEND_OPEN) { 921 if (backend_state_ != BACKEND_OPEN) {
922 callback.Run(ERROR_TYPE_STORAGE); 922 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
923 return; 923 return;
924 } 924 }
925 scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*); 925 scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*);
926 926
927 disk_cache::Entry** entry_ptr = entry.get(); 927 disk_cache::Entry** entry_ptr = entry.get();
928 928
929 ServiceWorkerFetchRequest* request_ptr = request.get(); 929 ServiceWorkerFetchRequest* request_ptr = request.get();
930 930
931 net::CompletionCallback open_entry_callback = base::Bind( 931 net::CompletionCallback open_entry_callback = base::Bind(
932 &CacheStorageCache::DeleteDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), 932 &CacheStorageCache::DeleteDidOpenEntry, weak_ptr_factory_.GetWeakPtr(),
933 origin_, base::Passed(request.Pass()), callback, 933 origin_, base::Passed(request.Pass()), callback,
934 base::Passed(entry.Pass()), quota_manager_proxy_); 934 base::Passed(entry.Pass()), quota_manager_proxy_);
935 935
936 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr, 936 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr,
937 open_entry_callback); 937 open_entry_callback);
938 if (rv != net::ERR_IO_PENDING) 938 if (rv != net::ERR_IO_PENDING)
939 open_entry_callback.Run(rv); 939 open_entry_callback.Run(rv);
940 } 940 }
941 941
942 void CacheStorageCache::DeleteDidOpenEntry( 942 void CacheStorageCache::DeleteDidOpenEntry(
943 const GURL& origin, 943 const GURL& origin,
944 scoped_ptr<ServiceWorkerFetchRequest> request, 944 scoped_ptr<ServiceWorkerFetchRequest> request,
945 const CacheStorageCache::ErrorCallback& callback, 945 const CacheStorageCache::ErrorCallback& callback,
946 scoped_ptr<disk_cache::Entry*> entry_ptr, 946 scoped_ptr<disk_cache::Entry*> entry_ptr,
947 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, 947 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy,
948 int rv) { 948 int rv) {
949 if (rv != net::OK) { 949 if (rv != net::OK) {
950 callback.Run(CacheStorageCache::ERROR_TYPE_NOT_FOUND); 950 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND);
951 return; 951 return;
952 } 952 }
953 953
954 DCHECK(entry_ptr); 954 DCHECK(entry_ptr);
955 disk_cache::ScopedEntryPtr entry(*entry_ptr); 955 disk_cache::ScopedEntryPtr entry(*entry_ptr);
956 956
957 if (quota_manager_proxy.get()) { 957 if (quota_manager_proxy.get()) {
958 quota_manager_proxy->NotifyStorageModified( 958 quota_manager_proxy->NotifyStorageModified(
959 storage::QuotaClient::kServiceWorkerCache, origin, 959 storage::QuotaClient::kServiceWorkerCache, origin,
960 storage::kStorageTypeTemporary, 960 storage::kStorageTypeTemporary,
961 -1 * (entry->GetDataSize(INDEX_HEADERS) + 961 -1 * (entry->GetDataSize(INDEX_HEADERS) +
962 entry->GetDataSize(INDEX_RESPONSE_BODY))); 962 entry->GetDataSize(INDEX_RESPONSE_BODY)));
963 } 963 }
964 964
965 entry->Doom(); 965 entry->Doom();
966 callback.Run(CacheStorageCache::ERROR_TYPE_OK); 966 callback.Run(CACHE_STORAGE_OK);
967 } 967 }
968 968
969 void CacheStorageCache::KeysImpl(const RequestsCallback& callback) { 969 void CacheStorageCache::KeysImpl(const RequestsCallback& callback) {
970 DCHECK(backend_state_ != BACKEND_UNINITIALIZED); 970 DCHECK(backend_state_ != BACKEND_UNINITIALIZED);
971 if (backend_state_ != BACKEND_OPEN) { 971 if (backend_state_ != BACKEND_OPEN) {
972 callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<Requests>()); 972 callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>());
973 return; 973 return;
974 } 974 }
975 975
976 // 1. Iterate through all of the entries, open them, and add them to a vector. 976 // 1. Iterate through all of the entries, open them, and add them to a vector.
977 // 2. For each open entry: 977 // 2. For each open entry:
978 // 2.1. Read the headers into a protobuf. 978 // 2.1. Read the headers into a protobuf.
979 // 2.2. Copy the protobuf into a ServiceWorkerFetchRequest (a "key"). 979 // 2.2. Copy the protobuf into a ServiceWorkerFetchRequest (a "key").
980 // 2.3. Push the response into a vector of requests to be returned. 980 // 2.3. Push the response into a vector of requests to be returned.
981 // 3. Return the vector of requests (keys). 981 // 3. Return the vector of requests (keys).
982 982
(...skipping 21 matching lines...) Expand all
1004 int rv) { 1004 int rv) {
1005 if (rv == net::ERR_FAILED) { 1005 if (rv == net::ERR_FAILED) {
1006 DCHECK(!keys_context->enumerated_entry); 1006 DCHECK(!keys_context->enumerated_entry);
1007 // Enumeration is complete, extract the requests from the entries. 1007 // Enumeration is complete, extract the requests from the entries.
1008 Entries::iterator iter = keys_context->entries.begin(); 1008 Entries::iterator iter = keys_context->entries.begin();
1009 KeysProcessNextEntry(keys_context.Pass(), iter); 1009 KeysProcessNextEntry(keys_context.Pass(), iter);
1010 return; 1010 return;
1011 } 1011 }
1012 1012
1013 if (rv < 0) { 1013 if (rv < 0) {
1014 keys_context->original_callback.Run(ERROR_TYPE_STORAGE, 1014 keys_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
1015 scoped_ptr<Requests>()); 1015 scoped_ptr<Requests>());
1016 return; 1016 return;
1017 } 1017 }
1018 1018
1019 if (backend_state_ != BACKEND_OPEN) { 1019 if (backend_state_ != BACKEND_OPEN) {
1020 keys_context->original_callback.Run(ERROR_TYPE_NOT_FOUND, 1020 keys_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND,
1021 scoped_ptr<Requests>()); 1021 scoped_ptr<Requests>());
1022 return; 1022 return;
1023 } 1023 }
1024 1024
1025 // Store the entry. 1025 // Store the entry.
1026 keys_context->entries.push_back(keys_context->enumerated_entry); 1026 keys_context->entries.push_back(keys_context->enumerated_entry);
1027 keys_context->enumerated_entry = NULL; 1027 keys_context->enumerated_entry = NULL;
1028 1028
1029 // Enumerate the next entry. 1029 // Enumerate the next entry.
1030 disk_cache::Backend::Iterator& iterator = *keys_context->backend_iterator; 1030 disk_cache::Backend::Iterator& iterator = *keys_context->backend_iterator;
1031 disk_cache::Entry** enumerated_entry = &keys_context->enumerated_entry; 1031 disk_cache::Entry** enumerated_entry = &keys_context->enumerated_entry;
1032 net::CompletionCallback open_entry_callback = base::Bind( 1032 net::CompletionCallback open_entry_callback = base::Bind(
1033 &CacheStorageCache::KeysDidOpenNextEntry, weak_ptr_factory_.GetWeakPtr(), 1033 &CacheStorageCache::KeysDidOpenNextEntry, weak_ptr_factory_.GetWeakPtr(),
1034 base::Passed(keys_context.Pass())); 1034 base::Passed(keys_context.Pass()));
1035 1035
1036 rv = iterator.OpenNextEntry(enumerated_entry, open_entry_callback); 1036 rv = iterator.OpenNextEntry(enumerated_entry, open_entry_callback);
1037 1037
1038 if (rv != net::ERR_IO_PENDING) 1038 if (rv != net::ERR_IO_PENDING)
1039 open_entry_callback.Run(rv); 1039 open_entry_callback.Run(rv);
1040 } 1040 }
1041 1041
1042 void CacheStorageCache::KeysProcessNextEntry( 1042 void CacheStorageCache::KeysProcessNextEntry(
1043 scoped_ptr<KeysContext> keys_context, 1043 scoped_ptr<KeysContext> keys_context,
1044 const Entries::iterator& iter) { 1044 const Entries::iterator& iter) {
1045 if (iter == keys_context->entries.end()) { 1045 if (iter == keys_context->entries.end()) {
1046 // All done. Return all of the keys. 1046 // All done. Return all of the keys.
1047 keys_context->original_callback.Run(ERROR_TYPE_OK, 1047 keys_context->original_callback.Run(CACHE_STORAGE_OK,
1048 keys_context->out_keys.Pass()); 1048 keys_context->out_keys.Pass());
1049 return; 1049 return;
1050 } 1050 }
1051 1051
1052 ReadMetadata(*iter, base::Bind(&CacheStorageCache::KeysDidReadMetadata, 1052 ReadMetadata(*iter, base::Bind(&CacheStorageCache::KeysDidReadMetadata,
1053 weak_ptr_factory_.GetWeakPtr(), 1053 weak_ptr_factory_.GetWeakPtr(),
1054 base::Passed(keys_context.Pass()), iter)); 1054 base::Passed(keys_context.Pass()), iter));
1055 } 1055 }
1056 1056
1057 void CacheStorageCache::KeysDidReadMetadata( 1057 void CacheStorageCache::KeysDidReadMetadata(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 NULL, backend, create_cache_callback); 1114 NULL, backend, create_cache_callback);
1115 if (rv != net::ERR_IO_PENDING) 1115 if (rv != net::ERR_IO_PENDING)
1116 create_cache_callback.Run(rv); 1116 create_cache_callback.Run(rv);
1117 } 1117 }
1118 1118
1119 void CacheStorageCache::CreateBackendDidCreate( 1119 void CacheStorageCache::CreateBackendDidCreate(
1120 const CacheStorageCache::ErrorCallback& callback, 1120 const CacheStorageCache::ErrorCallback& callback,
1121 scoped_ptr<ScopedBackendPtr> backend_ptr, 1121 scoped_ptr<ScopedBackendPtr> backend_ptr,
1122 int rv) { 1122 int rv) {
1123 if (rv != net::OK) { 1123 if (rv != net::OK) {
1124 callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); 1124 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
1125 return; 1125 return;
1126 } 1126 }
1127 1127
1128 backend_ = backend_ptr->Pass(); 1128 backend_ = backend_ptr->Pass();
1129 callback.Run(CacheStorageCache::ERROR_TYPE_OK); 1129 callback.Run(CACHE_STORAGE_OK);
1130 } 1130 }
1131 1131
1132 void CacheStorageCache::InitBackend() { 1132 void CacheStorageCache::InitBackend() {
1133 DCHECK(backend_state_ == BACKEND_UNINITIALIZED); 1133 DCHECK(backend_state_ == BACKEND_UNINITIALIZED);
1134 1134
1135 if (initializing_) 1135 if (initializing_)
1136 return; 1136 return;
1137 1137
1138 DCHECK(!scheduler_->ScheduledOperations()); 1138 DCHECK(!scheduler_->ScheduledOperations());
1139 initializing_ = true; 1139 initializing_ = true;
1140 1140
1141 scheduler_->ScheduleOperation(base::Bind( 1141 scheduler_->ScheduleOperation(base::Bind(
1142 &CacheStorageCache::CreateBackend, weak_ptr_factory_.GetWeakPtr(), 1142 &CacheStorageCache::CreateBackend, weak_ptr_factory_.GetWeakPtr(),
1143 base::Bind(&CacheStorageCache::InitDone, 1143 base::Bind(&CacheStorageCache::InitDone,
1144 weak_ptr_factory_.GetWeakPtr()))); 1144 weak_ptr_factory_.GetWeakPtr())));
1145 } 1145 }
1146 1146
1147 void CacheStorageCache::InitDone(ErrorType error) { 1147 void CacheStorageCache::InitDone(CacheStorageError error) {
1148 initializing_ = false; 1148 initializing_ = false;
1149 backend_state_ = (error == ERROR_TYPE_OK && backend_ && 1149 backend_state_ = (error == CACHE_STORAGE_OK && backend_ &&
1150 backend_state_ == BACKEND_UNINITIALIZED) 1150 backend_state_ == BACKEND_UNINITIALIZED)
1151 ? BACKEND_OPEN 1151 ? BACKEND_OPEN
1152 : BACKEND_CLOSED; 1152 : BACKEND_CLOSED;
1153 1153
1154 UMA_HISTOGRAM_ENUMERATION("ServiceWorkerCache.InitBackendResult", error, 1154 UMA_HISTOGRAM_ENUMERATION("ServiceWorkerCache.InitBackendResult", error,
1155 ErrorType::ERROR_TYPE_LAST + 1); 1155 CACHE_STORAGE_ERROR_LAST + 1);
1156 1156
1157 scheduler_->CompleteOperationAndRunNext(); 1157 scheduler_->CompleteOperationAndRunNext();
1158 } 1158 }
1159 1159
1160 void CacheStorageCache::PendingClosure(const base::Closure& callback) { 1160 void CacheStorageCache::PendingClosure(const base::Closure& callback) {
1161 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); 1161 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr();
1162 1162
1163 callback.Run(); 1163 callback.Run();
1164 if (cache) 1164 if (cache)
1165 scheduler_->CompleteOperationAndRunNext(); 1165 scheduler_->CompleteOperationAndRunNext();
1166 } 1166 }
1167 1167
1168 void CacheStorageCache::PendingErrorCallback(const ErrorCallback& callback, 1168 void CacheStorageCache::PendingErrorCallback(const ErrorCallback& callback,
1169 ErrorType error) { 1169 CacheStorageError error) {
1170 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); 1170 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr();
1171 1171
1172 callback.Run(error); 1172 callback.Run(error);
1173 if (cache) 1173 if (cache)
1174 scheduler_->CompleteOperationAndRunNext(); 1174 scheduler_->CompleteOperationAndRunNext();
1175 } 1175 }
1176 1176
1177 void CacheStorageCache::PendingResponseCallback( 1177 void CacheStorageCache::PendingResponseCallback(
1178 const ResponseCallback& callback, 1178 const ResponseCallback& callback,
1179 ErrorType error, 1179 CacheStorageError error,
1180 scoped_ptr<ServiceWorkerResponse> response, 1180 scoped_ptr<ServiceWorkerResponse> response,
1181 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { 1181 scoped_ptr<storage::BlobDataHandle> blob_data_handle) {
1182 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); 1182 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr();
1183 1183
1184 callback.Run(error, response.Pass(), blob_data_handle.Pass()); 1184 callback.Run(error, response.Pass(), blob_data_handle.Pass());
1185 if (cache) 1185 if (cache)
1186 scheduler_->CompleteOperationAndRunNext(); 1186 scheduler_->CompleteOperationAndRunNext();
1187 } 1187 }
1188 1188
1189 void CacheStorageCache::PendingRequestsCallback( 1189 void CacheStorageCache::PendingRequestsCallback(
1190 const RequestsCallback& callback, 1190 const RequestsCallback& callback,
1191 ErrorType error, 1191 CacheStorageError error,
1192 scoped_ptr<Requests> requests) { 1192 scoped_ptr<Requests> requests) {
1193 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); 1193 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr();
1194 1194
1195 callback.Run(error, requests.Pass()); 1195 callback.Run(error, requests.Pass());
1196 if (cache) 1196 if (cache)
1197 scheduler_->CompleteOperationAndRunNext(); 1197 scheduler_->CompleteOperationAndRunNext();
1198 } 1198 }
1199 1199
1200 } // namespace content 1200 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.h ('k') | content/browser/cache_storage/cache_storage_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698