Chromium Code Reviews| Index: net/disk_cache/backend_impl.cc |
| =================================================================== |
| --- net/disk_cache/backend_impl.cc (revision 126788) |
| +++ net/disk_cache/backend_impl.cc (working copy) |
| @@ -352,7 +352,15 @@ |
| } |
| BackendImpl::~BackendImpl() { |
| - background_queue_.WaitForPendingIO(); |
| + if (user_flags_ & kNoRandom) { |
| + // This is a unit test, so we want to be strict about not leaking entries |
| + // and completing all the work. |
| + background_queue_.WaitForPendingIO(); |
| + } else { |
| + // This is most likely not a test, so we want to do as little work as |
| + // possible at this time, at the price of leaving dirty entries behind. |
| + background_queue_.DropPendingIO(); |
| + } |
| if (background_queue_.BackgroundIsCurrentThread()) { |
| // Unit tests may use the same thread for everything. |
| @@ -496,10 +504,12 @@ |
| if (data_) |
| data_->header.crash = 0; |
| - File::WaitForPendingIO(&num_pending_io_); |
| if (user_flags_ & kNoRandom) { |
| // This is a net_unittest, verify that we are not 'leaking' entries. |
| + File::WaitForPendingIO(&num_pending_io_); |
| DCHECK(!num_refs_); |
| + } else { |
| + File::DropPendingIO(); |
|
gavinp
2012/03/20 15:40:08
This belt and suspenders approach looks good.
|
| } |
| } |
| block_files_.CloseFiles(); |
| @@ -826,6 +836,10 @@ |
| return block_files_.GetFile(address); |
| } |
| +base::WeakPtr<InFlightBackendIO> BackendImpl::GetBackgroundQueue() { |
| + return background_queue_.GetWeakPtr(); |
| +} |
| + |
| bool BackendImpl::CreateExternalFile(Addr* address) { |
| int file_number = data_->header.last_file + 1; |
| Addr file_address(0); |