Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: net/http/http_cache_unittest.cc

Issue 345643003: Http cache: Implement a timeout for the cache lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add constant Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/mock_http_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index c87fa1b7eecba7e2f12fef38c342b24e87325947..83241ab301e441665f6acf3f1b794fa7e5f9f183 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1699,6 +1699,33 @@ TEST(HttpCache, SimpleGET_ManyWriters_BypassCache) {
}
}
+// Tests that a (simulated) timeout allows transactions waiting on the cache
+// lock to continue.
+TEST(HttpCache, SimpleGET_WriterTimeout) {
+ MockHttpCache cache;
+ cache.BypassCacheLock();
+
+ MockHttpRequest request(kSimpleGET_Transaction);
+ Context c1, c2;
+ ASSERT_EQ(net::OK, cache.CreateTransaction(&c1.trans));
+ ASSERT_EQ(net::ERR_IO_PENDING,
+ c1.trans->Start(&request, c1.callback.callback(),
+ net::BoundNetLog()));
+ ASSERT_EQ(net::OK, cache.CreateTransaction(&c2.trans));
+ ASSERT_EQ(net::ERR_IO_PENDING,
+ c2.trans->Start(&request, c2.callback.callback(),
+ net::BoundNetLog()));
+
+ // The second request is queued after the first one.
+
+ c2.callback.WaitForResult();
+ ReadAndVerifyTransaction(c2.trans.get(), kSimpleGET_Transaction);
+
+ // Complete the first transaction.
+ c1.callback.WaitForResult();
+ ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction);
+}
+
TEST(HttpCache, SimpleGET_AbandonedCacheRead) {
MockHttpCache cache;
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/mock_http_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698