Index: net/disk_cache/sparse_control.cc |
=================================================================== |
--- net/disk_cache/sparse_control.cc (revision 53428) |
+++ net/disk_cache/sparse_control.cc (working copy) |
@@ -51,7 +51,7 @@ |
public disk_cache::FileIOCallback { |
public: |
ChildrenDeleter(disk_cache::BackendImpl* backend, const std::string& name) |
- : backend_(backend), name_(name) {} |
+ : backend_(backend->GetWeakPtr()), name_(name) {} |
virtual void OnFileIOComplete(int bytes_copied); |
@@ -66,7 +66,7 @@ |
void DeleteChildren(); |
- disk_cache::BackendImpl* backend_; |
+ base::WeakPtr<disk_cache::BackendImpl> backend_; |
std::string name_; |
disk_cache::Bitmap children_map_; |
int64 signature_; |
@@ -101,6 +101,9 @@ |
void ChildrenDeleter::ReadData(disk_cache::Addr address, int len) { |
DCHECK(address.is_block_file()); |
+ if (!backend_) |
+ return Release(); |
+ |
disk_cache::File* file(backend_->File(address)); |
if (!file) |
return Release(); |
@@ -121,7 +124,7 @@ |
void ChildrenDeleter::DeleteChildren() { |
int child_id = 0; |
- if (!children_map_.FindNextSetBit(&child_id)) { |
+ if (!children_map_.FindNextSetBit(&child_id) || !backend_) { |
// We are done. Just delete this object. |
return Release(); |
} |