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

Unified Diff: net/http/http_cache_unittest.cc

Issue 3016006: Http Cache: Don't delete the callback that is waiting for... (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') | 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 52557)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -667,6 +667,8 @@
void set_fail(bool fail) { fail_ = fail; }
+ net::CompletionCallback* callback() { return callback_; }
+
private:
int Result() { return fail_ ? net::ERR_FAILED : net::OK; }
@@ -1979,6 +1981,36 @@
delete context_list[2];
}
+// Tests that we can delete the cache while creating the backend.
+TEST(HttpCache, DeleteCacheWaitingForBackend) {
+ MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
+ MockHttpCache* cache = new MockHttpCache(factory);
+
+ MockHttpRequest request(kSimpleGET_Transaction);
+
+ 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());
+
+ // Just to make sure that everything is still pending.
+ MessageLoop::current()->RunAllPending();
+
+ // The request should be creating the disk cache.
+ EXPECT_FALSE(c->callback.have_result());
+
+ // We cannot call FinishCreation because the factory itself will go away with
+ // the cache, so grab the callback and attempt to use it.
+ net::CompletionCallback* callback = factory->callback();
+
+ delete cache;
Paweł Hajdan Jr. 2010/07/16 21:45:51 nit: How about using scoped pointers to make it mu
+ MessageLoop::current()->RunAllPending();
+
+ callback->Run(net::ERR_ABORTED);
+ delete c;
Paweł Hajdan Jr. 2010/07/16 21:45:51 Similarly here.
+}
+
TEST(HttpCache, TypicalGET_ConditionalRequest) {
MockHttpCache cache;
« 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