OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/appcache/appcache_update_job.h" | 5 #include "content/browser/appcache/appcache_update_job.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 |
9 #include <utility> | 10 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
16 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
17 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
18 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
19 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
20 #include "content/browser/appcache/appcache_group.h" | 22 #include "content/browser/appcache/appcache_group.h" |
21 #include "content/browser/appcache/appcache_host.h" | 23 #include "content/browser/appcache/appcache_host.h" |
22 #include "content/browser/appcache/appcache_response.h" | 24 #include "content/browser/appcache/appcache_response.h" |
23 #include "content/browser/appcache/mock_appcache_service.h" | 25 #include "content/browser/appcache/mock_appcache_service.h" |
24 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 return request_context_.get(); | 573 return request_context_.get(); |
572 } | 574 } |
573 | 575 |
574 void SetNewJobFactory(net::URLRequestJobFactory* job_factory) { | 576 void SetNewJobFactory(net::URLRequestJobFactory* job_factory) { |
575 DCHECK(job_factory); | 577 DCHECK(job_factory); |
576 job_factory_.reset(job_factory); | 578 job_factory_.reset(job_factory); |
577 request_context_->set_job_factory(job_factory_.get()); | 579 request_context_->set_job_factory(job_factory_.get()); |
578 } | 580 } |
579 | 581 |
580 void Init() override { | 582 void Init() override { |
581 scoped_ptr<net::URLRequestJobFactoryImpl> factory( | 583 std::unique_ptr<net::URLRequestJobFactoryImpl> factory( |
582 new net::URLRequestJobFactoryImpl()); | 584 new net::URLRequestJobFactoryImpl()); |
583 factory->SetProtocolHandler("http", | 585 factory->SetProtocolHandler("http", |
584 make_scoped_ptr(new MockHttpServerJobFactory)); | 586 base::WrapUnique(new MockHttpServerJobFactory)); |
585 factory->SetProtocolHandler("https", | 587 factory->SetProtocolHandler("https", |
586 make_scoped_ptr(new MockHttpServerJobFactory)); | 588 base::WrapUnique(new MockHttpServerJobFactory)); |
587 job_factory_ = std::move(factory); | 589 job_factory_ = std::move(factory); |
588 request_context_.reset(new net::TestURLRequestContext()); | 590 request_context_.reset(new net::TestURLRequestContext()); |
589 request_context_->set_job_factory(job_factory_.get()); | 591 request_context_->set_job_factory(job_factory_.get()); |
590 } | 592 } |
591 | 593 |
592 void CleanUp() override { | 594 void CleanUp() override { |
593 request_context_.reset(); | 595 request_context_.reset(); |
594 job_factory_.reset(); | 596 job_factory_.reset(); |
595 } | 597 } |
596 | 598 |
597 private: | 599 private: |
598 scoped_ptr<net::URLRequestJobFactory> job_factory_; | 600 std::unique_ptr<net::URLRequestJobFactory> job_factory_; |
599 scoped_ptr<net::URLRequestContext> request_context_; | 601 std::unique_ptr<net::URLRequestContext> request_context_; |
600 }; | 602 }; |
601 | 603 |
602 class AppCacheUpdateJobTest : public testing::Test, | 604 class AppCacheUpdateJobTest : public testing::Test, |
603 public AppCacheGroup::UpdateObserver { | 605 public AppCacheGroup::UpdateObserver { |
604 public: | 606 public: |
605 AppCacheUpdateJobTest() | 607 AppCacheUpdateJobTest() |
606 : do_checks_after_update_finished_(false), | 608 : do_checks_after_update_finished_(false), |
607 expect_group_obsolete_(false), | 609 expect_group_obsolete_(false), |
608 expect_group_has_cache_(false), | 610 expect_group_has_cache_(false), |
609 expect_group_is_being_deleted_(false), | 611 expect_group_is_being_deleted_(false), |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 800 |
799 WaitForUpdateToFinish(); | 801 WaitForUpdateToFinish(); |
800 } | 802 } |
801 | 803 |
802 void ManifestRedirectTest() { | 804 void ManifestRedirectTest() { |
803 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 805 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
804 | 806 |
805 net::URLRequestJobFactoryImpl* new_factory( | 807 net::URLRequestJobFactoryImpl* new_factory( |
806 new net::URLRequestJobFactoryImpl); | 808 new net::URLRequestJobFactoryImpl); |
807 new_factory->SetProtocolHandler("http", | 809 new_factory->SetProtocolHandler("http", |
808 make_scoped_ptr(new RedirectFactory)); | 810 base::WrapUnique(new RedirectFactory)); |
809 io_thread_->SetNewJobFactory(new_factory); | 811 io_thread_->SetNewJobFactory(new_factory); |
810 | 812 |
811 MakeService(); | 813 MakeService(); |
812 group_ = new AppCacheGroup(service_->storage(), GURL("http://testme"), | 814 group_ = new AppCacheGroup(service_->storage(), GURL("http://testme"), |
813 service_->storage()->NewGroupId()); | 815 service_->storage()->NewGroupId()); |
814 AppCacheUpdateJob* update = | 816 AppCacheUpdateJob* update = |
815 new AppCacheUpdateJob(service_.get(), group_.get()); | 817 new AppCacheUpdateJob(service_.get(), group_.get()); |
816 group_->update_job_ = update; | 818 group_->update_job_ = update; |
817 | 819 |
818 MockFrontend* frontend = MakeMockFrontend(); | 820 MockFrontend* frontend = MakeMockFrontend(); |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 | 1686 |
1685 void RetryRequestTest() { | 1687 void RetryRequestTest() { |
1686 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 1688 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1687 | 1689 |
1688 // Set some large number of times to return retry. | 1690 // Set some large number of times to return retry. |
1689 // Expect 1 manifest fetch and 3 retries. | 1691 // Expect 1 manifest fetch and 3 retries. |
1690 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4); | 1692 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4); |
1691 net::URLRequestJobFactoryImpl* new_factory( | 1693 net::URLRequestJobFactoryImpl* new_factory( |
1692 new net::URLRequestJobFactoryImpl); | 1694 new net::URLRequestJobFactoryImpl); |
1693 new_factory->SetProtocolHandler( | 1695 new_factory->SetProtocolHandler( |
1694 "http", make_scoped_ptr(new RetryRequestTestJobFactory)); | 1696 "http", base::WrapUnique(new RetryRequestTestJobFactory)); |
1695 io_thread_->SetNewJobFactory(new_factory); | 1697 io_thread_->SetNewJobFactory(new_factory); |
1696 | 1698 |
1697 MakeService(); | 1699 MakeService(); |
1698 group_ = new AppCacheGroup(service_->storage(), | 1700 group_ = new AppCacheGroup(service_->storage(), |
1699 RetryRequestTestJob::kRetryUrl, | 1701 RetryRequestTestJob::kRetryUrl, |
1700 service_->storage()->NewGroupId()); | 1702 service_->storage()->NewGroupId()); |
1701 AppCacheUpdateJob* update = | 1703 AppCacheUpdateJob* update = |
1702 new AppCacheUpdateJob(service_.get(), group_.get()); | 1704 new AppCacheUpdateJob(service_.get(), group_.get()); |
1703 group_->update_job_ = update; | 1705 group_->update_job_ = update; |
1704 | 1706 |
(...skipping 13 matching lines...) Expand all Loading... |
1718 | 1720 |
1719 void RetryNoRetryAfterTest() { | 1721 void RetryNoRetryAfterTest() { |
1720 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 1722 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1721 | 1723 |
1722 // Set some large number of times to return retry. | 1724 // Set some large number of times to return retry. |
1723 // Expect 1 manifest fetch and 0 retries. | 1725 // Expect 1 manifest fetch and 0 retries. |
1724 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1); | 1726 RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1); |
1725 net::URLRequestJobFactoryImpl* new_factory( | 1727 net::URLRequestJobFactoryImpl* new_factory( |
1726 new net::URLRequestJobFactoryImpl); | 1728 new net::URLRequestJobFactoryImpl); |
1727 new_factory->SetProtocolHandler( | 1729 new_factory->SetProtocolHandler( |
1728 "http", make_scoped_ptr(new RetryRequestTestJobFactory)); | 1730 "http", base::WrapUnique(new RetryRequestTestJobFactory)); |
1729 io_thread_->SetNewJobFactory(new_factory); | 1731 io_thread_->SetNewJobFactory(new_factory); |
1730 | 1732 |
1731 MakeService(); | 1733 MakeService(); |
1732 group_ = new AppCacheGroup(service_->storage(), | 1734 group_ = new AppCacheGroup(service_->storage(), |
1733 RetryRequestTestJob::kRetryUrl, | 1735 RetryRequestTestJob::kRetryUrl, |
1734 service_->storage()->NewGroupId()); | 1736 service_->storage()->NewGroupId()); |
1735 AppCacheUpdateJob* update = | 1737 AppCacheUpdateJob* update = |
1736 new AppCacheUpdateJob(service_.get(), group_.get()); | 1738 new AppCacheUpdateJob(service_.get(), group_.get()); |
1737 group_->update_job_ = update; | 1739 group_->update_job_ = update; |
1738 | 1740 |
(...skipping 14 matching lines...) Expand all Loading... |
1753 void RetryNonzeroRetryAfterTest() { | 1755 void RetryNonzeroRetryAfterTest() { |
1754 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 1756 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1755 | 1757 |
1756 // Set some large number of times to return retry. | 1758 // Set some large number of times to return retry. |
1757 // Expect 1 request and 0 retry attempts. | 1759 // Expect 1 request and 0 retry attempts. |
1758 RetryRequestTestJob::Initialize( | 1760 RetryRequestTestJob::Initialize( |
1759 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1); | 1761 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1); |
1760 net::URLRequestJobFactoryImpl* new_factory( | 1762 net::URLRequestJobFactoryImpl* new_factory( |
1761 new net::URLRequestJobFactoryImpl); | 1763 new net::URLRequestJobFactoryImpl); |
1762 new_factory->SetProtocolHandler( | 1764 new_factory->SetProtocolHandler( |
1763 "http", make_scoped_ptr(new RetryRequestTestJobFactory)); | 1765 "http", base::WrapUnique(new RetryRequestTestJobFactory)); |
1764 io_thread_->SetNewJobFactory(new_factory); | 1766 io_thread_->SetNewJobFactory(new_factory); |
1765 | 1767 |
1766 MakeService(); | 1768 MakeService(); |
1767 group_ = new AppCacheGroup(service_->storage(), | 1769 group_ = new AppCacheGroup(service_->storage(), |
1768 RetryRequestTestJob::kRetryUrl, | 1770 RetryRequestTestJob::kRetryUrl, |
1769 service_->storage()->NewGroupId()); | 1771 service_->storage()->NewGroupId()); |
1770 AppCacheUpdateJob* update = | 1772 AppCacheUpdateJob* update = |
1771 new AppCacheUpdateJob(service_.get(), group_.get()); | 1773 new AppCacheUpdateJob(service_.get(), group_.get()); |
1772 group_->update_job_ = update; | 1774 group_->update_job_ = update; |
1773 | 1775 |
(...skipping 13 matching lines...) Expand all Loading... |
1787 | 1789 |
1788 void RetrySuccessTest() { | 1790 void RetrySuccessTest() { |
1789 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 1791 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1790 | 1792 |
1791 // Set 2 as the retry limit (does not exceed the max). | 1793 // Set 2 as the retry limit (does not exceed the max). |
1792 // Expect 1 manifest fetch, 2 retries, 1 url fetch, 1 manifest refetch. | 1794 // Expect 1 manifest fetch, 2 retries, 1 url fetch, 1 manifest refetch. |
1793 RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5); | 1795 RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5); |
1794 net::URLRequestJobFactoryImpl* new_factory( | 1796 net::URLRequestJobFactoryImpl* new_factory( |
1795 new net::URLRequestJobFactoryImpl); | 1797 new net::URLRequestJobFactoryImpl); |
1796 new_factory->SetProtocolHandler( | 1798 new_factory->SetProtocolHandler( |
1797 "http", make_scoped_ptr(new RetryRequestTestJobFactory)); | 1799 "http", base::WrapUnique(new RetryRequestTestJobFactory)); |
1798 io_thread_->SetNewJobFactory(new_factory); | 1800 io_thread_->SetNewJobFactory(new_factory); |
1799 | 1801 |
1800 MakeService(); | 1802 MakeService(); |
1801 group_ = new AppCacheGroup(service_->storage(), | 1803 group_ = new AppCacheGroup(service_->storage(), |
1802 RetryRequestTestJob::kRetryUrl, | 1804 RetryRequestTestJob::kRetryUrl, |
1803 service_->storage()->NewGroupId()); | 1805 service_->storage()->NewGroupId()); |
1804 AppCacheUpdateJob* update = | 1806 AppCacheUpdateJob* update = |
1805 new AppCacheUpdateJob(service_.get(), group_.get()); | 1807 new AppCacheUpdateJob(service_.get(), group_.get()); |
1806 group_->update_job_ = update; | 1808 group_->update_job_ = update; |
1807 | 1809 |
(...skipping 13 matching lines...) Expand all Loading... |
1821 | 1823 |
1822 void RetryUrlTest() { | 1824 void RetryUrlTest() { |
1823 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 1825 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
1824 | 1826 |
1825 // Set 1 as the retry limit (does not exceed the max). | 1827 // Set 1 as the retry limit (does not exceed the max). |
1826 // Expect 1 manifest fetch, 1 url fetch, 1 url retry, 1 manifest refetch. | 1828 // Expect 1 manifest fetch, 1 url fetch, 1 url retry, 1 manifest refetch. |
1827 RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4); | 1829 RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4); |
1828 net::URLRequestJobFactoryImpl* new_factory( | 1830 net::URLRequestJobFactoryImpl* new_factory( |
1829 new net::URLRequestJobFactoryImpl); | 1831 new net::URLRequestJobFactoryImpl); |
1830 new_factory->SetProtocolHandler( | 1832 new_factory->SetProtocolHandler( |
1831 "http", make_scoped_ptr(new RetryRequestTestJobFactory)); | 1833 "http", base::WrapUnique(new RetryRequestTestJobFactory)); |
1832 io_thread_->SetNewJobFactory(new_factory); | 1834 io_thread_->SetNewJobFactory(new_factory); |
1833 | 1835 |
1834 MakeService(); | 1836 MakeService(); |
1835 group_ = new AppCacheGroup(service_->storage(), GURL("http://retryurl"), | 1837 group_ = new AppCacheGroup(service_->storage(), GURL("http://retryurl"), |
1836 service_->storage()->NewGroupId()); | 1838 service_->storage()->NewGroupId()); |
1837 AppCacheUpdateJob* update = | 1839 AppCacheUpdateJob* update = |
1838 new AppCacheUpdateJob(service_.get(), group_.get()); | 1840 new AppCacheUpdateJob(service_.get(), group_.get()); |
1839 group_->update_job_ = update; | 1841 group_->update_job_ = update; |
1840 | 1842 |
1841 MockFrontend* frontend = MakeMockFrontend(); | 1843 MockFrontend* frontend = MakeMockFrontend(); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 // WaitForUpdateToFinish. | 2689 // WaitForUpdateToFinish. |
2688 group_->AddUpdateObserver(this); | 2690 group_->AddUpdateObserver(this); |
2689 } | 2691 } |
2690 | 2692 |
2691 void IfModifiedSinceTest() { | 2693 void IfModifiedSinceTest() { |
2692 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 2694 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2693 | 2695 |
2694 net::URLRequestJobFactoryImpl* new_factory( | 2696 net::URLRequestJobFactoryImpl* new_factory( |
2695 new net::URLRequestJobFactoryImpl); | 2697 new net::URLRequestJobFactoryImpl); |
2696 new_factory->SetProtocolHandler( | 2698 new_factory->SetProtocolHandler( |
2697 "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); | 2699 "http", base::WrapUnique(new IfModifiedSinceJobFactory)); |
2698 io_thread_->SetNewJobFactory(new_factory); | 2700 io_thread_->SetNewJobFactory(new_factory); |
2699 | 2701 |
2700 MakeService(); | 2702 MakeService(); |
2701 group_ = new AppCacheGroup( | 2703 group_ = new AppCacheGroup( |
2702 service_->storage(), GURL("http://headertest"), 111); | 2704 service_->storage(), GURL("http://headertest"), 111); |
2703 AppCacheUpdateJob* update = | 2705 AppCacheUpdateJob* update = |
2704 new AppCacheUpdateJob(service_.get(), group_.get()); | 2706 new AppCacheUpdateJob(service_.get(), group_.get()); |
2705 group_->update_job_ = update; | 2707 group_->update_job_ = update; |
2706 | 2708 |
2707 // First test against a cache attempt. Will start manifest fetch | 2709 // First test against a cache attempt. Will start manifest fetch |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 } | 2761 } |
2760 | 2762 |
2761 void IfModifiedSinceUpgradeTest() { | 2763 void IfModifiedSinceUpgradeTest() { |
2762 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 2764 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2763 | 2765 |
2764 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", | 2766 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", |
2765 std::string()); | 2767 std::string()); |
2766 net::URLRequestJobFactoryImpl* new_factory( | 2768 net::URLRequestJobFactoryImpl* new_factory( |
2767 new net::URLRequestJobFactoryImpl); | 2769 new net::URLRequestJobFactoryImpl); |
2768 new_factory->SetProtocolHandler( | 2770 new_factory->SetProtocolHandler( |
2769 "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); | 2771 "http", base::WrapUnique(new IfModifiedSinceJobFactory)); |
2770 io_thread_->SetNewJobFactory(new_factory); | 2772 io_thread_->SetNewJobFactory(new_factory); |
2771 | 2773 |
2772 MakeService(); | 2774 MakeService(); |
2773 group_ = new AppCacheGroup( | 2775 group_ = new AppCacheGroup( |
2774 service_->storage(), | 2776 service_->storage(), |
2775 MockHttpServer::GetMockUrl("files/manifest1"), | 2777 MockHttpServer::GetMockUrl("files/manifest1"), |
2776 111); | 2778 111); |
2777 AppCacheUpdateJob* update = | 2779 AppCacheUpdateJob* update = |
2778 new AppCacheUpdateJob(service_.get(), group_.get()); | 2780 new AppCacheUpdateJob(service_.get(), group_.get()); |
2779 group_->update_job_ = update; | 2781 group_->update_job_ = update; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 // Start update after data write completes asynchronously. | 2825 // Start update after data write completes asynchronously. |
2824 } | 2826 } |
2825 | 2827 |
2826 void IfNoneMatchUpgradeTest() { | 2828 void IfNoneMatchUpgradeTest() { |
2827 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 2829 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2828 | 2830 |
2829 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); | 2831 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); |
2830 net::URLRequestJobFactoryImpl* new_factory( | 2832 net::URLRequestJobFactoryImpl* new_factory( |
2831 new net::URLRequestJobFactoryImpl); | 2833 new net::URLRequestJobFactoryImpl); |
2832 new_factory->SetProtocolHandler( | 2834 new_factory->SetProtocolHandler( |
2833 "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); | 2835 "http", base::WrapUnique(new IfModifiedSinceJobFactory)); |
2834 io_thread_->SetNewJobFactory(new_factory); | 2836 io_thread_->SetNewJobFactory(new_factory); |
2835 | 2837 |
2836 MakeService(); | 2838 MakeService(); |
2837 group_ = new AppCacheGroup( | 2839 group_ = new AppCacheGroup( |
2838 service_->storage(), | 2840 service_->storage(), |
2839 MockHttpServer::GetMockUrl("files/manifest1"), | 2841 MockHttpServer::GetMockUrl("files/manifest1"), |
2840 111); | 2842 111); |
2841 AppCacheUpdateJob* update = | 2843 AppCacheUpdateJob* update = |
2842 new AppCacheUpdateJob(service_.get(), group_.get()); | 2844 new AppCacheUpdateJob(service_.get(), group_.get()); |
2843 group_->update_job_ = update; | 2845 group_->update_job_ = update; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 // Start update after data write completes asynchronously. | 2889 // Start update after data write completes asynchronously. |
2888 } | 2890 } |
2889 | 2891 |
2890 void IfNoneMatchRefetchTest() { | 2892 void IfNoneMatchRefetchTest() { |
2891 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 2893 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2892 | 2894 |
2893 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); | 2895 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); |
2894 net::URLRequestJobFactoryImpl* new_factory( | 2896 net::URLRequestJobFactoryImpl* new_factory( |
2895 new net::URLRequestJobFactoryImpl); | 2897 new net::URLRequestJobFactoryImpl); |
2896 new_factory->SetProtocolHandler( | 2898 new_factory->SetProtocolHandler( |
2897 "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); | 2899 "http", base::WrapUnique(new IfModifiedSinceJobFactory)); |
2898 io_thread_->SetNewJobFactory(new_factory); | 2900 io_thread_->SetNewJobFactory(new_factory); |
2899 | 2901 |
2900 MakeService(); | 2902 MakeService(); |
2901 group_ = new AppCacheGroup( | 2903 group_ = new AppCacheGroup( |
2902 service_->storage(), GURL("http://headertest"), 111); | 2904 service_->storage(), GURL("http://headertest"), 111); |
2903 AppCacheUpdateJob* update = | 2905 AppCacheUpdateJob* update = |
2904 new AppCacheUpdateJob(service_.get(), group_.get()); | 2906 new AppCacheUpdateJob(service_.get(), group_.get()); |
2905 group_->update_job_ = update; | 2907 group_->update_job_ = update; |
2906 | 2908 |
2907 // Simulate a refetch manifest request that uses an ETag header. | 2909 // Simulate a refetch manifest request that uses an ETag header. |
(...skipping 18 matching lines...) Expand all Loading... |
2926 | 2928 |
2927 void MultipleHeadersRefetchTest() { | 2929 void MultipleHeadersRefetchTest() { |
2928 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 2930 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
2929 | 2931 |
2930 // Verify that code is correct when building multiple extra headers. | 2932 // Verify that code is correct when building multiple extra headers. |
2931 HttpHeadersRequestTestJob::Initialize( | 2933 HttpHeadersRequestTestJob::Initialize( |
2932 "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\""); | 2934 "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\""); |
2933 net::URLRequestJobFactoryImpl* new_factory( | 2935 net::URLRequestJobFactoryImpl* new_factory( |
2934 new net::URLRequestJobFactoryImpl); | 2936 new net::URLRequestJobFactoryImpl); |
2935 new_factory->SetProtocolHandler( | 2937 new_factory->SetProtocolHandler( |
2936 "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); | 2938 "http", base::WrapUnique(new IfModifiedSinceJobFactory)); |
2937 io_thread_->SetNewJobFactory(new_factory); | 2939 io_thread_->SetNewJobFactory(new_factory); |
2938 | 2940 |
2939 MakeService(); | 2941 MakeService(); |
2940 group_ = new AppCacheGroup( | 2942 group_ = new AppCacheGroup( |
2941 service_->storage(), GURL("http://headertest"), 111); | 2943 service_->storage(), GURL("http://headertest"), 111); |
2942 AppCacheUpdateJob* update = | 2944 AppCacheUpdateJob* update = |
2943 new AppCacheUpdateJob(service_.get(), group_.get()); | 2945 new AppCacheUpdateJob(service_.get(), group_.get()); |
2944 group_->update_job_ = update; | 2946 group_->update_job_ = update; |
2945 | 2947 |
2946 // Simulate a refetch manifest request that uses an ETag header. | 2948 // Simulate a refetch manifest request that uses an ETag header. |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3415 enum TestedManifest { | 3417 enum TestedManifest { |
3416 NONE, | 3418 NONE, |
3417 MANIFEST1, | 3419 MANIFEST1, |
3418 MANIFEST_MERGED_TYPES, | 3420 MANIFEST_MERGED_TYPES, |
3419 EMPTY_MANIFEST, | 3421 EMPTY_MANIFEST, |
3420 EMPTY_FILE_MANIFEST, | 3422 EMPTY_FILE_MANIFEST, |
3421 PENDING_MASTER_NO_UPDATE, | 3423 PENDING_MASTER_NO_UPDATE, |
3422 MANIFEST_WITH_INTERCEPT | 3424 MANIFEST_WITH_INTERCEPT |
3423 }; | 3425 }; |
3424 | 3426 |
3425 scoped_ptr<IOThread> io_thread_; | 3427 std::unique_ptr<IOThread> io_thread_; |
3426 | 3428 |
3427 scoped_ptr<MockAppCacheService> service_; | 3429 std::unique_ptr<MockAppCacheService> service_; |
3428 scoped_refptr<AppCacheGroup> group_; | 3430 scoped_refptr<AppCacheGroup> group_; |
3429 scoped_refptr<AppCache> protect_newest_cache_; | 3431 scoped_refptr<AppCache> protect_newest_cache_; |
3430 scoped_ptr<base::WaitableEvent> event_; | 3432 std::unique_ptr<base::WaitableEvent> event_; |
3431 | 3433 |
3432 scoped_ptr<AppCacheResponseWriter> response_writer_; | 3434 std::unique_ptr<AppCacheResponseWriter> response_writer_; |
3433 | 3435 |
3434 // Hosts used by an async test that need to live until update job finishes. | 3436 // Hosts used by an async test that need to live until update job finishes. |
3435 // Otherwise, test can put host on the stack instead of here. | 3437 // Otherwise, test can put host on the stack instead of here. |
3436 std::vector<AppCacheHost*> hosts_; | 3438 std::vector<AppCacheHost*> hosts_; |
3437 | 3439 |
3438 // Response infos used by an async test that need to live until update job | 3440 // Response infos used by an async test that need to live until update job |
3439 // finishes. | 3441 // finishes. |
3440 std::vector<scoped_refptr<AppCacheResponseInfo> > response_infos_; | 3442 std::vector<scoped_refptr<AppCacheResponseInfo> > response_infos_; |
3441 | 3443 |
3442 // Flag indicating if test cares to verify the update after update finishes. | 3444 // Flag indicating if test cares to verify the update after update finishes. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 | 3730 |
3729 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { | 3731 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { |
3730 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); | 3732 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); |
3731 } | 3733 } |
3732 | 3734 |
3733 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { | 3735 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { |
3734 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); | 3736 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); |
3735 } | 3737 } |
3736 | 3738 |
3737 } // namespace content | 3739 } // namespace content |
OLD | NEW |