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

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: Sans style 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) {
gavinp 2012/03/18 00:35:26 Do these long comments call the name kNoRandom int
rvargas (doing something else) 2012/03/20 02:54:23 I hear you, but I guess I'd have a comment here re
+ // 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();
gavinp 2012/03/18 00:35:26 ignore_result(trace_object_.release()); // Leak t
gavinp 2012/03/18 00:35:26 ignore_result(index_.release()); // Do we need th
gavinp 2012/03/18 00:35:26 What what about block_files_ ? I hacked up a patc
+ }
if (background_queue_.BackgroundIsCurrentThread()) {
// Unit tests may use the same thread for everything.
@@ -496,9 +504,9 @@
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_);
}
}
@@ -826,6 +834,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