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

Unified Diff: net/http/http_cache_unittest.cc

Issue 193043: Http cache: Don't delete sparse entries when we... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
===================================================================
--- net/http/http_cache_unittest.cc (revision 25640)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -2298,6 +2298,42 @@
RemoveMockTransaction(&kRangeGET_TransactionOK);
}
+// Tests that we don't delete a sparse entry when we cancel a request.
+TEST(HttpCache, RangeGET_Cancel) {
+ MockHttpCache cache;
+ cache.http_cache()->set_enable_range_support(true);
+ AddMockTransaction(&kRangeGET_TransactionOK);
+
+ MockHttpRequest request(kRangeGET_TransactionOK);
+
+ Context* c = new Context(cache.http_cache()->CreateTransaction());
+
+ int rv = c->trans->Start(&request, &c->callback, NULL);
+ if (rv == net::ERR_IO_PENDING)
+ rv = c->callback.WaitForResult();
+
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+
+ // Make sure that the entry has some data stored.
+ scoped_refptr<net::IOBufferWithSize> buf = new net::IOBufferWithSize(10);
+ rv = c->trans->Read(buf, buf->size(), &c->callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = c->callback.WaitForResult();
+ EXPECT_EQ(buf->size(), rv);
+
+ // Destroy the transaction.
+ delete c;
+
+ // Verify that the entry has not been deleted.
+ disk_cache::Entry* entry;
+ ASSERT_TRUE(cache.disk_cache()->OpenEntry(kRangeGET_TransactionOK.url,
+ &entry));
+ entry->Close();
+ RemoveMockTransaction(&kRangeGET_TransactionOK);
+}
+
#ifdef NDEBUG
// This test hits a NOTREACHED so it is a release mode only test.
TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) {
« no previous file with comments | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698