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

Unified Diff: net/disk_cache/backend_impl.cc

Issue 159327: Disk cache: Avoid restarting the cache while it may be in use.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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
« no previous file with comments | « net/disk_cache/backend_impl.h ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/backend_impl.cc
===================================================================
--- net/disk_cache/backend_impl.cc (revision 21362)
+++ net/disk_cache/backend_impl.cc (working copy)
@@ -881,7 +881,8 @@
disabled_ = true;
if (!num_refs_)
- RestartCache();
+ MessageLoop::current()->PostTask(FROM_HERE,
+ factory_.NewRunnableMethod(&BackendImpl::RestartCache));
}
void BackendImpl::ReportError(int error) {
@@ -1066,7 +1067,11 @@
max_size_= current_max_size;
}
+// We always execute this method from the message loop so that we can freely
+// release files, memory pointers etc.
void BackendImpl::RestartCache() {
+ DCHECK(!num_refs_);
+ DCHECK(!open_entries_.size());
PrepareForRestart();
DelayedCacheCleanup(path_);
@@ -1324,7 +1329,7 @@
EntryImpl* BackendImpl::GetEnumeratedEntry(CacheRankingsBlock* next,
bool to_evict) {
- if (!next)
+ if (!next || disabled_)
return NULL;
EntryImpl* entry;
@@ -1440,7 +1445,8 @@
num_refs_--;
if (!num_refs_ && disabled_)
- RestartCache();
+ MessageLoop::current()->PostTask(FROM_HERE,
+ factory_.NewRunnableMethod(&BackendImpl::RestartCache));
}
void BackendImpl::IncreaseNumEntries() {
« no previous file with comments | « net/disk_cache/backend_impl.h ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698