Index: net/http/http_cache.cc |
=================================================================== |
--- net/http/http_cache.cc (revision 52557) |
+++ net/http/http_cache.cc (working copy) |
@@ -134,10 +134,15 @@ |
~BackendCallback() {} |
virtual void RunWithParams(const Tuple1<int>& params) { |
- cache_->OnIOComplete(params.a, pending_op_); |
+ if (cache_) |
+ cache_->OnIOComplete(params.a, pending_op_); |
delete this; |
} |
+ void Cancel() { |
+ cache_ = NULL; |
+ } |
+ |
private: |
HttpCache* cache_; |
PendingOp* pending_op_; |
@@ -283,7 +288,15 @@ |
// though they are waiting for a callback that will never fire. |
PendingOp* pending_op = pending_it->second; |
delete pending_op->writer; |
- delete pending_op->callback; |
+ if (building_backend_) { |
+ // If we don't have a backend, when its construction finishes it will |
+ // deliver the callbacks. |
+ BackendCallback* callback = |
+ static_cast<BackendCallback*>(pending_op->callback); |
+ callback->Cancel(); |
+ } else { |
+ delete pending_op->callback; |
+ } |
STLDeleteElements(&pending_op->pending_queue); |
delete pending_op; |