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

Side by Side Diff: content/browser/appcache/appcache_url_request_job_unittest.cc

Issue 1887153002: Removing unused field - AppCacheResponseIO::group_id_. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 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
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/appcache/appcache_url_request_job.h" 5 #include "content/browser/appcache/appcache_url_request_job.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 base::Bind(&ExpectNotRestarted))); 495 base::Bind(&ExpectNotRestarted)));
496 job->DeliverNetworkResponse(); 496 job->DeliverNetworkResponse();
497 EXPECT_TRUE(job->is_delivering_network_response()); 497 EXPECT_TRUE(job->is_delivering_network_response());
498 EXPECT_FALSE(job->has_been_started()); 498 EXPECT_FALSE(job->has_been_started());
499 499
500 job.reset(new AppCacheURLRequestJob(request.get(), nullptr, storage, 500 job.reset(new AppCacheURLRequestJob(request.get(), nullptr, storage,
501 nullptr, false, 501 nullptr, false,
502 base::Bind(&ExpectNotRestarted))); 502 base::Bind(&ExpectNotRestarted)));
503 const GURL kManifestUrl("http://blah/"); 503 const GURL kManifestUrl("http://blah/");
504 const int64_t kCacheId(1); 504 const int64_t kCacheId(1);
505 const int64_t kGroupId(1);
506 const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1); 505 const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1);
507 job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kGroupId, 506 job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kEntry, false);
508 kEntry, false);
509 EXPECT_FALSE(job->is_waiting()); 507 EXPECT_FALSE(job->is_waiting());
510 EXPECT_TRUE(job->is_delivering_appcache_response()); 508 EXPECT_TRUE(job->is_delivering_appcache_response());
511 EXPECT_FALSE(job->has_been_started()); 509 EXPECT_FALSE(job->has_been_started());
512 EXPECT_EQ(kManifestUrl, job->manifest_url()); 510 EXPECT_EQ(kManifestUrl, job->manifest_url());
513 EXPECT_EQ(kCacheId, job->cache_id()); 511 EXPECT_EQ(kCacheId, job->cache_id());
514 EXPECT_EQ(kGroupId, job->group_id());
515 EXPECT_EQ(kEntry.types(), job->entry().types()); 512 EXPECT_EQ(kEntry.types(), job->entry().types());
516 EXPECT_EQ(kEntry.response_id(), job->entry().response_id()); 513 EXPECT_EQ(kEntry.response_id(), job->entry().response_id());
517 514
518 TestFinished(); 515 TestFinished();
519 } 516 }
520 517
521 // DeliverNetworkResponse -------------------------------------------------- 518 // DeliverNetworkResponse --------------------------------------------------
522 519
523 void DeliverNetworkResponse() { 520 void DeliverNetworkResponse() {
524 // This test has async steps. 521 // This test has async steps.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 // 2. Use net::URLRequest to retrieve it. 599 // 2. Use net::URLRequest to retrieve it.
603 // 3. Verify we received what we expected to receive. 600 // 3. Verify we received what we expected to receive.
604 601
605 PushNextTask(base::Bind( 602 PushNextTask(base::Bind(
606 &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse, 603 &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse,
607 base::Unretained(this))); 604 base::Unretained(this)));
608 PushNextTask( 605 PushNextTask(
609 base::Bind(&AppCacheURLRequestJobTest::RequestAppCachedResource, 606 base::Bind(&AppCacheURLRequestJobTest::RequestAppCachedResource,
610 base::Unretained(this), false)); 607 base::Unretained(this), false));
611 608
612 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); 609 writer_.reset(service_->storage()->CreateResponseWriter(GURL()));
613 written_response_id_ = writer_->response_id(); 610 written_response_id_ = writer_->response_id();
614 WriteBasicResponse(); 611 WriteBasicResponse();
615 // Continues async 612 // Continues async
616 } 613 }
617 614
618 void RequestAppCachedResource(bool start_after_delivery_orders) { 615 void RequestAppCachedResource(bool start_after_delivery_orders) {
619 AppCacheStorage* storage = service_->storage(); 616 AppCacheStorage* storage = service_->storage();
620 request_ = empty_context_->CreateRequest(GURL("http://blah/"), 617 request_ = empty_context_->CreateRequest(GURL("http://blah/"),
621 net::DEFAULT_PRIORITY, 618 net::DEFAULT_PRIORITY,
622 url_request_delegate_.get()); 619 url_request_delegate_.get());
623 620
624 // Setup to create an AppCacheURLRequestJob with orders to deliver 621 // Setup to create an AppCacheURLRequestJob with orders to deliver
625 // a network response. 622 // a network response.
626 std::unique_ptr<AppCacheURLRequestJob> job( 623 std::unique_ptr<AppCacheURLRequestJob> job(
627 new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false, 624 new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false,
628 base::Bind(&ExpectNotRestarted))); 625 base::Bind(&ExpectNotRestarted)));
629 626
630 if (start_after_delivery_orders) { 627 if (start_after_delivery_orders) {
631 job->DeliverAppCachedResponse( 628 job->DeliverAppCachedResponse(
632 GURL(), 0, 111, 629 GURL(), 111,
633 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), 630 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false);
634 false);
635 EXPECT_TRUE(job->is_delivering_appcache_response()); 631 EXPECT_TRUE(job->is_delivering_appcache_response());
636 } 632 }
637 633
638 // Start the request. 634 // Start the request.
639 EXPECT_FALSE(job->has_been_started()); 635 EXPECT_FALSE(job->has_been_started());
640 base::WeakPtr<AppCacheURLRequestJob> weak_job = job->GetWeakPtr(); 636 base::WeakPtr<AppCacheURLRequestJob> weak_job = job->GetWeakPtr();
641 job_factory_->SetJob(std::move(job)); 637 job_factory_->SetJob(std::move(job));
642 request_->Start(); 638 request_->Start();
643 EXPECT_FALSE(job_factory_->has_job()); 639 EXPECT_FALSE(job_factory_->has_job());
644 ASSERT_TRUE(weak_job); 640 ASSERT_TRUE(weak_job);
645 EXPECT_TRUE(weak_job->has_been_started()); 641 EXPECT_TRUE(weak_job->has_been_started());
646 642
647 if (!start_after_delivery_orders) { 643 if (!start_after_delivery_orders) {
648 weak_job->DeliverAppCachedResponse( 644 weak_job->DeliverAppCachedResponse(
649 GURL(), 0, 111, 645 GURL(), 111,
650 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false); 646 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false);
651 ASSERT_TRUE(weak_job); 647 ASSERT_TRUE(weak_job);
652 EXPECT_TRUE(weak_job->is_delivering_appcache_response()); 648 EXPECT_TRUE(weak_job->is_delivering_appcache_response());
653 } 649 }
654 650
655 // Completion is async. 651 // Completion is async.
656 } 652 }
657 653
658 void VerifyDeliverSmallAppCachedResponse() { 654 void VerifyDeliverSmallAppCachedResponse() {
659 EXPECT_TRUE(request_->status().is_success()); 655 EXPECT_TRUE(request_->status().is_success());
(...skipping 16 matching lines...) Expand all
676 // 2. Use net::URLRequest to retrieve it. 672 // 2. Use net::URLRequest to retrieve it.
677 // 3. Verify we received what we expected to receive. 673 // 3. Verify we received what we expected to receive.
678 674
679 PushNextTask(base::Bind( 675 PushNextTask(base::Bind(
680 &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse, 676 &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse,
681 base::Unretained(this))); 677 base::Unretained(this)));
682 PushNextTask(base::Bind( 678 PushNextTask(base::Bind(
683 &AppCacheURLRequestJobTest::RequestAppCachedResource, 679 &AppCacheURLRequestJobTest::RequestAppCachedResource,
684 base::Unretained(this), true)); 680 base::Unretained(this), true));
685 681
686 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); 682 writer_.reset(service_->storage()->CreateResponseWriter(GURL()));
687 written_response_id_ = writer_->response_id(); 683 written_response_id_ = writer_->response_id();
688 WriteLargeResponse(); 684 WriteLargeResponse();
689 // Continues async 685 // Continues async
690 } 686 }
691 687
692 void WriteLargeResponse() { 688 void WriteLargeResponse() {
693 // 3, 1k blocks 689 // 3, 1k blocks
694 static const char kHttpHeaders[] = 690 static const char kHttpHeaders[] =
695 "HTTP/1.0 200 OK\0Content-Length: 3072\0\0"; 691 "HTTP/1.0 200 OK\0Content-Length: 3072\0\0";
696 scoped_refptr<IOBuffer> body(new IOBuffer(kBlockSize * 3)); 692 scoped_refptr<IOBuffer> body(new IOBuffer(kBlockSize * 3));
(...skipping 22 matching lines...) Expand all
719 void DeliverPartialResponse() { 715 void DeliverPartialResponse() {
720 // This test has several async steps. 716 // This test has several async steps.
721 // 1. Write a small response to response storage. 717 // 1. Write a small response to response storage.
722 // 2. Use net::URLRequest to retrieve it a subset using a range request 718 // 2. Use net::URLRequest to retrieve it a subset using a range request
723 // 3. Verify we received what we expected to receive. 719 // 3. Verify we received what we expected to receive.
724 PushNextTask(base::Bind( 720 PushNextTask(base::Bind(
725 &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse, 721 &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse,
726 base::Unretained(this))); 722 base::Unretained(this)));
727 PushNextTask(base::Bind( 723 PushNextTask(base::Bind(
728 &AppCacheURLRequestJobTest::MakeRangeRequest, base::Unretained(this))); 724 &AppCacheURLRequestJobTest::MakeRangeRequest, base::Unretained(this)));
729 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); 725 writer_.reset(service_->storage()->CreateResponseWriter(GURL()));
730 written_response_id_ = writer_->response_id(); 726 written_response_id_ = writer_->response_id();
731 WriteBasicResponse(); 727 WriteBasicResponse();
732 // Continues async 728 // Continues async
733 } 729 }
734 730
735 void MakeRangeRequest() { 731 void MakeRangeRequest() {
736 AppCacheStorage* storage = service_->storage(); 732 AppCacheStorage* storage = service_->storage();
737 request_ = empty_context_->CreateRequest(GURL("http://blah/"), 733 request_ = empty_context_->CreateRequest(GURL("http://blah/"),
738 net::DEFAULT_PRIORITY, 734 net::DEFAULT_PRIORITY,
739 url_request_delegate_.get()); 735 url_request_delegate_.get());
740 736
741 // Request a range, the 3 middle chars out of 'Hello' 737 // Request a range, the 3 middle chars out of 'Hello'
742 net::HttpRequestHeaders extra_headers; 738 net::HttpRequestHeaders extra_headers;
743 extra_headers.SetHeader("Range", "bytes= 1-3"); 739 extra_headers.SetHeader("Range", "bytes= 1-3");
744 request_->SetExtraRequestHeaders(extra_headers); 740 request_->SetExtraRequestHeaders(extra_headers);
745 741
746 // Create job with orders to deliver an appcached entry. 742 // Create job with orders to deliver an appcached entry.
747 std::unique_ptr<AppCacheURLRequestJob> job( 743 std::unique_ptr<AppCacheURLRequestJob> job(
748 new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false, 744 new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false,
749 base::Bind(&ExpectNotRestarted))); 745 base::Bind(&ExpectNotRestarted)));
750 job->DeliverAppCachedResponse( 746 job->DeliverAppCachedResponse(
751 GURL(), 0, 111, 747 GURL(), 111,
752 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), 748 AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false);
753 false);
754 EXPECT_TRUE(job->is_delivering_appcache_response()); 749 EXPECT_TRUE(job->is_delivering_appcache_response());
755 750
756 // Start the request. 751 // Start the request.
757 EXPECT_FALSE(job->has_been_started()); 752 EXPECT_FALSE(job->has_been_started());
758 job_factory_->SetJob(std::move(job)); 753 job_factory_->SetJob(std::move(job));
759 request_->Start(); 754 request_->Start();
760 EXPECT_FALSE(job_factory_->has_job()); 755 EXPECT_FALSE(job_factory_->has_job());
761 // Completion is async. 756 // Completion is async.
762 } 757 }
763 758
(...skipping 23 matching lines...) Expand all
787 // 1. Write a large response to response storage. 782 // 1. Write a large response to response storage.
788 // 2. Use net::URLRequest to retrieve it. 783 // 2. Use net::URLRequest to retrieve it.
789 // 3. Cancel the request after data starts coming in. 784 // 3. Cancel the request after data starts coming in.
790 785
791 PushNextTask(base::Bind( 786 PushNextTask(base::Bind(
792 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this))); 787 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this)));
793 PushNextTask(base::Bind( 788 PushNextTask(base::Bind(
794 &AppCacheURLRequestJobTest::RequestAppCachedResource, 789 &AppCacheURLRequestJobTest::RequestAppCachedResource,
795 base::Unretained(this), true)); 790 base::Unretained(this), true));
796 791
797 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); 792 writer_.reset(service_->storage()->CreateResponseWriter(GURL()));
798 written_response_id_ = writer_->response_id(); 793 written_response_id_ = writer_->response_id();
799 WriteLargeResponse(); 794 WriteLargeResponse();
800 795
801 url_request_delegate_->kill_after_amount_received_ = kBlockSize; 796 url_request_delegate_->kill_after_amount_received_ = kBlockSize;
802 url_request_delegate_->kill_with_io_pending_ = false; 797 url_request_delegate_->kill_with_io_pending_ = false;
803 // Continues async 798 // Continues async
804 } 799 }
805 800
806 void VerifyCancel() { 801 void VerifyCancel() {
807 EXPECT_EQ(net::URLRequestStatus::CANCELED, 802 EXPECT_EQ(net::URLRequestStatus::CANCELED,
808 request_->status().status()); 803 request_->status().status());
809 TestFinished(); 804 TestFinished();
810 } 805 }
811 806
812 // CancelRequestWithIOPending -------------------------------------- 807 // CancelRequestWithIOPending --------------------------------------
813 808
814 void CancelRequestWithIOPending() { 809 void CancelRequestWithIOPending() {
815 // This test has several async steps. 810 // This test has several async steps.
816 // 1. Write a large response to response storage. 811 // 1. Write a large response to response storage.
817 // 2. Use net::URLRequest to retrieve it. 812 // 2. Use net::URLRequest to retrieve it.
818 // 3. Cancel the request after data starts coming in. 813 // 3. Cancel the request after data starts coming in.
819 814
820 PushNextTask(base::Bind( 815 PushNextTask(base::Bind(
821 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this))); 816 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this)));
822 PushNextTask(base::Bind( 817 PushNextTask(base::Bind(
823 &AppCacheURLRequestJobTest::RequestAppCachedResource, 818 &AppCacheURLRequestJobTest::RequestAppCachedResource,
824 base::Unretained(this), true)); 819 base::Unretained(this), true));
825 820
826 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); 821 writer_.reset(service_->storage()->CreateResponseWriter(GURL()));
827 written_response_id_ = writer_->response_id(); 822 written_response_id_ = writer_->response_id();
828 WriteLargeResponse(); 823 WriteLargeResponse();
829 824
830 url_request_delegate_->kill_after_amount_received_ = kBlockSize; 825 url_request_delegate_->kill_after_amount_received_ = kBlockSize;
831 url_request_delegate_->kill_with_io_pending_ = true; 826 url_request_delegate_->kill_with_io_pending_ = true;
832 // Continues async 827 // Continues async
833 } 828 }
834 829
835 830
836 // Data members -------------------------------------------------------- 831 // Data members --------------------------------------------------------
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 891
897 TEST_F(AppCacheURLRequestJobTest, CancelRequest) { 892 TEST_F(AppCacheURLRequestJobTest, CancelRequest) {
898 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest); 893 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest);
899 } 894 }
900 895
901 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { 896 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) {
902 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); 897 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending);
903 } 898 }
904 899
905 } // namespace content 900 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job.cc ('k') | content/browser/appcache/mock_appcache_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698