| Index: net/http/http_cache_unittest.cc
|
| ===================================================================
|
| --- net/http/http_cache_unittest.cc (revision 57078)
|
| +++ 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;
|
|
|
|
|