| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 base::RunLoop().RunUntilIdle(); | 82 base::RunLoop().RunUntilIdle(); |
| 83 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 83 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 84 base::RunLoop().RunUntilIdle(); | 84 base::RunLoop().RunUntilIdle(); |
| 85 cache_ = NULL; | 85 cache_ = NULL; |
| 86 base::RunLoop().RunUntilIdle(); | 86 base::RunLoop().RunUntilIdle(); |
| 87 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 87 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 88 base::RunLoop().RunUntilIdle(); | 88 base::RunLoop().RunUntilIdle(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { | 91 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { |
| 92 std::map<std::string, std::string> headers; | 92 ServiceWorkerHeaderMap headers; |
| 93 headers.insert(std::make_pair("a", "a")); | 93 headers.insert(std::make_pair("a", "a")); |
| 94 headers.insert(std::make_pair("b", "b")); | 94 headers.insert(std::make_pair("b", "b")); |
| 95 body_request_ = ServiceWorkerFetchRequest( | 95 body_request_ = ServiceWorkerFetchRequest( |
| 96 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); | 96 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); |
| 97 no_body_request_ = | 97 no_body_request_ = |
| 98 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), | 98 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), |
| 99 "GET", | 99 "GET", |
| 100 headers, | 100 headers, |
| 101 GURL(""), | 101 GURL(""), |
| 102 false); | 102 false); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 TEST_P(ServiceWorkerCacheTestP, QuickStressBody) { | 391 TEST_P(ServiceWorkerCacheTestP, QuickStressBody) { |
| 392 for (int i = 0; i < 100; ++i) { | 392 for (int i = 0; i < 100; ++i) { |
| 393 ASSERT_FALSE(Match(body_request_)); | 393 ASSERT_FALSE(Match(body_request_)); |
| 394 ASSERT_TRUE(Put(body_request_, body_response_)); | 394 ASSERT_TRUE(Put(body_request_, body_response_)); |
| 395 ASSERT_TRUE(Match(body_request_)); | 395 ASSERT_TRUE(Match(body_request_)); |
| 396 ASSERT_TRUE(Delete(body_request_)); | 396 ASSERT_TRUE(Delete(body_request_)); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 #endif // OS_WIN | 399 #endif // OS_WIN |
| 400 | 400 |
| 401 TEST_F(ServiceWorkerCacheTest, CaselessServiceWorkerResponseHeaders) { |
| 402 // ServiceWorkerCache depends on ServiceWorkerResponse having caseless |
| 403 // headers so that it can quickly lookup vary headers. |
| 404 ServiceWorkerResponse response( |
| 405 GURL("http://www.example.com"), 200, "OK", ServiceWorkerHeaderMap(), ""); |
| 406 response.headers["content-type"] = "foo"; |
| 407 response.headers["Content-Type"] = "bar"; |
| 408 EXPECT_EQ("bar", response.headers["content-type"]); |
| 409 } |
| 410 |
| 411 TEST_F(ServiceWorkerCacheTest, CaselessServiceWorkerFetchRequestHeaders) { |
| 412 // ServiceWorkerCache depends on ServiceWorkerFetchRequest having caseless |
| 413 // headers so that it can quickly lookup vary headers. |
| 414 ServiceWorkerFetchRequest request(GURL("http://www.example.com"), |
| 415 "GET", |
| 416 ServiceWorkerHeaderMap(), |
| 417 GURL(""), |
| 418 false); |
| 419 request.headers["content-type"] = "foo"; |
| 420 request.headers["Content-Type"] = "bar"; |
| 421 EXPECT_EQ("bar", request.headers["content-type"]); |
| 422 } |
| 423 |
| 401 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, | 424 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, |
| 402 ServiceWorkerCacheTestP, | 425 ServiceWorkerCacheTestP, |
| 403 ::testing::Values(false, true)); | 426 ::testing::Values(false, true)); |
| 404 | 427 |
| 405 } // namespace content | 428 } // namespace content |
| OLD | NEW |