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

Side by Side Diff: net/disk_cache/simple/simple_index_file.cc

Issue 13933029: Add SimpleCache index file heuristics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/disk_cache/simple/simple_index_file.h" 5 #include "net/disk_cache/simple/simple_index_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 LOG(ERROR) << "Could not write Simple Cache index to temporary file: " 154 LOG(ERROR) << "Could not write Simple Cache index to temporary file: "
155 << temp_filename.value(); 155 << temp_filename.value();
156 file_util::Delete(temp_filename, /* recursive = */ false); 156 file_util::Delete(temp_filename, /* recursive = */ false);
157 return; 157 return;
158 } 158 }
159 // Swap temp and index_file. 159 // Swap temp and index_file.
160 bool result = file_util::ReplaceFile(temp_filename, index_filename); 160 bool result = file_util::ReplaceFile(temp_filename, index_filename);
161 DCHECK(result); 161 DCHECK(result);
162 } 162 }
163 163
164 // static
165 bool SimpleIndexFile::IsIndexFileStale(const base::FilePath& index_filename) {
166 base::PlatformFileInfo dir_info;
167 base::PlatformFileInfo index_info;
168 if (!file_util::GetFileInfo(index_filename.DirName(), &dir_info))
169 return false;
170 DCHECK(dir_info.is_directory);
171 if (!file_util::GetFileInfo(index_filename, &index_info))
172 return false;
173
174 // Index file last_modified must be equal to the directory last_modified since
175 // the last operation we do is ReplaceFile in the
176 // SimpleIndexFile::WriteToDisk().
177 // If not true, we need to restore the index.
178 return index_info.last_modified >= dir_info.last_modified;
179 }
180
164 } // namespace disk_cache 181 } // namespace disk_cache
OLDNEW
« net/disk_cache/simple/simple_index_file.h ('K') | « net/disk_cache/simple/simple_index_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698