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

Unified Diff: net/http/http_cache_unittest.cc

Issue 23710059: Release the cache entry on deferred redirect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable new tests on Chrome Frame Created 7 years, 3 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
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 01909ae3c505828c566cde302498e07e4c7e4410..cc5a5e7346a8755d66b41dcac7b66d80d4b5b54d 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -5333,7 +5333,7 @@ TEST(HttpCache, CachedRedirect) {
MockHttpRequest request(kTestTransaction);
net::TestCompletionCallback callback;
- // write to the cache
+ // Write to the cache.
{
scoped_ptr<net::HttpTransaction> trans;
int rv = cache.http_cache()->CreateTransaction(
@@ -5355,6 +5355,9 @@ TEST(HttpCache, CachedRedirect) {
info->headers->EnumerateHeader(NULL, "Location", &location);
EXPECT_EQ(location, "http://www.bar.com/");
+ // Mark the transaction as completed so it is cached.
+ trans->DoneReading();
+
// Destroy transaction when going out of scope. We have not actually
// read the response body -- want to test that it is still getting cached.
}
@@ -5362,7 +5365,12 @@ TEST(HttpCache, CachedRedirect) {
EXPECT_EQ(0, cache.disk_cache()->open_count());
EXPECT_EQ(1, cache.disk_cache()->create_count());
- // read from the cache
+ // Active entries in the cache are not retired synchronously. Make
+ // sure the next run hits the MockHttpCache and open_count is
+ // correct.
+ base::MessageLoop::current()->RunUntilIdle();
+
+ // Read from the cache.
{
scoped_ptr<net::HttpTransaction> trans;
int rv = cache.http_cache()->CreateTransaction(
@@ -5384,6 +5392,9 @@ TEST(HttpCache, CachedRedirect) {
info->headers->EnumerateHeader(NULL, "Location", &location);
EXPECT_EQ(location, "http://www.bar.com/");
+ // Mark the transaction as completed so it is cached.
+ trans->DoneReading();
+
// Destroy transaction when going out of scope. We have not actually
// read the response body -- want to test that it is still getting cached.
}

Powered by Google App Engine
This is Rietveld 408576698