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

Unified Diff: net/disk_cache/simple/simple_index_file.cc

Issue 691803003: Do not DCHECK on SimpleCache deletion-while-closing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 6 years, 2 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_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_index_file.cc
diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc
index c6a29a28333d99d2617adfa7f26911760c632177..37347c8ad0d458d05bc0980a639f5591919ea021 100644
--- a/net/disk_cache/simple/simple_index_file.cc
+++ b/net/disk_cache/simple/simple_index_file.cc
@@ -71,7 +71,7 @@ void UmaRecordIndexInitMethod(IndexInitMethod method,
bool WritePickleFile(Pickle* pickle, const base::FilePath& file_name) {
File file(
file_name,
- File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE | File::FLAG_SHARE_DELETE);
+ File::FLAG_CREATE | File::FLAG_WRITE | File::FLAG_SHARE_DELETE);
if (!file.IsValid())
return false;
@@ -222,8 +222,11 @@ void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type,
}
// Atomically rename the temporary index file to become the real one.
- bool result = base::ReplaceFile(temp_index_filename, index_filename, NULL);
- DCHECK(result);
+ // TODO(gavinp): DCHECK when not shutting down, since that is very strange.
+ // The rename failing during shutdown is legal because it's legal to begin
+ // erasing a cache as soon as the destructor has been called.
+ if (!base::ReplaceFile(temp_index_filename, index_filename, NULL))
+ return;
if (app_on_background) {
SIMPLE_CACHE_UMA(TIMES,
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698