Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Unified Diff: net/disk_cache/backend_impl.cc

Issue 9702059: Disk cache: Remove all non essential synchronization from the cache destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698