| 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 "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 | 1681 |
| 1682 EXPECT_EQ(5, cache.network_layer()->transaction_count()); | 1682 EXPECT_EQ(5, cache.network_layer()->transaction_count()); |
| 1683 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 1683 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| 1684 EXPECT_EQ(5, cache.disk_cache()->create_count()); | 1684 EXPECT_EQ(5, cache.disk_cache()->create_count()); |
| 1685 | 1685 |
| 1686 for (int i = 0; i < kNumTransactions; ++i) { | 1686 for (int i = 0; i < kNumTransactions; ++i) { |
| 1687 delete context_list[i]; | 1687 delete context_list[i]; |
| 1688 } | 1688 } |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 // Tests that a (simulated) timeout allows transactions waiting on the cache | 1691 // Tests that a short timeout allows transactions waiting on the cache lock to |
| 1692 // lock to continue. | 1692 // continue. |
| 1693 TEST(HttpCache, SimpleGET_WriterTimeout) { | 1693 TEST(HttpCache, SimpleGET_WriterTimeout) { |
| 1694 MockHttpCache cache; | 1694 MockHttpCache cache; |
| 1695 cache.BypassCacheLock(); | |
| 1696 | 1695 |
| 1697 MockHttpRequest request(kSimpleGET_Transaction); | 1696 MockHttpRequest request(kSimpleGET_Transaction); |
| 1698 Context c1, c2; | 1697 Context c1, c2; |
| 1699 ASSERT_EQ(OK, cache.CreateTransaction(&c1.trans)); | 1698 ASSERT_EQ(OK, cache.CreateTransaction(&c1.trans)); |
| 1700 ASSERT_EQ(ERR_IO_PENDING, | 1699 ASSERT_EQ(ERR_IO_PENDING, |
| 1701 c1.trans->Start(&request, c1.callback.callback(), BoundNetLog())); | 1700 c1.trans->Start(&request, c1.callback.callback(), BoundNetLog())); |
| 1702 ASSERT_EQ(OK, cache.CreateTransaction(&c2.trans)); | 1701 ASSERT_EQ(OK, cache.CreateTransaction(&c2.trans)); |
| 1703 ASSERT_EQ(ERR_IO_PENDING, | 1702 ASSERT_EQ(ERR_IO_PENDING, |
| 1704 c2.trans->Start(&request, c2.callback.callback(), BoundNetLog())); | 1703 c2.trans->Start(&request, c2.callback.callback(), BoundNetLog())); |
| 1705 | 1704 |
| (...skipping 6012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7718 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 7717 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
| 7719 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 7718 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| 7720 EXPECT_TRUE(response_info.was_cached); | 7719 EXPECT_TRUE(response_info.was_cached); |
| 7721 | 7720 |
| 7722 // The new SSL state is reported. | 7721 // The new SSL state is reported. |
| 7723 EXPECT_EQ(status2, response_info.ssl_info.connection_status); | 7722 EXPECT_EQ(status2, response_info.ssl_info.connection_status); |
| 7724 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get())); | 7723 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get())); |
| 7725 } | 7724 } |
| 7726 | 7725 |
| 7727 } // namespace net | 7726 } // namespace net |
| OLD | NEW |