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

Unified Diff: net/http/http_cache_unittest.cc

Issue 2945002: Disk cache: Switch the disk cache to use the cache_thread.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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') | net/net.gyp » ('j') | 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 51874)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -369,9 +369,7 @@
}
~MockDiskCache() {
- EntryMap::iterator it = entries_.begin();
- for (; it != entries_.end(); ++it)
- it->second->Release();
+ ReleaseAll();
}
virtual int32 GetEntryCount() const {
@@ -496,6 +494,13 @@
// Return entries that fail some of their requests.
void set_soft_failures(bool value) { soft_failures_ = value; }
+ void ReleaseAll() {
+ EntryMap::iterator it = entries_.begin();
+ for (; it != entries_.end(); ++it)
+ it->second->Release();
+ entries_.clear();
+ }
+
private:
typedef base::hash_map<std::string, MockDiskEntry*> EntryMap;
@@ -1720,6 +1725,29 @@
}
}
+// Tests that we can cancel a single request to open a disk cache entry.
+TEST(HttpCache, SimpleGET_CancelCreate) {
+ MockHttpCache cache;
+
+ MockHttpRequest request(kSimpleGET_Transaction);
+
+ Context* c = new Context();
+
+ c->result = cache.http_cache()->CreateTransaction(&c->trans);
+ EXPECT_EQ(net::OK, c->result);
+
+ c->result = c->trans->Start(&request, &c->callback, net::BoundNetLog());
+ EXPECT_EQ(net::ERR_IO_PENDING, c->result);
+
+ // Release the reference that the mock disk cache keeps for this entry, so
+ // that we test that the http cache handles the cancelation correctly.
+ cache.disk_cache()->ReleaseAll();
+ delete c;
+
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+}
+
// Tests that we delete/create entries even if multiple requests are queued.
TEST(HttpCache, SimpleGET_ManyWriters_BypassCache) {
MockHttpCache cache;
« no previous file with comments | « net/http/http_cache.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698