| 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/service_worker/service_worker_cache.h" | 5 #include "content/browser/service_worker/service_worker_cache.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 class ServiceWorkerCacheTest : public testing::Test { | 45 class ServiceWorkerCacheTest : public testing::Test { |
| 46 public: | 46 public: |
| 47 ServiceWorkerCacheTest() | 47 ServiceWorkerCacheTest() |
| 48 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), | 48 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), |
| 49 callback_error_(ServiceWorkerCache::ErrorTypeOK) {} | 49 callback_error_(ServiceWorkerCache::ErrorTypeOK) {} |
| 50 | 50 |
| 51 virtual void SetUp() override { | 51 void SetUp() override { |
| 52 ChromeBlobStorageContext* blob_storage_context = | 52 ChromeBlobStorageContext* blob_storage_context = |
| 53 ChromeBlobStorageContext::GetFor(&browser_context_); | 53 ChromeBlobStorageContext::GetFor(&browser_context_); |
| 54 // Wait for chrome_blob_storage_context to finish initializing. | 54 // Wait for chrome_blob_storage_context to finish initializing. |
| 55 base::RunLoop().RunUntilIdle(); | 55 base::RunLoop().RunUntilIdle(); |
| 56 blob_storage_context_ = blob_storage_context->context(); | 56 blob_storage_context_ = blob_storage_context->context(); |
| 57 | 57 |
| 58 quota_manager_proxy_ = new MockQuotaManagerProxy( | 58 quota_manager_proxy_ = new MockQuotaManagerProxy( |
| 59 nullptr, base::MessageLoopProxy::current().get()); | 59 nullptr, base::MessageLoopProxy::current().get()); |
| 60 | 60 |
| 61 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); | 61 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 79 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 80 cache_ = ServiceWorkerCache::CreatePersistentCache( | 80 cache_ = ServiceWorkerCache::CreatePersistentCache( |
| 81 GURL("http://example.com"), | 81 GURL("http://example.com"), |
| 82 temp_dir_.path(), | 82 temp_dir_.path(), |
| 83 url_request_context, | 83 url_request_context, |
| 84 quota_manager_proxy_, | 84 quota_manager_proxy_, |
| 85 blob_storage_context->context()->AsWeakPtr()); | 85 blob_storage_context->context()->AsWeakPtr()); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void TearDown() override { | 89 void TearDown() override { |
| 90 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 90 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
| 91 base::RunLoop().RunUntilIdle(); | 91 base::RunLoop().RunUntilIdle(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { | 94 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { |
| 95 ServiceWorkerHeaderMap headers; | 95 ServiceWorkerHeaderMap headers; |
| 96 headers.insert(std::make_pair("a", "a")); | 96 headers.insert(std::make_pair("a", "a")); |
| 97 headers.insert(std::make_pair("b", "b")); | 97 headers.insert(std::make_pair("b", "b")); |
| 98 body_request_ = ServiceWorkerFetchRequest( | 98 body_request_ = ServiceWorkerFetchRequest( |
| 99 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); | 99 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 EXPECT_EQ(0, cache_->MemoryBackedSize()); | 591 EXPECT_EQ(0, cache_->MemoryBackedSize()); |
| 592 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 592 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 593 EXPECT_EQ(0, cache_->MemoryBackedSize()); | 593 EXPECT_EQ(0, cache_->MemoryBackedSize()); |
| 594 } | 594 } |
| 595 | 595 |
| 596 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, | 596 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, |
| 597 ServiceWorkerCacheTestP, | 597 ServiceWorkerCacheTestP, |
| 598 ::testing::Values(false, true)); | 598 ::testing::Values(false, true)); |
| 599 | 599 |
| 600 } // namespace content | 600 } // namespace content |
| OLD | NEW |