OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 void RunTestOnIOThread(Method method) { | 610 void RunTestOnIOThread(Method method) { |
611 event_.reset(new base::WaitableEvent(false, false)); | 611 event_.reset(new base::WaitableEvent(false, false)); |
612 io_thread_->message_loop()->PostTask( | 612 io_thread_->message_loop()->PostTask( |
613 FROM_HERE, base::Bind(method, base::Unretained(this))); | 613 FROM_HERE, base::Bind(method, base::Unretained(this))); |
614 | 614 |
615 // Wait until task is done before exiting the test. | 615 // Wait until task is done before exiting the test. |
616 event_->Wait(); | 616 event_->Wait(); |
617 } | 617 } |
618 | 618 |
619 void StartCacheAttemptTest() { | 619 void StartCacheAttemptTest() { |
620 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 620 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
621 | 621 |
622 MakeService(); | 622 MakeService(); |
623 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), | 623 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), |
624 service_->storage()->NewGroupId()); | 624 service_->storage()->NewGroupId()); |
625 | 625 |
626 AppCacheUpdateJob* update = | 626 AppCacheUpdateJob* update = |
627 new AppCacheUpdateJob(service_.get(), group_.get()); | 627 new AppCacheUpdateJob(service_.get(), group_.get()); |
628 group_->update_job_ = update; | 628 group_->update_job_ = update; |
629 | 629 |
630 MockFrontend mock_frontend; | 630 MockFrontend mock_frontend; |
(...skipping 13 matching lines...) Expand all Loading... |
644 EXPECT_EQ(expected, events[0].first.size()); | 644 EXPECT_EQ(expected, events[0].first.size()); |
645 EXPECT_EQ(host.host_id(), events[0].first[0]); | 645 EXPECT_EQ(host.host_id(), events[0].first[0]); |
646 EXPECT_EQ(CHECKING_EVENT, events[0].second); | 646 EXPECT_EQ(CHECKING_EVENT, events[0].second); |
647 | 647 |
648 // Abort as we're not testing actual URL fetches in this test. | 648 // Abort as we're not testing actual URL fetches in this test. |
649 delete update; | 649 delete update; |
650 UpdateFinished(); | 650 UpdateFinished(); |
651 } | 651 } |
652 | 652 |
653 void StartUpgradeAttemptTest() { | 653 void StartUpgradeAttemptTest() { |
654 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 654 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
655 | 655 |
656 { | 656 { |
657 MakeService(); | 657 MakeService(); |
658 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), | 658 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), |
659 service_->storage()->NewGroupId()); | 659 service_->storage()->NewGroupId()); |
660 | 660 |
661 // Give the group some existing caches. | 661 // Give the group some existing caches. |
662 AppCache* cache1 = MakeCacheForGroup(1, 111); | 662 AppCache* cache1 = MakeCacheForGroup(1, 111); |
663 AppCache* cache2 = MakeCacheForGroup(2, 222); | 663 AppCache* cache2 = MakeCacheForGroup(2, 222); |
664 | 664 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 events = mock_frontend3.raised_events_; | 711 events = mock_frontend3.raised_events_; |
712 EXPECT_TRUE(events.empty()); | 712 EXPECT_TRUE(events.empty()); |
713 | 713 |
714 // Abort as we're not testing actual URL fetches in this test. | 714 // Abort as we're not testing actual URL fetches in this test. |
715 delete update; | 715 delete update; |
716 } | 716 } |
717 UpdateFinished(); | 717 UpdateFinished(); |
718 } | 718 } |
719 | 719 |
720 void CacheAttemptFetchManifestFailTest() { | 720 void CacheAttemptFetchManifestFailTest() { |
721 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 721 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
722 | 722 |
723 MakeService(); | 723 MakeService(); |
724 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), | 724 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), |
725 service_->storage()->NewGroupId()); | 725 service_->storage()->NewGroupId()); |
726 AppCacheUpdateJob* update = | 726 AppCacheUpdateJob* update = |
727 new AppCacheUpdateJob(service_.get(), group_.get()); | 727 new AppCacheUpdateJob(service_.get(), group_.get()); |
728 group_->update_job_ = update; | 728 group_->update_job_ = update; |
729 | 729 |
730 MockFrontend* frontend = MakeMockFrontend(); | 730 MockFrontend* frontend = MakeMockFrontend(); |
731 AppCacheHost* host = MakeHost(1, frontend); | 731 AppCacheHost* host = MakeHost(1, frontend); |
732 update->StartUpdate(host, GURL()); | 732 update->StartUpdate(host, GURL()); |
733 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 733 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
734 | 734 |
735 update->manifest_fetcher_->request()->CancelWithError(-100); | 735 update->manifest_fetcher_->request()->CancelWithError(-100); |
736 | 736 |
737 // Set up checks for when update job finishes. | 737 // Set up checks for when update job finishes. |
738 do_checks_after_update_finished_ = true; | 738 do_checks_after_update_finished_ = true; |
739 expect_group_obsolete_ = false; | 739 expect_group_obsolete_ = false; |
740 expect_group_has_cache_ = false; | 740 expect_group_has_cache_ = false; |
741 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 741 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
742 CHECKING_EVENT); | 742 CHECKING_EVENT); |
743 | 743 |
744 WaitForUpdateToFinish(); | 744 WaitForUpdateToFinish(); |
745 } | 745 } |
746 | 746 |
747 void UpgradeFetchManifestFailTest() { | 747 void UpgradeFetchManifestFailTest() { |
748 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 748 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
749 | 749 |
750 MakeService(); | 750 MakeService(); |
751 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), | 751 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), |
752 service_->storage()->NewGroupId()); | 752 service_->storage()->NewGroupId()); |
753 AppCacheUpdateJob* update = | 753 AppCacheUpdateJob* update = |
754 new AppCacheUpdateJob(service_.get(), group_.get()); | 754 new AppCacheUpdateJob(service_.get(), group_.get()); |
755 group_->update_job_ = update; | 755 group_->update_job_ = update; |
756 | 756 |
757 AppCache* cache = MakeCacheForGroup(1, 111); | 757 AppCache* cache = MakeCacheForGroup(1, 111); |
758 MockFrontend* frontend1 = MakeMockFrontend(); | 758 MockFrontend* frontend1 = MakeMockFrontend(); |
(...skipping 17 matching lines...) Expand all Loading... |
776 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); | 776 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); |
777 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); | 777 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); |
778 MockFrontend::HostIds ids2(1, host2->host_id()); | 778 MockFrontend::HostIds ids2(1, host2->host_id()); |
779 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 779 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
780 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 780 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
781 | 781 |
782 WaitForUpdateToFinish(); | 782 WaitForUpdateToFinish(); |
783 } | 783 } |
784 | 784 |
785 void ManifestRedirectTest() { | 785 void ManifestRedirectTest() { |
786 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 786 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
787 | 787 |
788 net::URLRequestJobFactoryImpl* new_factory( | 788 net::URLRequestJobFactoryImpl* new_factory( |
789 new net::URLRequestJobFactoryImpl); | 789 new net::URLRequestJobFactoryImpl); |
790 new_factory->SetProtocolHandler("http", new RedirectFactory); | 790 new_factory->SetProtocolHandler("http", new RedirectFactory); |
791 io_thread_->SetNewJobFactory(new_factory); | 791 io_thread_->SetNewJobFactory(new_factory); |
792 | 792 |
793 MakeService(); | 793 MakeService(); |
794 group_ = new AppCacheGroup(service_->storage(), GURL("http://testme"), | 794 group_ = new AppCacheGroup(service_->storage(), GURL("http://testme"), |
795 service_->storage()->NewGroupId()); | 795 service_->storage()->NewGroupId()); |
796 AppCacheUpdateJob* update = | 796 AppCacheUpdateJob* update = |
797 new AppCacheUpdateJob(service_.get(), group_.get()); | 797 new AppCacheUpdateJob(service_.get(), group_.get()); |
798 group_->update_job_ = update; | 798 group_->update_job_ = update; |
799 | 799 |
800 MockFrontend* frontend = MakeMockFrontend(); | 800 MockFrontend* frontend = MakeMockFrontend(); |
801 AppCacheHost* host = MakeHost(1, frontend); | 801 AppCacheHost* host = MakeHost(1, frontend); |
802 update->StartUpdate(host, GURL()); | 802 update->StartUpdate(host, GURL()); |
803 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 803 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
804 | 804 |
805 // Set up checks for when update job finishes. | 805 // Set up checks for when update job finishes. |
806 do_checks_after_update_finished_ = true; | 806 do_checks_after_update_finished_ = true; |
807 expect_group_obsolete_ = false; | 807 expect_group_obsolete_ = false; |
808 expect_group_has_cache_ = false; // redirect is like a failed request | 808 expect_group_has_cache_ = false; // redirect is like a failed request |
809 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 809 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
810 CHECKING_EVENT); | 810 CHECKING_EVENT); |
811 | 811 |
812 WaitForUpdateToFinish(); | 812 WaitForUpdateToFinish(); |
813 } | 813 } |
814 | 814 |
815 void ManifestMissingMimeTypeTest() { | 815 void ManifestMissingMimeTypeTest() { |
816 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 816 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
817 | 817 |
818 MakeService(); | 818 MakeService(); |
819 group_ = new AppCacheGroup( | 819 group_ = new AppCacheGroup( |
820 service_->storage(), | 820 service_->storage(), |
821 MockHttpServer::GetMockUrl("files/missing-mime-manifest"), | 821 MockHttpServer::GetMockUrl("files/missing-mime-manifest"), |
822 service_->storage()->NewGroupId()); | 822 service_->storage()->NewGroupId()); |
823 AppCacheUpdateJob* update = | 823 AppCacheUpdateJob* update = |
824 new AppCacheUpdateJob(service_.get(), group_.get()); | 824 new AppCacheUpdateJob(service_.get(), group_.get()); |
825 group_->update_job_ = update; | 825 group_->update_job_ = update; |
826 | 826 |
(...skipping 17 matching lines...) Expand all Loading... |
844 MockFrontend::HostIds ids(1, host->host_id()); | 844 MockFrontend::HostIds ids(1, host->host_id()); |
845 frontend->AddExpectedEvent(ids, CHECKING_EVENT); | 845 frontend->AddExpectedEvent(ids, CHECKING_EVENT); |
846 frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT); | 846 frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT); |
847 frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final | 847 frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final |
848 frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT); | 848 frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT); |
849 | 849 |
850 WaitForUpdateToFinish(); | 850 WaitForUpdateToFinish(); |
851 } | 851 } |
852 | 852 |
853 void ManifestNotFoundTest() { | 853 void ManifestNotFoundTest() { |
854 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 854 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
855 | 855 |
856 MakeService(); | 856 MakeService(); |
857 group_ = new AppCacheGroup( | 857 group_ = new AppCacheGroup( |
858 service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"), | 858 service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"), |
859 service_->storage()->NewGroupId()); | 859 service_->storage()->NewGroupId()); |
860 AppCacheUpdateJob* update = | 860 AppCacheUpdateJob* update = |
861 new AppCacheUpdateJob(service_.get(), group_.get()); | 861 new AppCacheUpdateJob(service_.get(), group_.get()); |
862 group_->update_job_ = update; | 862 group_->update_job_ = update; |
863 | 863 |
864 AppCache* cache = MakeCacheForGroup(1, 111); | 864 AppCache* cache = MakeCacheForGroup(1, 111); |
(...skipping 16 matching lines...) Expand all Loading... |
881 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); | 881 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); |
882 frontend1->AddExpectedEvent(ids1, OBSOLETE_EVENT); | 882 frontend1->AddExpectedEvent(ids1, OBSOLETE_EVENT); |
883 MockFrontend::HostIds ids2(1, host2->host_id()); | 883 MockFrontend::HostIds ids2(1, host2->host_id()); |
884 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 884 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
885 frontend2->AddExpectedEvent(ids2, OBSOLETE_EVENT); | 885 frontend2->AddExpectedEvent(ids2, OBSOLETE_EVENT); |
886 | 886 |
887 WaitForUpdateToFinish(); | 887 WaitForUpdateToFinish(); |
888 } | 888 } |
889 | 889 |
890 void ManifestGoneTest() { | 890 void ManifestGoneTest() { |
891 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 891 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
892 | 892 |
893 MakeService(); | 893 MakeService(); |
894 group_ = new AppCacheGroup( | 894 group_ = new AppCacheGroup( |
895 service_->storage(), MockHttpServer::GetMockUrl("files/gone"), | 895 service_->storage(), MockHttpServer::GetMockUrl("files/gone"), |
896 service_->storage()->NewGroupId()); | 896 service_->storage()->NewGroupId()); |
897 AppCacheUpdateJob* update = | 897 AppCacheUpdateJob* update = |
898 new AppCacheUpdateJob(service_.get(), group_.get()); | 898 new AppCacheUpdateJob(service_.get(), group_.get()); |
899 group_->update_job_ = update; | 899 group_->update_job_ = update; |
900 | 900 |
901 MockFrontend* frontend = MakeMockFrontend(); | 901 MockFrontend* frontend = MakeMockFrontend(); |
902 AppCacheHost* host = MakeHost(1, frontend); | 902 AppCacheHost* host = MakeHost(1, frontend); |
903 update->StartUpdate(host, GURL()); | 903 update->StartUpdate(host, GURL()); |
904 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 904 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
905 | 905 |
906 // Set up checks for when update job finishes. | 906 // Set up checks for when update job finishes. |
907 do_checks_after_update_finished_ = true; | 907 do_checks_after_update_finished_ = true; |
908 expect_group_obsolete_ = false; | 908 expect_group_obsolete_ = false; |
909 expect_group_has_cache_ = false; | 909 expect_group_has_cache_ = false; |
910 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 910 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
911 CHECKING_EVENT); | 911 CHECKING_EVENT); |
912 | 912 |
913 WaitForUpdateToFinish(); | 913 WaitForUpdateToFinish(); |
914 } | 914 } |
915 | 915 |
916 void CacheAttemptNotModifiedTest() { | 916 void CacheAttemptNotModifiedTest() { |
917 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 917 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
918 | 918 |
919 MakeService(); | 919 MakeService(); |
920 group_ = new AppCacheGroup( | 920 group_ = new AppCacheGroup( |
921 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), | 921 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), |
922 service_->storage()->NewGroupId()); | 922 service_->storage()->NewGroupId()); |
923 AppCacheUpdateJob* update = | 923 AppCacheUpdateJob* update = |
924 new AppCacheUpdateJob(service_.get(), group_.get()); | 924 new AppCacheUpdateJob(service_.get(), group_.get()); |
925 group_->update_job_ = update; | 925 group_->update_job_ = update; |
926 | 926 |
927 MockFrontend* frontend = MakeMockFrontend(); | 927 MockFrontend* frontend = MakeMockFrontend(); |
928 AppCacheHost* host = MakeHost(1, frontend); | 928 AppCacheHost* host = MakeHost(1, frontend); |
929 update->StartUpdate(host, GURL()); | 929 update->StartUpdate(host, GURL()); |
930 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 930 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
931 | 931 |
932 // Set up checks for when update job finishes. | 932 // Set up checks for when update job finishes. |
933 do_checks_after_update_finished_ = true; | 933 do_checks_after_update_finished_ = true; |
934 expect_group_obsolete_ = false; | 934 expect_group_obsolete_ = false; |
935 expect_group_has_cache_ = false; // treated like cache failure | 935 expect_group_has_cache_ = false; // treated like cache failure |
936 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 936 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
937 CHECKING_EVENT); | 937 CHECKING_EVENT); |
938 | 938 |
939 WaitForUpdateToFinish(); | 939 WaitForUpdateToFinish(); |
940 } | 940 } |
941 | 941 |
942 void UpgradeNotModifiedTest() { | 942 void UpgradeNotModifiedTest() { |
943 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 943 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
944 | 944 |
945 MakeService(); | 945 MakeService(); |
946 group_ = new AppCacheGroup( | 946 group_ = new AppCacheGroup( |
947 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), | 947 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), |
948 service_->storage()->NewGroupId()); | 948 service_->storage()->NewGroupId()); |
949 AppCacheUpdateJob* update = | 949 AppCacheUpdateJob* update = |
950 new AppCacheUpdateJob(service_.get(), group_.get()); | 950 new AppCacheUpdateJob(service_.get(), group_.get()); |
951 group_->update_job_ = update; | 951 group_->update_job_ = update; |
952 | 952 |
953 AppCache* cache = MakeCacheForGroup(1, 111); | 953 AppCache* cache = MakeCacheForGroup(1, 111); |
(...skipping 16 matching lines...) Expand all Loading... |
970 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); | 970 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); |
971 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT); | 971 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT); |
972 MockFrontend::HostIds ids2(1, host2->host_id()); | 972 MockFrontend::HostIds ids2(1, host2->host_id()); |
973 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 973 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
974 frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT); | 974 frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT); |
975 | 975 |
976 WaitForUpdateToFinish(); | 976 WaitForUpdateToFinish(); |
977 } | 977 } |
978 | 978 |
979 void UpgradeManifestDataUnchangedTest() { | 979 void UpgradeManifestDataUnchangedTest() { |
980 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 980 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
981 | 981 |
982 MakeService(); | 982 MakeService(); |
983 group_ = new AppCacheGroup( | 983 group_ = new AppCacheGroup( |
984 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 984 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
985 service_->storage()->NewGroupId()); | 985 service_->storage()->NewGroupId()); |
986 AppCacheUpdateJob* update = | 986 AppCacheUpdateJob* update = |
987 new AppCacheUpdateJob(service_.get(), group_.get()); | 987 new AppCacheUpdateJob(service_.get(), group_.get()); |
988 group_->update_job_ = update; | 988 group_->update_job_ = update; |
989 | 989 |
990 // Create response writer to get a response id. | 990 // Create response writer to get a response id. |
(...skipping 29 matching lines...) Expand all Loading... |
1020 io_buffer.get(), | 1020 io_buffer.get(), |
1021 seed_data.length(), | 1021 seed_data.length(), |
1022 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 1022 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
1023 base::Unretained(this))); | 1023 base::Unretained(this))); |
1024 | 1024 |
1025 // Start update after data write completes asynchronously. | 1025 // Start update after data write completes asynchronously. |
1026 } | 1026 } |
1027 | 1027 |
1028 // See http://code.google.com/p/chromium/issues/detail?id=95101 | 1028 // See http://code.google.com/p/chromium/issues/detail?id=95101 |
1029 void Bug95101Test() { | 1029 void Bug95101Test() { |
1030 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1030 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1031 | 1031 |
1032 MakeService(); | 1032 MakeService(); |
1033 group_ = new AppCacheGroup( | 1033 group_ = new AppCacheGroup( |
1034 service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"), | 1034 service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"), |
1035 service_->storage()->NewGroupId()); | 1035 service_->storage()->NewGroupId()); |
1036 AppCacheUpdateJob* update = | 1036 AppCacheUpdateJob* update = |
1037 new AppCacheUpdateJob(service_.get(), group_.get()); | 1037 new AppCacheUpdateJob(service_.get(), group_.get()); |
1038 group_->update_job_ = update; | 1038 group_->update_job_ = update; |
1039 | 1039 |
1040 // Create a malformed cache with a missing manifest entry. | 1040 // Create a malformed cache with a missing manifest entry. |
(...skipping 25 matching lines...) Expand all Loading... |
1066 response_writer_.reset(); | 1066 response_writer_.reset(); |
1067 | 1067 |
1068 AppCacheUpdateJob* update = group_->update_job_; | 1068 AppCacheUpdateJob* update = group_->update_job_; |
1069 update->StartUpdate(NULL, GURL()); | 1069 update->StartUpdate(NULL, GURL()); |
1070 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 1070 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
1071 | 1071 |
1072 WaitForUpdateToFinish(); | 1072 WaitForUpdateToFinish(); |
1073 } | 1073 } |
1074 | 1074 |
1075 void BasicCacheAttemptSuccessTest() { | 1075 void BasicCacheAttemptSuccessTest() { |
1076 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1076 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1077 | 1077 |
1078 GURL manifest_url = MockHttpServer::GetMockUrl("files/manifest1"); | 1078 GURL manifest_url = MockHttpServer::GetMockUrl("files/manifest1"); |
1079 | 1079 |
1080 MakeService(); | 1080 MakeService(); |
1081 group_ = new AppCacheGroup( | 1081 group_ = new AppCacheGroup( |
1082 service_->storage(), manifest_url, | 1082 service_->storage(), manifest_url, |
1083 service_->storage()->NewGroupId()); | 1083 service_->storage()->NewGroupId()); |
1084 AppCacheUpdateJob* update = | 1084 AppCacheUpdateJob* update = |
1085 new AppCacheUpdateJob(service_.get(), group_.get()); | 1085 new AppCacheUpdateJob(service_.get(), group_.get()); |
1086 group_->update_job_ = update; | 1086 group_->update_job_ = update; |
1087 | 1087 |
1088 MockFrontend* frontend = MakeMockFrontend(); | 1088 MockFrontend* frontend = MakeMockFrontend(); |
1089 AppCacheHost* host = MakeHost(1, frontend); | 1089 AppCacheHost* host = MakeHost(1, frontend); |
1090 update->StartUpdate(host, GURL()); | 1090 update->StartUpdate(host, GURL()); |
1091 | 1091 |
1092 // Set up checks for when update job finishes. | 1092 // Set up checks for when update job finishes. |
1093 do_checks_after_update_finished_ = true; | 1093 do_checks_after_update_finished_ = true; |
1094 expect_group_obsolete_ = false; | 1094 expect_group_obsolete_ = false; |
1095 expect_group_has_cache_ = true; | 1095 expect_group_has_cache_ = true; |
1096 tested_manifest_ = MANIFEST1; | 1096 tested_manifest_ = MANIFEST1; |
1097 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1097 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1098 CHECKING_EVENT); | 1098 CHECKING_EVENT); |
1099 | 1099 |
1100 WaitForUpdateToFinish(); | 1100 WaitForUpdateToFinish(); |
1101 } | 1101 } |
1102 | 1102 |
1103 void DownloadInterceptEntriesTest() { | 1103 void DownloadInterceptEntriesTest() { |
1104 // Ensures we download intercept entries too. | 1104 // Ensures we download intercept entries too. |
1105 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1105 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1106 GURL manifest_url = | 1106 GURL manifest_url = |
1107 MockHttpServer::GetMockUrl("files/manifest-with-intercept"); | 1107 MockHttpServer::GetMockUrl("files/manifest-with-intercept"); |
1108 MakeService(); | 1108 MakeService(); |
1109 group_ = new AppCacheGroup( | 1109 group_ = new AppCacheGroup( |
1110 service_->storage(), manifest_url, | 1110 service_->storage(), manifest_url, |
1111 service_->storage()->NewGroupId()); | 1111 service_->storage()->NewGroupId()); |
1112 AppCacheUpdateJob* update = | 1112 AppCacheUpdateJob* update = |
1113 new AppCacheUpdateJob(service_.get(), group_.get()); | 1113 new AppCacheUpdateJob(service_.get(), group_.get()); |
1114 group_->update_job_ = update; | 1114 group_->update_job_ = update; |
1115 | 1115 |
1116 MockFrontend* frontend = MakeMockFrontend(); | 1116 MockFrontend* frontend = MakeMockFrontend(); |
1117 AppCacheHost* host = MakeHost(1, frontend); | 1117 AppCacheHost* host = MakeHost(1, frontend); |
1118 update->StartUpdate(host, GURL()); | 1118 update->StartUpdate(host, GURL()); |
1119 | 1119 |
1120 // Set up checks for when update job finishes. | 1120 // Set up checks for when update job finishes. |
1121 do_checks_after_update_finished_ = true; | 1121 do_checks_after_update_finished_ = true; |
1122 expect_group_obsolete_ = false; | 1122 expect_group_obsolete_ = false; |
1123 expect_group_has_cache_ = true; | 1123 expect_group_has_cache_ = true; |
1124 tested_manifest_ = MANIFEST_WITH_INTERCEPT; | 1124 tested_manifest_ = MANIFEST_WITH_INTERCEPT; |
1125 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1125 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1126 CHECKING_EVENT); | 1126 CHECKING_EVENT); |
1127 | 1127 |
1128 WaitForUpdateToFinish(); | 1128 WaitForUpdateToFinish(); |
1129 } | 1129 } |
1130 | 1130 |
1131 void BasicUpgradeSuccessTest() { | 1131 void BasicUpgradeSuccessTest() { |
1132 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1132 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1133 | 1133 |
1134 MakeService(); | 1134 MakeService(); |
1135 group_ = new AppCacheGroup( | 1135 group_ = new AppCacheGroup( |
1136 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1136 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1137 service_->storage()->NewGroupId()); | 1137 service_->storage()->NewGroupId()); |
1138 AppCacheUpdateJob* update = | 1138 AppCacheUpdateJob* update = |
1139 new AppCacheUpdateJob(service_.get(), group_.get()); | 1139 new AppCacheUpdateJob(service_.get(), group_.get()); |
1140 group_->update_job_ = update; | 1140 group_->update_job_ = update; |
1141 | 1141 |
1142 // Create a response writer to get a response id. | 1142 // Create a response writer to get a response id. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 response_writer_->WriteData( | 1183 response_writer_->WriteData( |
1184 io_buffer.get(), | 1184 io_buffer.get(), |
1185 seed_data.length(), | 1185 seed_data.length(), |
1186 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 1186 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
1187 base::Unretained(this))); | 1187 base::Unretained(this))); |
1188 | 1188 |
1189 // Start update after data write completes asynchronously. | 1189 // Start update after data write completes asynchronously. |
1190 } | 1190 } |
1191 | 1191 |
1192 void UpgradeLoadFromNewestCacheTest() { | 1192 void UpgradeLoadFromNewestCacheTest() { |
1193 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1193 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1194 | 1194 |
1195 MakeService(); | 1195 MakeService(); |
1196 group_ = new AppCacheGroup( | 1196 group_ = new AppCacheGroup( |
1197 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1197 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1198 service_->storage()->NewGroupId()); | 1198 service_->storage()->NewGroupId()); |
1199 AppCacheUpdateJob* update = | 1199 AppCacheUpdateJob* update = |
1200 new AppCacheUpdateJob(service_.get(), group_.get()); | 1200 new AppCacheUpdateJob(service_.get(), group_.get()); |
1201 group_->update_job_ = update; | 1201 group_->update_job_ = update; |
1202 | 1202 |
1203 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); | 1203 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info | 1246 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1247 response_writer_->WriteInfo( | 1247 response_writer_->WriteInfo( |
1248 io_buffer.get(), | 1248 io_buffer.get(), |
1249 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 1249 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
1250 base::Unretained(this))); | 1250 base::Unretained(this))); |
1251 | 1251 |
1252 // Start update after data write completes asynchronously. | 1252 // Start update after data write completes asynchronously. |
1253 } | 1253 } |
1254 | 1254 |
1255 void UpgradeNoLoadFromNewestCacheTest() { | 1255 void UpgradeNoLoadFromNewestCacheTest() { |
1256 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1256 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1257 | 1257 |
1258 MakeService(); | 1258 MakeService(); |
1259 group_ = new AppCacheGroup( | 1259 group_ = new AppCacheGroup( |
1260 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1260 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1261 service_->storage()->NewGroupId()); | 1261 service_->storage()->NewGroupId()); |
1262 AppCacheUpdateJob* update = | 1262 AppCacheUpdateJob* update = |
1263 new AppCacheUpdateJob(service_.get(), group_.get()); | 1263 new AppCacheUpdateJob(service_.get(), group_.get()); |
1264 group_->update_job_ = update; | 1264 group_->update_job_ = update; |
1265 | 1265 |
1266 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); | 1266 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info | 1306 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1307 response_writer_->WriteInfo( | 1307 response_writer_->WriteInfo( |
1308 io_buffer.get(), | 1308 io_buffer.get(), |
1309 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 1309 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
1310 base::Unretained(this))); | 1310 base::Unretained(this))); |
1311 | 1311 |
1312 // Start update after data write completes asynchronously. | 1312 // Start update after data write completes asynchronously. |
1313 } | 1313 } |
1314 | 1314 |
1315 void UpgradeLoadFromNewestCacheVaryHeaderTest() { | 1315 void UpgradeLoadFromNewestCacheVaryHeaderTest() { |
1316 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1316 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1317 | 1317 |
1318 MakeService(); | 1318 MakeService(); |
1319 group_ = new AppCacheGroup( | 1319 group_ = new AppCacheGroup( |
1320 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1320 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1321 service_->storage()->NewGroupId()); | 1321 service_->storage()->NewGroupId()); |
1322 AppCacheUpdateJob* update = | 1322 AppCacheUpdateJob* update = |
1323 new AppCacheUpdateJob(service_.get(), group_.get()); | 1323 new AppCacheUpdateJob(service_.get(), group_.get()); |
1324 group_->update_job_ = update; | 1324 group_->update_job_ = update; |
1325 | 1325 |
1326 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); | 1326 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info | 1366 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1367 response_writer_->WriteInfo( | 1367 response_writer_->WriteInfo( |
1368 io_buffer.get(), | 1368 io_buffer.get(), |
1369 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 1369 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
1370 base::Unretained(this))); | 1370 base::Unretained(this))); |
1371 | 1371 |
1372 // Start update after data write completes asynchronously. | 1372 // Start update after data write completes asynchronously. |
1373 } | 1373 } |
1374 | 1374 |
1375 void UpgradeSuccessMergedTypesTest() { | 1375 void UpgradeSuccessMergedTypesTest() { |
1376 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1376 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1377 | 1377 |
1378 MakeService(); | 1378 MakeService(); |
1379 group_ = new AppCacheGroup(service_->storage(), | 1379 group_ = new AppCacheGroup(service_->storage(), |
1380 MockHttpServer::GetMockUrl("files/manifest-merged-types"), | 1380 MockHttpServer::GetMockUrl("files/manifest-merged-types"), |
1381 service_->storage()->NewGroupId()); | 1381 service_->storage()->NewGroupId()); |
1382 AppCacheUpdateJob* update = | 1382 AppCacheUpdateJob* update = |
1383 new AppCacheUpdateJob(service_.get(), group_.get()); | 1383 new AppCacheUpdateJob(service_.get(), group_.get()); |
1384 group_->update_job_ = update; | 1384 group_->update_job_ = update; |
1385 | 1385 |
1386 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); | 1386 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); |
(...skipping 30 matching lines...) Expand all Loading... |
1417 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 1417 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
1418 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1418 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1419 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1419 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1420 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final | 1420 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final |
1421 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); | 1421 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); |
1422 | 1422 |
1423 WaitForUpdateToFinish(); | 1423 WaitForUpdateToFinish(); |
1424 } | 1424 } |
1425 | 1425 |
1426 void CacheAttemptFailUrlFetchTest() { | 1426 void CacheAttemptFailUrlFetchTest() { |
1427 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1427 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1428 | 1428 |
1429 MakeService(); | 1429 MakeService(); |
1430 group_ = new AppCacheGroup(service_->storage(), | 1430 group_ = new AppCacheGroup(service_->storage(), |
1431 MockHttpServer::GetMockUrl("files/manifest-with-404"), | 1431 MockHttpServer::GetMockUrl("files/manifest-with-404"), |
1432 service_->storage()->NewGroupId()); | 1432 service_->storage()->NewGroupId()); |
1433 AppCacheUpdateJob* update = | 1433 AppCacheUpdateJob* update = |
1434 new AppCacheUpdateJob(service_.get(), group_.get()); | 1434 new AppCacheUpdateJob(service_.get(), group_.get()); |
1435 group_->update_job_ = update; | 1435 group_->update_job_ = update; |
1436 | 1436 |
1437 MockFrontend* frontend = MakeMockFrontend(); | 1437 MockFrontend* frontend = MakeMockFrontend(); |
1438 AppCacheHost* host = MakeHost(1, frontend); | 1438 AppCacheHost* host = MakeHost(1, frontend); |
1439 update->StartUpdate(host, GURL()); | 1439 update->StartUpdate(host, GURL()); |
1440 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 1440 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
1441 | 1441 |
1442 // Set up checks for when update job finishes. | 1442 // Set up checks for when update job finishes. |
1443 do_checks_after_update_finished_ = true; | 1443 do_checks_after_update_finished_ = true; |
1444 expect_group_obsolete_ = false; | 1444 expect_group_obsolete_ = false; |
1445 expect_group_has_cache_ = false; // 404 explicit url is cache failure | 1445 expect_group_has_cache_ = false; // 404 explicit url is cache failure |
1446 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1446 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1447 CHECKING_EVENT); | 1447 CHECKING_EVENT); |
1448 | 1448 |
1449 WaitForUpdateToFinish(); | 1449 WaitForUpdateToFinish(); |
1450 } | 1450 } |
1451 | 1451 |
1452 void UpgradeFailUrlFetchTest() { | 1452 void UpgradeFailUrlFetchTest() { |
1453 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1453 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1454 | 1454 |
1455 MakeService(); | 1455 MakeService(); |
1456 group_ = new AppCacheGroup(service_->storage(), | 1456 group_ = new AppCacheGroup(service_->storage(), |
1457 MockHttpServer::GetMockUrl("files/manifest-fb-404"), | 1457 MockHttpServer::GetMockUrl("files/manifest-fb-404"), |
1458 service_->storage()->NewGroupId()); | 1458 service_->storage()->NewGroupId()); |
1459 AppCacheUpdateJob* update = | 1459 AppCacheUpdateJob* update = |
1460 new AppCacheUpdateJob(service_.get(), group_.get()); | 1460 new AppCacheUpdateJob(service_.get(), group_.get()); |
1461 group_->update_job_ = update; | 1461 group_->update_job_ = update; |
1462 | 1462 |
1463 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 99); | 1463 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 99); |
(...skipping 20 matching lines...) Expand all Loading... |
1484 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); | 1484 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); |
1485 MockFrontend::HostIds ids2(1, host2->host_id()); | 1485 MockFrontend::HostIds ids2(1, host2->host_id()); |
1486 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 1486 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
1487 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 1487 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
1488 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 1488 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
1489 | 1489 |
1490 WaitForUpdateToFinish(); | 1490 WaitForUpdateToFinish(); |
1491 } | 1491 } |
1492 | 1492 |
1493 void UpgradeFailMasterUrlFetchTest() { | 1493 void UpgradeFailMasterUrlFetchTest() { |
1494 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1494 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1495 | 1495 |
1496 tested_manifest_path_override_ = "files/manifest1-with-notmodified"; | 1496 tested_manifest_path_override_ = "files/manifest1-with-notmodified"; |
1497 | 1497 |
1498 MakeService(); | 1498 MakeService(); |
1499 const GURL kManifestUrl = | 1499 const GURL kManifestUrl = |
1500 MockHttpServer::GetMockUrl(tested_manifest_path_override_); | 1500 MockHttpServer::GetMockUrl(tested_manifest_path_override_); |
1501 group_ = new AppCacheGroup( | 1501 group_ = new AppCacheGroup( |
1502 service_->storage(), kManifestUrl, | 1502 service_->storage(), kManifestUrl, |
1503 service_->storage()->NewGroupId()); | 1503 service_->storage()->NewGroupId()); |
1504 AppCacheUpdateJob* update = | 1504 AppCacheUpdateJob* update = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // explicit2 | 1580 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // explicit2 |
1581 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // servererror | 1581 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // servererror |
1582 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // notmodified | 1582 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // notmodified |
1583 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final | 1583 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final |
1584 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); | 1584 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); |
1585 | 1585 |
1586 WaitForUpdateToFinish(); | 1586 WaitForUpdateToFinish(); |
1587 } | 1587 } |
1588 | 1588 |
1589 void EmptyManifestTest() { | 1589 void EmptyManifestTest() { |
1590 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1590 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1591 | 1591 |
1592 MakeService(); | 1592 MakeService(); |
1593 group_ = new AppCacheGroup( | 1593 group_ = new AppCacheGroup( |
1594 service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"), | 1594 service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"), |
1595 service_->storage()->NewGroupId()); | 1595 service_->storage()->NewGroupId()); |
1596 AppCacheUpdateJob* update = | 1596 AppCacheUpdateJob* update = |
1597 new AppCacheUpdateJob(service_.get(), group_.get()); | 1597 new AppCacheUpdateJob(service_.get(), group_.get()); |
1598 group_->update_job_ = update; | 1598 group_->update_job_ = update; |
1599 | 1599 |
1600 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33); | 1600 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33); |
(...skipping 23 matching lines...) Expand all Loading... |
1624 MockFrontend::HostIds ids2(1, host2->host_id()); | 1624 MockFrontend::HostIds ids2(1, host2->host_id()); |
1625 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 1625 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
1626 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 1626 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
1627 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final | 1627 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final |
1628 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); | 1628 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); |
1629 | 1629 |
1630 WaitForUpdateToFinish(); | 1630 WaitForUpdateToFinish(); |
1631 } | 1631 } |
1632 | 1632 |
1633 void EmptyFileTest() { | 1633 void EmptyFileTest() { |
1634 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1634 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1635 | 1635 |
1636 MakeService(); | 1636 MakeService(); |
1637 group_ = new AppCacheGroup(service_->storage(), | 1637 group_ = new AppCacheGroup(service_->storage(), |
1638 MockHttpServer::GetMockUrl("files/empty-file-manifest"), | 1638 MockHttpServer::GetMockUrl("files/empty-file-manifest"), |
1639 service_->storage()->NewGroupId()); | 1639 service_->storage()->NewGroupId()); |
1640 AppCacheUpdateJob* update = | 1640 AppCacheUpdateJob* update = |
1641 new AppCacheUpdateJob(service_.get(), group_.get()); | 1641 new AppCacheUpdateJob(service_.get(), group_.get()); |
1642 group_->update_job_ = update; | 1642 group_->update_job_ = update; |
1643 | 1643 |
1644 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 22); | 1644 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 22); |
(...skipping 14 matching lines...) Expand all Loading... |
1659 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); | 1659 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); |
1660 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT); | 1660 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT); |
1661 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); | 1661 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); |
1662 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final | 1662 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final |
1663 frontend->AddExpectedEvent(ids1, UPDATE_READY_EVENT); | 1663 frontend->AddExpectedEvent(ids1, UPDATE_READY_EVENT); |
1664 | 1664 |
1665 WaitForUpdateToFinish(); | 1665 WaitForUpdateToFinish(); |
1666 } | 1666 } |
1667 | 1667 |
1668 void RetryRequestTest() { | 1668 void RetryRequestTest() { |
1669 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1669 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1670 | 1670 |
1671 // Set some large number of times to return retry. | 1671 // Set some large number of times to return retry. |
1672 // Expect 1 manifest fetch and 3 retries. | 1672 // Expect 1 manifest fetch and 3 retries. |
1673 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4); | 1673 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4); |
1674 net::URLRequestJobFactoryImpl* new_factory( | 1674 net::URLRequestJobFactoryImpl* new_factory( |
1675 new net::URLRequestJobFactoryImpl); | 1675 new net::URLRequestJobFactoryImpl); |
1676 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); | 1676 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); |
1677 io_thread_->SetNewJobFactory(new_factory); | 1677 io_thread_->SetNewJobFactory(new_factory); |
1678 | 1678 |
1679 MakeService(); | 1679 MakeService(); |
(...skipping 13 matching lines...) Expand all Loading... |
1693 do_checks_after_update_finished_ = true; | 1693 do_checks_after_update_finished_ = true; |
1694 expect_group_obsolete_ = false; | 1694 expect_group_obsolete_ = false; |
1695 expect_group_has_cache_ = false; | 1695 expect_group_has_cache_ = false; |
1696 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1696 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1697 CHECKING_EVENT); | 1697 CHECKING_EVENT); |
1698 | 1698 |
1699 WaitForUpdateToFinish(); | 1699 WaitForUpdateToFinish(); |
1700 } | 1700 } |
1701 | 1701 |
1702 void RetryNoRetryAfterTest() { | 1702 void RetryNoRetryAfterTest() { |
1703 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1703 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1704 | 1704 |
1705 // Set some large number of times to return retry. | 1705 // Set some large number of times to return retry. |
1706 // Expect 1 manifest fetch and 0 retries. | 1706 // Expect 1 manifest fetch and 0 retries. |
1707 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1); | 1707 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1); |
1708 net::URLRequestJobFactoryImpl* new_factory( | 1708 net::URLRequestJobFactoryImpl* new_factory( |
1709 new net::URLRequestJobFactoryImpl); | 1709 new net::URLRequestJobFactoryImpl); |
1710 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); | 1710 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); |
1711 io_thread_->SetNewJobFactory(new_factory); | 1711 io_thread_->SetNewJobFactory(new_factory); |
1712 | 1712 |
1713 MakeService(); | 1713 MakeService(); |
(...skipping 13 matching lines...) Expand all Loading... |
1727 do_checks_after_update_finished_ = true; | 1727 do_checks_after_update_finished_ = true; |
1728 expect_group_obsolete_ = false; | 1728 expect_group_obsolete_ = false; |
1729 expect_group_has_cache_ = false; | 1729 expect_group_has_cache_ = false; |
1730 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1730 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1731 CHECKING_EVENT); | 1731 CHECKING_EVENT); |
1732 | 1732 |
1733 WaitForUpdateToFinish(); | 1733 WaitForUpdateToFinish(); |
1734 } | 1734 } |
1735 | 1735 |
1736 void RetryNonzeroRetryAfterTest() { | 1736 void RetryNonzeroRetryAfterTest() { |
1737 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1737 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1738 | 1738 |
1739 // Set some large number of times to return retry. | 1739 // Set some large number of times to return retry. |
1740 // Expect 1 request and 0 retry attempts. | 1740 // Expect 1 request and 0 retry attempts. |
1741 RetryRequestTestJob::Initialize( | 1741 RetryRequestTestJob::Initialize( |
1742 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1); | 1742 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1); |
1743 net::URLRequestJobFactoryImpl* new_factory( | 1743 net::URLRequestJobFactoryImpl* new_factory( |
1744 new net::URLRequestJobFactoryImpl); | 1744 new net::URLRequestJobFactoryImpl); |
1745 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); | 1745 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); |
1746 io_thread_->SetNewJobFactory(new_factory); | 1746 io_thread_->SetNewJobFactory(new_factory); |
1747 | 1747 |
(...skipping 14 matching lines...) Expand all Loading... |
1762 do_checks_after_update_finished_ = true; | 1762 do_checks_after_update_finished_ = true; |
1763 expect_group_obsolete_ = false; | 1763 expect_group_obsolete_ = false; |
1764 expect_group_has_cache_ = false; | 1764 expect_group_has_cache_ = false; |
1765 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1765 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1766 CHECKING_EVENT); | 1766 CHECKING_EVENT); |
1767 | 1767 |
1768 WaitForUpdateToFinish(); | 1768 WaitForUpdateToFinish(); |
1769 } | 1769 } |
1770 | 1770 |
1771 void RetrySuccessTest() { | 1771 void RetrySuccessTest() { |
1772 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1772 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1773 | 1773 |
1774 // Set 2 as the retry limit (does not exceed the max). | 1774 // Set 2 as the retry limit (does not exceed the max). |
1775 // Expect 1 manifest fetch, 2 retries, 1 url fetch, 1 manifest refetch. | 1775 // Expect 1 manifest fetch, 2 retries, 1 url fetch, 1 manifest refetch. |
1776 RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5); | 1776 RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5); |
1777 net::URLRequestJobFactoryImpl* new_factory( | 1777 net::URLRequestJobFactoryImpl* new_factory( |
1778 new net::URLRequestJobFactoryImpl); | 1778 new net::URLRequestJobFactoryImpl); |
1779 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); | 1779 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); |
1780 io_thread_->SetNewJobFactory(new_factory); | 1780 io_thread_->SetNewJobFactory(new_factory); |
1781 | 1781 |
1782 MakeService(); | 1782 MakeService(); |
(...skipping 13 matching lines...) Expand all Loading... |
1796 do_checks_after_update_finished_ = true; | 1796 do_checks_after_update_finished_ = true; |
1797 expect_group_obsolete_ = false; | 1797 expect_group_obsolete_ = false; |
1798 expect_group_has_cache_ = true; | 1798 expect_group_has_cache_ = true; |
1799 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1799 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1800 CHECKING_EVENT); | 1800 CHECKING_EVENT); |
1801 | 1801 |
1802 WaitForUpdateToFinish(); | 1802 WaitForUpdateToFinish(); |
1803 } | 1803 } |
1804 | 1804 |
1805 void RetryUrlTest() { | 1805 void RetryUrlTest() { |
1806 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1806 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1807 | 1807 |
1808 // Set 1 as the retry limit (does not exceed the max). | 1808 // Set 1 as the retry limit (does not exceed the max). |
1809 // Expect 1 manifest fetch, 1 url fetch, 1 url retry, 1 manifest refetch. | 1809 // Expect 1 manifest fetch, 1 url fetch, 1 url retry, 1 manifest refetch. |
1810 RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4); | 1810 RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4); |
1811 net::URLRequestJobFactoryImpl* new_factory( | 1811 net::URLRequestJobFactoryImpl* new_factory( |
1812 new net::URLRequestJobFactoryImpl); | 1812 new net::URLRequestJobFactoryImpl); |
1813 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); | 1813 new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); |
1814 io_thread_->SetNewJobFactory(new_factory); | 1814 io_thread_->SetNewJobFactory(new_factory); |
1815 | 1815 |
1816 MakeService(); | 1816 MakeService(); |
(...skipping 12 matching lines...) Expand all Loading... |
1829 do_checks_after_update_finished_ = true; | 1829 do_checks_after_update_finished_ = true; |
1830 expect_group_obsolete_ = false; | 1830 expect_group_obsolete_ = false; |
1831 expect_group_has_cache_ = true; | 1831 expect_group_has_cache_ = true; |
1832 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1832 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1833 CHECKING_EVENT); | 1833 CHECKING_EVENT); |
1834 | 1834 |
1835 WaitForUpdateToFinish(); | 1835 WaitForUpdateToFinish(); |
1836 } | 1836 } |
1837 | 1837 |
1838 void FailStoreNewestCacheTest() { | 1838 void FailStoreNewestCacheTest() { |
1839 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1839 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1840 | 1840 |
1841 MakeService(); | 1841 MakeService(); |
1842 MockAppCacheStorage* storage = | 1842 MockAppCacheStorage* storage = |
1843 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); | 1843 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); |
1844 storage->SimulateStoreGroupAndNewestCacheFailure(); | 1844 storage->SimulateStoreGroupAndNewestCacheFailure(); |
1845 | 1845 |
1846 group_ = new AppCacheGroup( | 1846 group_ = new AppCacheGroup( |
1847 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1847 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1848 service_->storage()->NewGroupId()); | 1848 service_->storage()->NewGroupId()); |
1849 AppCacheUpdateJob* update = | 1849 AppCacheUpdateJob* update = |
1850 new AppCacheUpdateJob(service_.get(), group_.get()); | 1850 new AppCacheUpdateJob(service_.get(), group_.get()); |
1851 group_->update_job_ = update; | 1851 group_->update_job_ = update; |
1852 | 1852 |
1853 MockFrontend* frontend = MakeMockFrontend(); | 1853 MockFrontend* frontend = MakeMockFrontend(); |
1854 AppCacheHost* host = MakeHost(1, frontend); | 1854 AppCacheHost* host = MakeHost(1, frontend); |
1855 update->StartUpdate(host, GURL()); | 1855 update->StartUpdate(host, GURL()); |
1856 | 1856 |
1857 // Set up checks for when update job finishes. | 1857 // Set up checks for when update job finishes. |
1858 do_checks_after_update_finished_ = true; | 1858 do_checks_after_update_finished_ = true; |
1859 expect_group_obsolete_ = false; | 1859 expect_group_obsolete_ = false; |
1860 expect_group_has_cache_ = false; // storage failed | 1860 expect_group_has_cache_ = false; // storage failed |
1861 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 1861 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1862 CHECKING_EVENT); | 1862 CHECKING_EVENT); |
1863 | 1863 |
1864 WaitForUpdateToFinish(); | 1864 WaitForUpdateToFinish(); |
1865 } | 1865 } |
1866 | 1866 |
1867 void UpgradeFailStoreNewestCacheTest() { | 1867 void UpgradeFailStoreNewestCacheTest() { |
1868 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1868 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1869 | 1869 |
1870 MakeService(); | 1870 MakeService(); |
1871 MockAppCacheStorage* storage = | 1871 MockAppCacheStorage* storage = |
1872 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); | 1872 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); |
1873 storage->SimulateStoreGroupAndNewestCacheFailure(); | 1873 storage->SimulateStoreGroupAndNewestCacheFailure(); |
1874 | 1874 |
1875 group_ = new AppCacheGroup( | 1875 group_ = new AppCacheGroup( |
1876 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 1876 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
1877 service_->storage()->NewGroupId()); | 1877 service_->storage()->NewGroupId()); |
1878 AppCacheUpdateJob* update = | 1878 AppCacheUpdateJob* update = |
(...skipping 25 matching lines...) Expand all Loading... |
1904 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 1904 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
1905 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 1905 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
1906 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1906 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1907 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1907 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1908 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 1908 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
1909 | 1909 |
1910 WaitForUpdateToFinish(); | 1910 WaitForUpdateToFinish(); |
1911 } | 1911 } |
1912 | 1912 |
1913 void MasterEntryFailStoreNewestCacheTest() { | 1913 void MasterEntryFailStoreNewestCacheTest() { |
1914 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1914 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1915 | 1915 |
1916 MakeService(); | 1916 MakeService(); |
1917 MockAppCacheStorage* storage = | 1917 MockAppCacheStorage* storage = |
1918 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); | 1918 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); |
1919 storage->SimulateStoreGroupAndNewestCacheFailure(); | 1919 storage->SimulateStoreGroupAndNewestCacheFailure(); |
1920 | 1920 |
1921 const GURL kManifestUrl = MockHttpServer::GetMockUrl("files/notmodified"); | 1921 const GURL kManifestUrl = MockHttpServer::GetMockUrl("files/notmodified"); |
1922 const int64 kManifestResponseId = 11; | 1922 const int64 kManifestResponseId = 11; |
1923 | 1923 |
1924 // Seed the response_info working set with canned data for | 1924 // Seed the response_info working set with canned data for |
(...skipping 29 matching lines...) Expand all Loading... |
1954 expect_newest_cache_ = cache.get(); // unchanged | 1954 expect_newest_cache_ = cache.get(); // unchanged |
1955 MockFrontend::HostIds ids1(1, host->host_id()); | 1955 MockFrontend::HostIds ids1(1, host->host_id()); |
1956 frontend->AddExpectedEvent(ids1, ERROR_EVENT); | 1956 frontend->AddExpectedEvent(ids1, ERROR_EVENT); |
1957 frontend->expected_error_message_ = | 1957 frontend->expected_error_message_ = |
1958 "Failed to commit new cache to storage"; | 1958 "Failed to commit new cache to storage"; |
1959 | 1959 |
1960 WaitForUpdateToFinish(); | 1960 WaitForUpdateToFinish(); |
1961 } | 1961 } |
1962 | 1962 |
1963 void UpgradeFailMakeGroupObsoleteTest() { | 1963 void UpgradeFailMakeGroupObsoleteTest() { |
1964 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 1964 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1965 | 1965 |
1966 MakeService(); | 1966 MakeService(); |
1967 MockAppCacheStorage* storage = | 1967 MockAppCacheStorage* storage = |
1968 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); | 1968 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); |
1969 storage->SimulateMakeGroupObsoleteFailure(); | 1969 storage->SimulateMakeGroupObsoleteFailure(); |
1970 | 1970 |
1971 group_ = new AppCacheGroup( | 1971 group_ = new AppCacheGroup( |
1972 service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"), | 1972 service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"), |
1973 service_->storage()->NewGroupId()); | 1973 service_->storage()->NewGroupId()); |
1974 AppCacheUpdateJob* update = | 1974 AppCacheUpdateJob* update = |
(...skipping 20 matching lines...) Expand all Loading... |
1995 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); | 1995 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); |
1996 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); | 1996 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); |
1997 MockFrontend::HostIds ids2(1, host2->host_id()); | 1997 MockFrontend::HostIds ids2(1, host2->host_id()); |
1998 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 1998 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
1999 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 1999 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
2000 | 2000 |
2001 WaitForUpdateToFinish(); | 2001 WaitForUpdateToFinish(); |
2002 } | 2002 } |
2003 | 2003 |
2004 void MasterEntryFetchManifestFailTest() { | 2004 void MasterEntryFetchManifestFailTest() { |
2005 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2005 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2006 | 2006 |
2007 MakeService(); | 2007 MakeService(); |
2008 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), 111); | 2008 group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), 111); |
2009 AppCacheUpdateJob* update = | 2009 AppCacheUpdateJob* update = |
2010 new AppCacheUpdateJob(service_.get(), group_.get()); | 2010 new AppCacheUpdateJob(service_.get(), group_.get()); |
2011 group_->update_job_ = update; | 2011 group_->update_job_ = update; |
2012 | 2012 |
2013 MockFrontend* frontend = MakeMockFrontend(); | 2013 MockFrontend* frontend = MakeMockFrontend(); |
2014 AppCacheHost* host = MakeHost(1, frontend); | 2014 AppCacheHost* host = MakeHost(1, frontend); |
2015 host->new_master_entry_url_ = GURL("http://failme/blah"); | 2015 host->new_master_entry_url_ = GURL("http://failme/blah"); |
2016 update->StartUpdate(host, host->new_master_entry_url_); | 2016 update->StartUpdate(host, host->new_master_entry_url_); |
2017 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 2017 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
2018 | 2018 |
2019 update->manifest_fetcher_->request()->CancelWithError(-100); | 2019 update->manifest_fetcher_->request()->CancelWithError(-100); |
2020 | 2020 |
2021 // Set up checks for when update job finishes. | 2021 // Set up checks for when update job finishes. |
2022 do_checks_after_update_finished_ = true; | 2022 do_checks_after_update_finished_ = true; |
2023 expect_group_obsolete_ = false; | 2023 expect_group_obsolete_ = false; |
2024 expect_group_has_cache_ = false; | 2024 expect_group_has_cache_ = false; |
2025 MockFrontend::HostIds ids1(1, host->host_id()); | 2025 MockFrontend::HostIds ids1(1, host->host_id()); |
2026 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); | 2026 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); |
2027 frontend->AddExpectedEvent(ids1, ERROR_EVENT); | 2027 frontend->AddExpectedEvent(ids1, ERROR_EVENT); |
2028 | 2028 |
2029 WaitForUpdateToFinish(); | 2029 WaitForUpdateToFinish(); |
2030 } | 2030 } |
2031 | 2031 |
2032 void MasterEntryBadManifestTest() { | 2032 void MasterEntryBadManifestTest() { |
2033 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2033 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2034 | 2034 |
2035 MakeService(); | 2035 MakeService(); |
2036 group_ = new AppCacheGroup(service_->storage(), | 2036 group_ = new AppCacheGroup(service_->storage(), |
2037 MockHttpServer::GetMockUrl("files/bad-manifest"), 111); | 2037 MockHttpServer::GetMockUrl("files/bad-manifest"), 111); |
2038 AppCacheUpdateJob* update = | 2038 AppCacheUpdateJob* update = |
2039 new AppCacheUpdateJob(service_.get(), group_.get()); | 2039 new AppCacheUpdateJob(service_.get(), group_.get()); |
2040 group_->update_job_ = update; | 2040 group_->update_job_ = update; |
2041 | 2041 |
2042 MockFrontend* frontend = MakeMockFrontend(); | 2042 MockFrontend* frontend = MakeMockFrontend(); |
2043 AppCacheHost* host = MakeHost(1, frontend); | 2043 AppCacheHost* host = MakeHost(1, frontend); |
2044 host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah"); | 2044 host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah"); |
2045 update->StartUpdate(host, host->new_master_entry_url_); | 2045 update->StartUpdate(host, host->new_master_entry_url_); |
2046 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 2046 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
2047 | 2047 |
2048 // Set up checks for when update job finishes. | 2048 // Set up checks for when update job finishes. |
2049 do_checks_after_update_finished_ = true; | 2049 do_checks_after_update_finished_ = true; |
2050 expect_group_obsolete_ = false; | 2050 expect_group_obsolete_ = false; |
2051 expect_group_has_cache_ = false; | 2051 expect_group_has_cache_ = false; |
2052 MockFrontend::HostIds ids1(1, host->host_id()); | 2052 MockFrontend::HostIds ids1(1, host->host_id()); |
2053 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); | 2053 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); |
2054 frontend->AddExpectedEvent(ids1, ERROR_EVENT); | 2054 frontend->AddExpectedEvent(ids1, ERROR_EVENT); |
2055 | 2055 |
2056 WaitForUpdateToFinish(); | 2056 WaitForUpdateToFinish(); |
2057 } | 2057 } |
2058 | 2058 |
2059 void MasterEntryManifestNotFoundTest() { | 2059 void MasterEntryManifestNotFoundTest() { |
2060 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2060 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2061 | 2061 |
2062 MakeService(); | 2062 MakeService(); |
2063 group_ = new AppCacheGroup( | 2063 group_ = new AppCacheGroup( |
2064 service_->storage(), | 2064 service_->storage(), |
2065 MockHttpServer::GetMockUrl("files/nosuchfile"), | 2065 MockHttpServer::GetMockUrl("files/nosuchfile"), |
2066 111); | 2066 111); |
2067 AppCacheUpdateJob* update = | 2067 AppCacheUpdateJob* update = |
2068 new AppCacheUpdateJob(service_.get(), group_.get()); | 2068 new AppCacheUpdateJob(service_.get(), group_.get()); |
2069 group_->update_job_ = update; | 2069 group_->update_job_ = update; |
2070 | 2070 |
2071 MockFrontend* frontend = MakeMockFrontend(); | 2071 MockFrontend* frontend = MakeMockFrontend(); |
2072 AppCacheHost* host = MakeHost(1, frontend); | 2072 AppCacheHost* host = MakeHost(1, frontend); |
2073 host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah"); | 2073 host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah"); |
2074 | 2074 |
2075 update->StartUpdate(host, host->new_master_entry_url_); | 2075 update->StartUpdate(host, host->new_master_entry_url_); |
2076 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 2076 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
2077 | 2077 |
2078 // Set up checks for when update job finishes. | 2078 // Set up checks for when update job finishes. |
2079 do_checks_after_update_finished_ = true; | 2079 do_checks_after_update_finished_ = true; |
2080 expect_group_obsolete_ = false; | 2080 expect_group_obsolete_ = false; |
2081 expect_group_has_cache_ = false; | 2081 expect_group_has_cache_ = false; |
2082 MockFrontend::HostIds ids1(1, host->host_id()); | 2082 MockFrontend::HostIds ids1(1, host->host_id()); |
2083 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); | 2083 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); |
2084 frontend->AddExpectedEvent(ids1, ERROR_EVENT); | 2084 frontend->AddExpectedEvent(ids1, ERROR_EVENT); |
2085 | 2085 |
2086 WaitForUpdateToFinish(); | 2086 WaitForUpdateToFinish(); |
2087 } | 2087 } |
2088 | 2088 |
2089 void MasterEntryFailUrlFetchTest() { | 2089 void MasterEntryFailUrlFetchTest() { |
2090 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2090 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2091 | 2091 |
2092 MakeService(); | 2092 MakeService(); |
2093 group_ = new AppCacheGroup(service_->storage(), | 2093 group_ = new AppCacheGroup(service_->storage(), |
2094 MockHttpServer::GetMockUrl("files/manifest-fb-404"), 111); | 2094 MockHttpServer::GetMockUrl("files/manifest-fb-404"), 111); |
2095 AppCacheUpdateJob* update = | 2095 AppCacheUpdateJob* update = |
2096 new AppCacheUpdateJob(service_.get(), group_.get()); | 2096 new AppCacheUpdateJob(service_.get(), group_.get()); |
2097 group_->update_job_ = update; | 2097 group_->update_job_ = update; |
2098 | 2098 |
2099 MockFrontend* frontend = MakeMockFrontend(); | 2099 MockFrontend* frontend = MakeMockFrontend(); |
2100 frontend->SetIgnoreProgressEvents(true); | 2100 frontend->SetIgnoreProgressEvents(true); |
(...skipping 10 matching lines...) Expand all Loading... |
2111 expect_group_has_cache_ = false; // 404 fallback url is cache failure | 2111 expect_group_has_cache_ = false; // 404 fallback url is cache failure |
2112 MockFrontend::HostIds ids1(1, host->host_id()); | 2112 MockFrontend::HostIds ids1(1, host->host_id()); |
2113 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); | 2113 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); |
2114 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT); | 2114 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT); |
2115 frontend->AddExpectedEvent(ids1, ERROR_EVENT); | 2115 frontend->AddExpectedEvent(ids1, ERROR_EVENT); |
2116 | 2116 |
2117 WaitForUpdateToFinish(); | 2117 WaitForUpdateToFinish(); |
2118 } | 2118 } |
2119 | 2119 |
2120 void MasterEntryAllFailTest() { | 2120 void MasterEntryAllFailTest() { |
2121 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2121 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2122 | 2122 |
2123 MakeService(); | 2123 MakeService(); |
2124 group_ = new AppCacheGroup( | 2124 group_ = new AppCacheGroup( |
2125 service_->storage(), | 2125 service_->storage(), |
2126 MockHttpServer::GetMockUrl("files/manifest1"), | 2126 MockHttpServer::GetMockUrl("files/manifest1"), |
2127 111); | 2127 111); |
2128 AppCacheUpdateJob* update = | 2128 AppCacheUpdateJob* update = |
2129 new AppCacheUpdateJob(service_.get(), group_.get()); | 2129 new AppCacheUpdateJob(service_.get(), group_.get()); |
2130 group_->update_job_ = update; | 2130 group_->update_job_ = update; |
2131 | 2131 |
(...skipping 21 matching lines...) Expand all Loading... |
2153 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); | 2153 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); |
2154 MockFrontend::HostIds ids2(1, host2->host_id()); | 2154 MockFrontend::HostIds ids2(1, host2->host_id()); |
2155 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 2155 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
2156 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 2156 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
2157 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 2157 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
2158 | 2158 |
2159 WaitForUpdateToFinish(); | 2159 WaitForUpdateToFinish(); |
2160 } | 2160 } |
2161 | 2161 |
2162 void UpgradeMasterEntryAllFailTest() { | 2162 void UpgradeMasterEntryAllFailTest() { |
2163 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2163 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2164 | 2164 |
2165 MakeService(); | 2165 MakeService(); |
2166 group_ = new AppCacheGroup( | 2166 group_ = new AppCacheGroup( |
2167 service_->storage(), | 2167 service_->storage(), |
2168 MockHttpServer::GetMockUrl("files/manifest1"), | 2168 MockHttpServer::GetMockUrl("files/manifest1"), |
2169 111); | 2169 111); |
2170 AppCacheUpdateJob* update = | 2170 AppCacheUpdateJob* update = |
2171 new AppCacheUpdateJob(service_.get(), group_.get()); | 2171 new AppCacheUpdateJob(service_.get(), group_.get()); |
2172 group_->update_job_ = update; | 2172 group_->update_job_ = update; |
2173 | 2173 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); | 2208 frontend2->AddExpectedEvent(ids2, ERROR_EVENT); |
2209 MockFrontend::HostIds ids3(1, host3->host_id()); | 2209 MockFrontend::HostIds ids3(1, host3->host_id()); |
2210 frontend3->AddExpectedEvent(ids3, CHECKING_EVENT); | 2210 frontend3->AddExpectedEvent(ids3, CHECKING_EVENT); |
2211 frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT); | 2211 frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT); |
2212 frontend3->AddExpectedEvent(ids3, ERROR_EVENT); | 2212 frontend3->AddExpectedEvent(ids3, ERROR_EVENT); |
2213 | 2213 |
2214 WaitForUpdateToFinish(); | 2214 WaitForUpdateToFinish(); |
2215 } | 2215 } |
2216 | 2216 |
2217 void MasterEntrySomeFailTest() { | 2217 void MasterEntrySomeFailTest() { |
2218 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2218 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2219 | 2219 |
2220 MakeService(); | 2220 MakeService(); |
2221 group_ = new AppCacheGroup( | 2221 group_ = new AppCacheGroup( |
2222 service_->storage(), | 2222 service_->storage(), |
2223 MockHttpServer::GetMockUrl("files/manifest1"), | 2223 MockHttpServer::GetMockUrl("files/manifest1"), |
2224 111); | 2224 111); |
2225 AppCacheUpdateJob* update = | 2225 AppCacheUpdateJob* update = |
2226 new AppCacheUpdateJob(service_.get(), group_.get()); | 2226 new AppCacheUpdateJob(service_.get(), group_.get()); |
2227 group_->update_job_ = update; | 2227 group_->update_job_ = update; |
2228 | 2228 |
(...skipping 27 matching lines...) Expand all Loading... |
2256 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 2256 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
2257 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 2257 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
2258 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 2258 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
2259 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final | 2259 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final |
2260 frontend2->AddExpectedEvent(ids2, CACHED_EVENT); | 2260 frontend2->AddExpectedEvent(ids2, CACHED_EVENT); |
2261 | 2261 |
2262 WaitForUpdateToFinish(); | 2262 WaitForUpdateToFinish(); |
2263 } | 2263 } |
2264 | 2264 |
2265 void UpgradeMasterEntrySomeFailTest() { | 2265 void UpgradeMasterEntrySomeFailTest() { |
2266 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2266 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2267 | 2267 |
2268 MakeService(); | 2268 MakeService(); |
2269 group_ = new AppCacheGroup( | 2269 group_ = new AppCacheGroup( |
2270 service_->storage(), | 2270 service_->storage(), |
2271 MockHttpServer::GetMockUrl("files/manifest1"), | 2271 MockHttpServer::GetMockUrl("files/manifest1"), |
2272 111); | 2272 111); |
2273 AppCacheUpdateJob* update = | 2273 AppCacheUpdateJob* update = |
2274 new AppCacheUpdateJob(service_.get(), group_.get()); | 2274 new AppCacheUpdateJob(service_.get(), group_.get()); |
2275 group_->update_job_ = update; | 2275 group_->update_job_ = update; |
2276 | 2276 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT); | 2316 frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT); |
2317 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); | 2317 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); |
2318 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); | 2318 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); |
2319 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); // final | 2319 frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); // final |
2320 frontend3->AddExpectedEvent(ids3, UPDATE_READY_EVENT); | 2320 frontend3->AddExpectedEvent(ids3, UPDATE_READY_EVENT); |
2321 | 2321 |
2322 WaitForUpdateToFinish(); | 2322 WaitForUpdateToFinish(); |
2323 } | 2323 } |
2324 | 2324 |
2325 void MasterEntryNoUpdateTest() { | 2325 void MasterEntryNoUpdateTest() { |
2326 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2326 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2327 | 2327 |
2328 MakeService(); | 2328 MakeService(); |
2329 group_ = new AppCacheGroup(service_->storage(), | 2329 group_ = new AppCacheGroup(service_->storage(), |
2330 MockHttpServer::GetMockUrl("files/notmodified"), 111); | 2330 MockHttpServer::GetMockUrl("files/notmodified"), 111); |
2331 AppCacheUpdateJob* update = | 2331 AppCacheUpdateJob* update = |
2332 new AppCacheUpdateJob(service_.get(), group_.get()); | 2332 new AppCacheUpdateJob(service_.get(), group_.get()); |
2333 group_->update_job_ = update; | 2333 group_->update_job_ = update; |
2334 | 2334 |
2335 AppCache* cache = MakeCacheForGroup(1, 111); | 2335 AppCache* cache = MakeCacheForGroup(1, 111); |
2336 MockFrontend* frontend1 = MakeMockFrontend(); | 2336 MockFrontend* frontend1 = MakeMockFrontend(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 frontend2->AddExpectedEvent(ids3, CHECKING_EVENT); | 2370 frontend2->AddExpectedEvent(ids3, CHECKING_EVENT); |
2371 MockFrontend::HostIds ids2and3; | 2371 MockFrontend::HostIds ids2and3; |
2372 ids2and3.push_back(host2->host_id()); | 2372 ids2and3.push_back(host2->host_id()); |
2373 ids2and3.push_back(host3->host_id()); | 2373 ids2and3.push_back(host3->host_id()); |
2374 frontend2->AddExpectedEvent(ids2and3, NO_UPDATE_EVENT); | 2374 frontend2->AddExpectedEvent(ids2and3, NO_UPDATE_EVENT); |
2375 | 2375 |
2376 WaitForUpdateToFinish(); | 2376 WaitForUpdateToFinish(); |
2377 } | 2377 } |
2378 | 2378 |
2379 void StartUpdateMidCacheAttemptTest() { | 2379 void StartUpdateMidCacheAttemptTest() { |
2380 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2380 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2381 | 2381 |
2382 MakeService(); | 2382 MakeService(); |
2383 group_ = new AppCacheGroup( | 2383 group_ = new AppCacheGroup( |
2384 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), | 2384 service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"), |
2385 service_->storage()->NewGroupId()); | 2385 service_->storage()->NewGroupId()); |
2386 AppCacheUpdateJob* update = | 2386 AppCacheUpdateJob* update = |
2387 new AppCacheUpdateJob(service_.get(), group_.get()); | 2387 new AppCacheUpdateJob(service_.get(), group_.get()); |
2388 group_->update_job_ = update; | 2388 group_->update_job_ = update; |
2389 | 2389 |
2390 MockFrontend* frontend1 = MakeMockFrontend(); | 2390 MockFrontend* frontend1 = MakeMockFrontend(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 | 2457 |
2458 // Host 5 is not associated with cache so no progress/cached events. | 2458 // Host 5 is not associated with cache so no progress/cached events. |
2459 MockFrontend::HostIds ids5(1, host5->host_id()); | 2459 MockFrontend::HostIds ids5(1, host5->host_id()); |
2460 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); | 2460 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); |
2461 frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT); | 2461 frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT); |
2462 | 2462 |
2463 WaitForUpdateToFinish(); | 2463 WaitForUpdateToFinish(); |
2464 } | 2464 } |
2465 | 2465 |
2466 void StartUpdateMidNoUpdateTest() { | 2466 void StartUpdateMidNoUpdateTest() { |
2467 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2467 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2468 | 2468 |
2469 MakeService(); | 2469 MakeService(); |
2470 group_ = new AppCacheGroup( | 2470 group_ = new AppCacheGroup( |
2471 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), | 2471 service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"), |
2472 service_->storage()->NewGroupId()); | 2472 service_->storage()->NewGroupId()); |
2473 AppCacheUpdateJob* update = | 2473 AppCacheUpdateJob* update = |
2474 new AppCacheUpdateJob(service_.get(), group_.get()); | 2474 new AppCacheUpdateJob(service_.get(), group_.get()); |
2475 group_->update_job_ = update; | 2475 group_->update_job_ = update; |
2476 | 2476 |
2477 AppCache* cache = MakeCacheForGroup(1, 111); | 2477 AppCache* cache = MakeCacheForGroup(1, 111); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2538 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); | 2538 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); |
2539 frontend5->AddExpectedEvent(ids5, NO_UPDATE_EVENT); | 2539 frontend5->AddExpectedEvent(ids5, NO_UPDATE_EVENT); |
2540 MockFrontend::HostIds ids6(1, host6->host_id()); | 2540 MockFrontend::HostIds ids6(1, host6->host_id()); |
2541 frontend6->AddExpectedEvent(ids6, CHECKING_EVENT); | 2541 frontend6->AddExpectedEvent(ids6, CHECKING_EVENT); |
2542 frontend6->AddExpectedEvent(ids6, NO_UPDATE_EVENT); | 2542 frontend6->AddExpectedEvent(ids6, NO_UPDATE_EVENT); |
2543 | 2543 |
2544 WaitForUpdateToFinish(); | 2544 WaitForUpdateToFinish(); |
2545 } | 2545 } |
2546 | 2546 |
2547 void StartUpdateMidDownloadTest() { | 2547 void StartUpdateMidDownloadTest() { |
2548 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2548 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2549 | 2549 |
2550 MakeService(); | 2550 MakeService(); |
2551 group_ = new AppCacheGroup( | 2551 group_ = new AppCacheGroup( |
2552 service_->storage(), | 2552 service_->storage(), |
2553 MockHttpServer::GetMockUrl("files/manifest1"), | 2553 MockHttpServer::GetMockUrl("files/manifest1"), |
2554 111); | 2554 111); |
2555 AppCacheUpdateJob* update = | 2555 AppCacheUpdateJob* update = |
2556 new AppCacheUpdateJob(service_.get(), group_.get()); | 2556 new AppCacheUpdateJob(service_.get(), group_.get()); |
2557 group_->update_job_ = update; | 2557 group_->update_job_ = update; |
2558 | 2558 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); | 2623 frontend5->AddExpectedEvent(ids5, CHECKING_EVENT); |
2624 frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT); | 2624 frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT); |
2625 frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT); | 2625 frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT); |
2626 frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT); // final | 2626 frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT); // final |
2627 frontend5->AddExpectedEvent(ids5, UPDATE_READY_EVENT); | 2627 frontend5->AddExpectedEvent(ids5, UPDATE_READY_EVENT); |
2628 | 2628 |
2629 WaitForUpdateToFinish(); | 2629 WaitForUpdateToFinish(); |
2630 } | 2630 } |
2631 | 2631 |
2632 void QueueMasterEntryTest() { | 2632 void QueueMasterEntryTest() { |
2633 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2633 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2634 | 2634 |
2635 MakeService(); | 2635 MakeService(); |
2636 group_ = new AppCacheGroup( | 2636 group_ = new AppCacheGroup( |
2637 service_->storage(), | 2637 service_->storage(), |
2638 MockHttpServer::GetMockUrl("files/manifest1"), | 2638 MockHttpServer::GetMockUrl("files/manifest1"), |
2639 111); | 2639 111); |
2640 AppCacheUpdateJob* update = | 2640 AppCacheUpdateJob* update = |
2641 new AppCacheUpdateJob(service_.get(), group_.get()); | 2641 new AppCacheUpdateJob(service_.get(), group_.get()); |
2642 group_->update_job_ = update; | 2642 group_->update_job_ = update; |
2643 | 2643 |
(...skipping 29 matching lines...) Expand all Loading... |
2673 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); | 2673 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); |
2674 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); | 2674 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); |
2675 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final | 2675 frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final |
2676 frontend->AddExpectedEvent(ids1, CACHED_EVENT); | 2676 frontend->AddExpectedEvent(ids1, CACHED_EVENT); |
2677 | 2677 |
2678 // Group status will be IDLE so cannot call WaitForUpdateToFinish. | 2678 // Group status will be IDLE so cannot call WaitForUpdateToFinish. |
2679 group_->AddUpdateObserver(this); | 2679 group_->AddUpdateObserver(this); |
2680 } | 2680 } |
2681 | 2681 |
2682 void IfModifiedSinceTest() { | 2682 void IfModifiedSinceTest() { |
2683 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2683 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2684 | 2684 |
2685 net::URLRequestJobFactoryImpl* new_factory( | 2685 net::URLRequestJobFactoryImpl* new_factory( |
2686 new net::URLRequestJobFactoryImpl); | 2686 new net::URLRequestJobFactoryImpl); |
2687 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); | 2687 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); |
2688 io_thread_->SetNewJobFactory(new_factory); | 2688 io_thread_->SetNewJobFactory(new_factory); |
2689 | 2689 |
2690 MakeService(); | 2690 MakeService(); |
2691 group_ = new AppCacheGroup( | 2691 group_ = new AppCacheGroup( |
2692 service_->storage(), GURL("http://headertest"), 111); | 2692 service_->storage(), GURL("http://headertest"), 111); |
2693 AppCacheUpdateJob* update = | 2693 AppCacheUpdateJob* update = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 update->manifest_response_info_.reset(response_info); | 2742 update->manifest_response_info_.reset(response_info); |
2743 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; | 2743 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; |
2744 update->FetchManifest(false); // not first request | 2744 update->FetchManifest(false); // not first request |
2745 HttpHeadersRequestTestJob::Verify(); | 2745 HttpHeadersRequestTestJob::Verify(); |
2746 delete update; | 2746 delete update; |
2747 | 2747 |
2748 UpdateFinished(); | 2748 UpdateFinished(); |
2749 } | 2749 } |
2750 | 2750 |
2751 void IfModifiedSinceUpgradeTest() { | 2751 void IfModifiedSinceUpgradeTest() { |
2752 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2752 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2753 | 2753 |
2754 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", | 2754 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", |
2755 std::string()); | 2755 std::string()); |
2756 net::URLRequestJobFactoryImpl* new_factory( | 2756 net::URLRequestJobFactoryImpl* new_factory( |
2757 new net::URLRequestJobFactoryImpl); | 2757 new net::URLRequestJobFactoryImpl); |
2758 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); | 2758 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); |
2759 io_thread_->SetNewJobFactory(new_factory); | 2759 io_thread_->SetNewJobFactory(new_factory); |
2760 | 2760 |
2761 MakeService(); | 2761 MakeService(); |
2762 group_ =new AppCacheGroup( | 2762 group_ =new AppCacheGroup( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info | 2806 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
2807 response_writer_->WriteInfo( | 2807 response_writer_->WriteInfo( |
2808 io_buffer.get(), | 2808 io_buffer.get(), |
2809 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 2809 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
2810 base::Unretained(this))); | 2810 base::Unretained(this))); |
2811 | 2811 |
2812 // Start update after data write completes asynchronously. | 2812 // Start update after data write completes asynchronously. |
2813 } | 2813 } |
2814 | 2814 |
2815 void IfNoneMatchUpgradeTest() { | 2815 void IfNoneMatchUpgradeTest() { |
2816 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2816 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2817 | 2817 |
2818 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); | 2818 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); |
2819 net::URLRequestJobFactoryImpl* new_factory( | 2819 net::URLRequestJobFactoryImpl* new_factory( |
2820 new net::URLRequestJobFactoryImpl); | 2820 new net::URLRequestJobFactoryImpl); |
2821 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); | 2821 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); |
2822 io_thread_->SetNewJobFactory(new_factory); | 2822 io_thread_->SetNewJobFactory(new_factory); |
2823 | 2823 |
2824 MakeService(); | 2824 MakeService(); |
2825 group_ = new AppCacheGroup( | 2825 group_ = new AppCacheGroup( |
2826 service_->storage(), | 2826 service_->storage(), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info | 2869 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
2870 response_writer_->WriteInfo( | 2870 response_writer_->WriteInfo( |
2871 io_buffer.get(), | 2871 io_buffer.get(), |
2872 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, | 2872 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, |
2873 base::Unretained(this))); | 2873 base::Unretained(this))); |
2874 | 2874 |
2875 // Start update after data write completes asynchronously. | 2875 // Start update after data write completes asynchronously. |
2876 } | 2876 } |
2877 | 2877 |
2878 void IfNoneMatchRefetchTest() { | 2878 void IfNoneMatchRefetchTest() { |
2879 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2879 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2880 | 2880 |
2881 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); | 2881 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); |
2882 net::URLRequestJobFactoryImpl* new_factory( | 2882 net::URLRequestJobFactoryImpl* new_factory( |
2883 new net::URLRequestJobFactoryImpl); | 2883 new net::URLRequestJobFactoryImpl); |
2884 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); | 2884 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); |
2885 io_thread_->SetNewJobFactory(new_factory); | 2885 io_thread_->SetNewJobFactory(new_factory); |
2886 | 2886 |
2887 MakeService(); | 2887 MakeService(); |
2888 group_ = new AppCacheGroup( | 2888 group_ = new AppCacheGroup( |
2889 service_->storage(), GURL("http://headertest"), 111); | 2889 service_->storage(), GURL("http://headertest"), 111); |
(...skipping 15 matching lines...) Expand all Loading... |
2905 update->manifest_response_info_.reset(response_info); | 2905 update->manifest_response_info_.reset(response_info); |
2906 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; | 2906 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; |
2907 update->FetchManifest(false); // not first request | 2907 update->FetchManifest(false); // not first request |
2908 HttpHeadersRequestTestJob::Verify(); | 2908 HttpHeadersRequestTestJob::Verify(); |
2909 delete update; | 2909 delete update; |
2910 | 2910 |
2911 UpdateFinished(); | 2911 UpdateFinished(); |
2912 } | 2912 } |
2913 | 2913 |
2914 void MultipleHeadersRefetchTest() { | 2914 void MultipleHeadersRefetchTest() { |
2915 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2915 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2916 | 2916 |
2917 // Verify that code is correct when building multiple extra headers. | 2917 // Verify that code is correct when building multiple extra headers. |
2918 HttpHeadersRequestTestJob::Initialize( | 2918 HttpHeadersRequestTestJob::Initialize( |
2919 "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\""); | 2919 "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\""); |
2920 net::URLRequestJobFactoryImpl* new_factory( | 2920 net::URLRequestJobFactoryImpl* new_factory( |
2921 new net::URLRequestJobFactoryImpl); | 2921 new net::URLRequestJobFactoryImpl); |
2922 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); | 2922 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); |
2923 io_thread_->SetNewJobFactory(new_factory); | 2923 io_thread_->SetNewJobFactory(new_factory); |
2924 | 2924 |
2925 MakeService(); | 2925 MakeService(); |
(...skipping 18 matching lines...) Expand all Loading... |
2944 update->manifest_response_info_.reset(response_info); | 2944 update->manifest_response_info_.reset(response_info); |
2945 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; | 2945 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; |
2946 update->FetchManifest(false); // not first request | 2946 update->FetchManifest(false); // not first request |
2947 HttpHeadersRequestTestJob::Verify(); | 2947 HttpHeadersRequestTestJob::Verify(); |
2948 delete update; | 2948 delete update; |
2949 | 2949 |
2950 UpdateFinished(); | 2950 UpdateFinished(); |
2951 } | 2951 } |
2952 | 2952 |
2953 void CrossOriginHttpsSuccessTest() { | 2953 void CrossOriginHttpsSuccessTest() { |
2954 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2954 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2955 | 2955 |
2956 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( | 2956 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( |
2957 "files/valid_cross_origin_https_manifest"); | 2957 "files/valid_cross_origin_https_manifest"); |
2958 | 2958 |
2959 MakeService(); | 2959 MakeService(); |
2960 group_ = new AppCacheGroup( | 2960 group_ = new AppCacheGroup( |
2961 service_->storage(), manifest_url, service_->storage()->NewGroupId()); | 2961 service_->storage(), manifest_url, service_->storage()->NewGroupId()); |
2962 AppCacheUpdateJob* update = | 2962 AppCacheUpdateJob* update = |
2963 new AppCacheUpdateJob(service_.get(), group_.get()); | 2963 new AppCacheUpdateJob(service_.get(), group_.get()); |
2964 group_->update_job_ = update; | 2964 group_->update_job_ = update; |
2965 | 2965 |
2966 MockFrontend* frontend = MakeMockFrontend(); | 2966 MockFrontend* frontend = MakeMockFrontend(); |
2967 AppCacheHost* host = MakeHost(1, frontend); | 2967 AppCacheHost* host = MakeHost(1, frontend); |
2968 update->StartUpdate(host, GURL()); | 2968 update->StartUpdate(host, GURL()); |
2969 | 2969 |
2970 // Set up checks for when update job finishes. | 2970 // Set up checks for when update job finishes. |
2971 do_checks_after_update_finished_ = true; | 2971 do_checks_after_update_finished_ = true; |
2972 expect_group_obsolete_ = false; | 2972 expect_group_obsolete_ = false; |
2973 expect_group_has_cache_ = true; | 2973 expect_group_has_cache_ = true; |
2974 tested_manifest_ = NONE; | 2974 tested_manifest_ = NONE; |
2975 MockFrontend::HostIds host_ids(1, host->host_id()); | 2975 MockFrontend::HostIds host_ids(1, host->host_id()); |
2976 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); | 2976 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); |
2977 | 2977 |
2978 WaitForUpdateToFinish(); | 2978 WaitForUpdateToFinish(); |
2979 } | 2979 } |
2980 | 2980 |
2981 void CrossOriginHttpsDeniedTest() { | 2981 void CrossOriginHttpsDeniedTest() { |
2982 ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type()); | 2982 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2983 | 2983 |
2984 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( | 2984 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( |
2985 "files/invalid_cross_origin_https_manifest"); | 2985 "files/invalid_cross_origin_https_manifest"); |
2986 | 2986 |
2987 MakeService(); | 2987 MakeService(); |
2988 group_ = new AppCacheGroup( | 2988 group_ = new AppCacheGroup( |
2989 service_->storage(), manifest_url, service_->storage()->NewGroupId()); | 2989 service_->storage(), manifest_url, service_->storage()->NewGroupId()); |
2990 AppCacheUpdateJob* update = | 2990 AppCacheUpdateJob* update = |
2991 new AppCacheUpdateJob(service_.get(), group_.get()); | 2991 new AppCacheUpdateJob(service_.get(), group_.get()); |
2992 group_->update_job_ = update; | 2992 group_->update_job_ = update; |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3683 | 3683 |
3684 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { | 3684 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { |
3685 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); | 3685 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); |
3686 } | 3686 } |
3687 | 3687 |
3688 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { | 3688 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { |
3689 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); | 3689 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); |
3690 } | 3690 } |
3691 | 3691 |
3692 } // namespace appcache | 3692 } // namespace appcache |
OLD | NEW |