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

Unified Diff: net/http/http_cache_unittest.cc

Issue 3173030: Http cache: It turns out that the cache destructor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
« net/http/http_cache.cc ('K') | « 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 56707)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -2012,6 +2012,61 @@
callback->Run(net::ERR_ABORTED);
}
+class DeleteCacheCompletionCallback : public TestCompletionCallback {
+ public:
+ explicit DeleteCacheCompletionCallback(MockHttpCache* cache)
+ : cache_(cache) {}
+
+ virtual void RunWithParams(const Tuple1<int>& params) {
+ delete cache_;
+ TestCompletionCallback::RunWithParams(params);
+ }
+
+ private:
+ MockHttpCache* cache_;
+};
+
+// Tests that we can delete the cache while creating the backend, from within
+// one of the callbacks.
+TEST(HttpCache, DeleteCacheWaitingForBackend2) {
+ MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
+ MockHttpCache* cache = new MockHttpCache(factory);
+
+ DeleteCacheCompletionCallback cb(cache);
+ disk_cache::Backend* backend;
+ int rv = cache->http_cache()->GetBackend(&backend, &cb);
+ EXPECT_EQ(net::ERR_IO_PENDING, rv);
+
+ // Now let's queue a regular transaction
+ MockHttpRequest request(kSimpleGET_Transaction);
+
+ scoped_ptr<Context> c(new Context());
+ c->result = cache->http_cache()->CreateTransaction(&c->trans);
+ EXPECT_EQ(net::OK, c->result);
+
+ c->trans->Start(&request, &c->callback, net::BoundNetLog());
+
+ // And another direct backend request.
+ TestCompletionCallback cb2;
+ rv = cache->http_cache()->GetBackend(&backend, &cb2);
+ EXPECT_EQ(net::ERR_IO_PENDING, rv);
+
+ // Just to make sure that everything is still pending.
+ MessageLoop::current()->RunAllPending();
+
+ // The request should be queued.
+ EXPECT_FALSE(c->callback.have_result());
+
+ // Generate the callback.
+ factory->FinishCreation();
+ rv = cb.WaitForResult();
+
+ // The cache should be gone by now.
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(net::OK, c->callback.GetResult(c->result));
+ EXPECT_FALSE(cb2.have_result());
+}
+
TEST(HttpCache, TypicalGET_ConditionalRequest) {
MockHttpCache cache;
« net/http/http_cache.cc ('K') | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698