Index: net/http/http_cache_unittest.cc |
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc |
index 60c7ed7c8d75d286465b15c12b4806d86acc6b87..4ac08004838d077ce81187700b55a18c76ef8dea 100644 |
--- a/net/http/http_cache_unittest.cc |
+++ b/net/http/http_cache_unittest.cc |
@@ -1769,6 +1769,35 @@ TEST(HttpCache, SimpleGET_WriterTimeout) { |
ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction); |
} |
+// Tests that a (simulated) timeout allows transactions waiting on the cache |
+// lock to continue but read only transactions to error out. |
+TEST(HttpCache, SimpleGET_WriterTimeoutReadOnlyError) { |
+ MockHttpCache cache; |
+ 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.
|
+ |
+ MockHttpRequest request(kSimpleGET_Transaction); |
+ Context c1, c2; |
+ ASSERT_THAT(cache.CreateTransaction(&c1.trans), IsOk()); |
+ ASSERT_EQ(ERR_IO_PENDING, c1.trans->Start(&request, c1.callback.callback(), |
+ NetLogWithSource())); |
+ |
+ // Using load flags similar to MetadataWriter. |
+ request.load_flags = |
+ LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION | LOAD_SKIP_VARY_CHECK; |
+ ASSERT_THAT(cache.CreateTransaction(&c2.trans), IsOk()); |
+ ASSERT_EQ(ERR_IO_PENDING, c2.trans->Start(&request, c2.callback.callback(), |
+ NetLogWithSource())); |
+ |
+ // The second request is queued after the first one. |
+ |
jkarlin
2017/02/03 13:16:30
Remove this line
shivanisha
2017/02/03 14:58:09
done.
|
+ int res = c2.callback.WaitForResult(); |
+ ASSERT_EQ(ERR_CACHE_MISS, res); |
+ |
+ // Complete the first transaction. |
+ c1.callback.WaitForResult(); |
+ ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction); |
+} |
+ |
TEST(HttpCache, SimpleGET_AbandonedCacheRead) { |
MockHttpCache cache; |