| 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" |
| 11 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 11 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 12 #include "content/browser/fileapi/mock_url_request_delegate.h" | 12 #include "content/browser/fileapi/mock_url_request_delegate.h" |
| 13 #include "content/common/service_worker/service_worker_types.h" | 13 #include "content/common/service_worker/service_worker_types.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
| 16 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 17 #include "net/disk_cache/simple/simple_backend_impl.h" | |
| 18 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "net/url_request/url_request_job_factory_impl.h" | 19 #include "net/url_request/url_request_job_factory_impl.h" |
| 21 #include "storage/browser/blob/blob_data_handle.h" | 20 #include "storage/browser/blob/blob_data_handle.h" |
| 22 #include "storage/browser/blob/blob_storage_context.h" | 21 #include "storage/browser/blob/blob_storage_context.h" |
| 23 #include "storage/browser/blob/blob_url_request_job_factory.h" | 22 #include "storage/browser/blob/blob_url_request_job_factory.h" |
| 24 #include "storage/common/blob/blob_data.h" | 23 #include "storage/common/blob/blob_data.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 25 |
| 27 namespace content { | 26 namespace content { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 72 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 74 cache_ = ServiceWorkerCache::CreatePersistentCache( | 73 cache_ = ServiceWorkerCache::CreatePersistentCache( |
| 75 temp_dir_.path(), | 74 temp_dir_.path(), |
| 76 url_request_context, | 75 url_request_context, |
| 77 blob_storage_context->context()->AsWeakPtr()); | 76 blob_storage_context->context()->AsWeakPtr()); |
| 78 } | 77 } |
| 79 } | 78 } |
| 80 | 79 |
| 81 virtual void TearDown() OVERRIDE { | 80 virtual void TearDown() OVERRIDE { |
| 82 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 83 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | |
| 84 base::RunLoop().RunUntilIdle(); | |
| 85 cache_ = NULL; | |
| 86 base::RunLoop().RunUntilIdle(); | |
| 87 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | |
| 88 base::RunLoop().RunUntilIdle(); | |
| 89 } | 82 } |
| 90 | 83 |
| 91 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { | 84 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { |
| 92 std::map<std::string, std::string> headers; | 85 std::map<std::string, std::string> headers; |
| 93 headers.insert(std::make_pair("a", "a")); | 86 headers.insert(std::make_pair("a", "a")); |
| 94 headers.insert(std::make_pair("b", "b")); | 87 headers.insert(std::make_pair("b", "b")); |
| 95 body_request_ = ServiceWorkerFetchRequest( | 88 body_request_ = ServiceWorkerFetchRequest( |
| 96 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); | 89 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); |
| 97 no_body_request_ = | 90 no_body_request_ = |
| 98 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), | 91 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ASSERT_TRUE(Delete(body_request_)); | 389 ASSERT_TRUE(Delete(body_request_)); |
| 397 } | 390 } |
| 398 } | 391 } |
| 399 #endif // OS_WIN | 392 #endif // OS_WIN |
| 400 | 393 |
| 401 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, | 394 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, |
| 402 ServiceWorkerCacheTestP, | 395 ServiceWorkerCacheTestP, |
| 403 ::testing::Values(false, true)); | 396 ::testing::Values(false, true)); |
| 404 | 397 |
| 405 } // namespace content | 398 } // namespace content |
| OLD | NEW |