Chromium Code Reviews| 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; |