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

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

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/base/test_completion_callback_unittest.cc ('k') | net/disk_cache/simple/simple_index_file_unittest.cc » ('j') | 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 37347c8ad0d458d05bc0980a639f5591919ea021..ac71330386e819222309a6e108d89ae273705671 100644
--- a/net/disk_cache/simple/simple_index_file.cc
+++ b/net/disk_cache/simple/simple_index_file.cc
@@ -199,6 +199,15 @@ void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type,
scoped_ptr<Pickle> pickle,
const base::TimeTicks& start_time,
bool app_on_background) {
+ DCHECK_EQ(index_filename.DirName().value(),
+ temp_index_filename.DirName().value());
+ base::FilePath index_file_directory = temp_index_filename.DirName();
+ if (!base::DirectoryExists(index_file_directory) &&
+ !base::CreateDirectory(index_file_directory)) {
+ LOG(ERROR) << "Could not create a directory to hold the index file";
+ return;
+ }
+
// There is a chance that the index containing all the necessary data about
// newly created entries will appear to be stale. This can happen if on-disk
// part of a Create operation does not fit into the time budget for the index
@@ -211,14 +220,8 @@ void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type,
}
SerializeFinalData(cache_dir_mtime, pickle.get());
if (!WritePickleFile(pickle.get(), temp_index_filename)) {
- if (!base::CreateDirectory(temp_index_filename.DirName())) {
- LOG(ERROR) << "Could not create a directory to hold the index file";
- return;
- }
- if (!WritePickleFile(pickle.get(), temp_index_filename)) {
- LOG(ERROR) << "Failed to write the temporary index file";
- return;
- }
+ LOG(ERROR) << "Failed to write the temporary index file";
+ return;
}
// Atomically rename the temporary index file to become the real one.
« no previous file with comments | « net/base/test_completion_callback_unittest.cc ('k') | net/disk_cache/simple/simple_index_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698