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 #include <memory> | 10 #include <memory> |
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 // The second request is queued after the first one. | 1762 // The second request is queued after the first one. |
1763 | 1763 |
1764 c2.callback.WaitForResult(); | 1764 c2.callback.WaitForResult(); |
1765 ReadAndVerifyTransaction(c2.trans.get(), kSimpleGET_Transaction); | 1765 ReadAndVerifyTransaction(c2.trans.get(), kSimpleGET_Transaction); |
1766 | 1766 |
1767 // Complete the first transaction. | 1767 // Complete the first transaction. |
1768 c1.callback.WaitForResult(); | 1768 c1.callback.WaitForResult(); |
1769 ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction); | 1769 ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction); |
1770 } | 1770 } |
1771 | 1771 |
1772 // Tests that a (simulated) timeout allows transactions waiting on the cache | |
1773 // lock to continue but read only transactions to error out. | |
1774 TEST(HttpCache, SimpleGET_WriterTimeoutReadOnlyError) { | |
1775 MockHttpCache cache; | |
1776 cache.BypassCacheLock(); | |
jkarlin
2017/02/03 13:16:30
nit: Can you add a comment that it's because of th
shivanisha
2017/02/03 14:58:09
done.
| |
1777 | |
1778 MockHttpRequest request(kSimpleGET_Transaction); | |
1779 Context c1, c2; | |
1780 ASSERT_THAT(cache.CreateTransaction(&c1.trans), IsOk()); | |
1781 ASSERT_EQ(ERR_IO_PENDING, c1.trans->Start(&request, c1.callback.callback(), | |
1782 NetLogWithSource())); | |
1783 | |
1784 // Using load flags similar to MetadataWriter. | |
1785 request.load_flags = | |
1786 LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION | LOAD_SKIP_VARY_CHECK; | |
1787 ASSERT_THAT(cache.CreateTransaction(&c2.trans), IsOk()); | |
1788 ASSERT_EQ(ERR_IO_PENDING, c2.trans->Start(&request, c2.callback.callback(), | |
1789 NetLogWithSource())); | |
1790 | |
1791 // The second request is queued after the first one. | |
1792 | |
jkarlin
2017/02/03 13:16:30
Remove this line
shivanisha
2017/02/03 14:58:09
done.
| |
1793 int res = c2.callback.WaitForResult(); | |
1794 ASSERT_EQ(ERR_CACHE_MISS, res); | |
1795 | |
1796 // Complete the first transaction. | |
1797 c1.callback.WaitForResult(); | |
1798 ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction); | |
1799 } | |
1800 | |
1772 TEST(HttpCache, SimpleGET_AbandonedCacheRead) { | 1801 TEST(HttpCache, SimpleGET_AbandonedCacheRead) { |
1773 MockHttpCache cache; | 1802 MockHttpCache cache; |
1774 | 1803 |
1775 // write to the cache | 1804 // write to the cache |
1776 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); | 1805 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
1777 | 1806 |
1778 MockHttpRequest request(kSimpleGET_Transaction); | 1807 MockHttpRequest request(kSimpleGET_Transaction); |
1779 TestCompletionCallback callback; | 1808 TestCompletionCallback callback; |
1780 | 1809 |
1781 std::unique_ptr<HttpTransaction> trans; | 1810 std::unique_ptr<HttpTransaction> trans; |
(...skipping 6472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8254 RunTransactionTestWithResponseInfo(cache.http_cache(), | 8283 RunTransactionTestWithResponseInfo(cache.http_cache(), |
8255 kTypicalGET_Transaction, &response_info); | 8284 kTypicalGET_Transaction, &response_info); |
8256 | 8285 |
8257 EXPECT_FALSE(response_info.was_cached); | 8286 EXPECT_FALSE(response_info.was_cached); |
8258 EXPECT_TRUE(response_info.network_accessed); | 8287 EXPECT_TRUE(response_info.network_accessed); |
8259 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, | 8288 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, |
8260 response_info.cache_entry_status); | 8289 response_info.cache_entry_status); |
8261 } | 8290 } |
8262 | 8291 |
8263 } // namespace net | 8292 } // namespace net |
OLD | NEW |