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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/memory_mapped_file.h" 10 #include "base/files/memory_mapped_file.h"
(...skipping 28 matching lines...) Expand all
39 // Used in histograms. Please only add new values at the end. 39 // Used in histograms. Please only add new values at the end.
40 enum IndexFileState { 40 enum IndexFileState {
41 INDEX_STATE_CORRUPT = 0, 41 INDEX_STATE_CORRUPT = 0,
42 INDEX_STATE_STALE = 1, 42 INDEX_STATE_STALE = 1,
43 INDEX_STATE_FRESH = 2, 43 INDEX_STATE_FRESH = 2,
44 INDEX_STATE_FRESH_CONCURRENT_UPDATES = 3, 44 INDEX_STATE_FRESH_CONCURRENT_UPDATES = 3,
45 INDEX_STATE_MAX = 4, 45 INDEX_STATE_MAX = 4,
46 }; 46 };
47 47
48 void UmaRecordIndexFileState(IndexFileState state, net::CacheType cache_type) { 48 void UmaRecordIndexFileState(IndexFileState state, net::CacheType cache_type) {
49 SIMPLE_CACHE_UMA(ENUMERATION, 49 SIMPLE_CACHE_UMA(
50 "IndexFileStateOnLoad", cache_type, state, INDEX_STATE_MAX); 50 ENUMERATION, "IndexFileStateOnLoad", cache_type, state, INDEX_STATE_MAX);
51 } 51 }
52 52
53 // Used in histograms. Please only add new values at the end. 53 // Used in histograms. Please only add new values at the end.
54 enum IndexInitMethod { 54 enum IndexInitMethod {
55 INITIALIZE_METHOD_RECOVERED = 0, 55 INITIALIZE_METHOD_RECOVERED = 0,
56 INITIALIZE_METHOD_LOADED = 1, 56 INITIALIZE_METHOD_LOADED = 1,
57 INITIALIZE_METHOD_NEWCACHE = 2, 57 INITIALIZE_METHOD_NEWCACHE = 2,
58 INITIALIZE_METHOD_MAX = 3, 58 INITIALIZE_METHOD_MAX = 3,
59 }; 59 };
60 60
61 void UmaRecordIndexInitMethod(IndexInitMethod method, 61 void UmaRecordIndexInitMethod(IndexInitMethod method,
62 net::CacheType cache_type) { 62 net::CacheType cache_type) {
63 SIMPLE_CACHE_UMA(ENUMERATION, 63 SIMPLE_CACHE_UMA(ENUMERATION,
64 "IndexInitializeMethod", cache_type, 64 "IndexInitializeMethod",
65 method, INITIALIZE_METHOD_MAX); 65 cache_type,
66 method,
67 INITIALIZE_METHOD_MAX);
66 } 68 }
67 69
68 bool WritePickleFile(Pickle* pickle, const base::FilePath& file_name) { 70 bool WritePickleFile(Pickle* pickle, const base::FilePath& file_name) {
69 int bytes_written = base::WriteFile( 71 int bytes_written = base::WriteFile(
70 file_name, static_cast<const char*>(pickle->data()), pickle->size()); 72 file_name, static_cast<const char*>(pickle->data()), pickle->size());
71 if (bytes_written != implicit_cast<int>(pickle->size())) { 73 if (bytes_written != implicit_cast<int>(pickle->size())) {
72 base::DeleteFile(file_name, /* recursive = */ false); 74 base::DeleteFile(file_name, /* recursive = */ false);
73 return false; 75 return false;
74 } 76 }
75 return true; 77 return true;
(...skipping 30 matching lines...) Expand all
106 // guaranteed to be more accurate than mtime. It is no worse though. 108 // guaranteed to be more accurate than mtime. It is no worse though.
107 last_used_time = file_info.last_accessed; 109 last_used_time = file_info.last_accessed;
108 #endif 110 #endif
109 if (last_used_time.is_null()) 111 if (last_used_time.is_null())
110 last_used_time = file_info.last_modified; 112 last_used_time = file_info.last_modified;
111 113
112 int64 file_size = file_info.size; 114 int64 file_size = file_info.size;
113 SimpleIndex::EntrySet::iterator it = entries->find(hash_key); 115 SimpleIndex::EntrySet::iterator it = entries->find(hash_key);
114 if (it == entries->end()) { 116 if (it == entries->end()) {
115 SimpleIndex::InsertInEntrySet( 117 SimpleIndex::InsertInEntrySet(
116 hash_key, 118 hash_key, EntryMetadata(last_used_time, file_size), entries);
117 EntryMetadata(last_used_time, file_size),
118 entries);
119 } else { 119 } else {
120 // Summing up the total size of the entry through all the *_[0-1] files 120 // Summing up the total size of the entry through all the *_[0-1] files
121 it->second.SetEntrySize(it->second.GetEntrySize() + file_size); 121 it->second.SetEntrySize(it->second.GetEntrySize() + file_size);
122 } 122 }
123 } 123 }
124 124
125 } // namespace 125 } // namespace
126 126
127 SimpleIndexLoadResult::SimpleIndexLoadResult() : did_load(false), 127 SimpleIndexLoadResult::SimpleIndexLoadResult()
128 flush_required(false) { 128 : did_load(false), flush_required(false) {
129 } 129 }
130 130
131 SimpleIndexLoadResult::~SimpleIndexLoadResult() { 131 SimpleIndexLoadResult::~SimpleIndexLoadResult() {
132 } 132 }
133 133
134 void SimpleIndexLoadResult::Reset() { 134 void SimpleIndexLoadResult::Reset() {
135 did_load = false; 135 did_load = false;
136 flush_required = false; 136 flush_required = false;
137 entries.clear(); 137 entries.clear();
138 } 138 }
139 139
140 // static 140 // static
141 const char SimpleIndexFile::kIndexFileName[] = "the-real-index"; 141 const char SimpleIndexFile::kIndexFileName[] = "the-real-index";
142 // static 142 // static
143 const char SimpleIndexFile::kIndexDirectory[] = "index-dir"; 143 const char SimpleIndexFile::kIndexDirectory[] = "index-dir";
144 // static 144 // static
145 const char SimpleIndexFile::kTempIndexFileName[] = "temp-index"; 145 const char SimpleIndexFile::kTempIndexFileName[] = "temp-index";
146 146
147 SimpleIndexFile::IndexMetadata::IndexMetadata() 147 SimpleIndexFile::IndexMetadata::IndexMetadata()
148 : magic_number_(kSimpleIndexMagicNumber), 148 : magic_number_(kSimpleIndexMagicNumber),
149 version_(kSimpleVersion), 149 version_(kSimpleVersion),
150 number_of_entries_(0), 150 number_of_entries_(0),
151 cache_size_(0) {} 151 cache_size_(0) {
152 }
152 153
153 SimpleIndexFile::IndexMetadata::IndexMetadata( 154 SimpleIndexFile::IndexMetadata::IndexMetadata(uint64 number_of_entries,
154 uint64 number_of_entries, uint64 cache_size) 155 uint64 cache_size)
155 : magic_number_(kSimpleIndexMagicNumber), 156 : magic_number_(kSimpleIndexMagicNumber),
156 version_(kSimpleVersion), 157 version_(kSimpleVersion),
157 number_of_entries_(number_of_entries), 158 number_of_entries_(number_of_entries),
158 cache_size_(cache_size) {} 159 cache_size_(cache_size) {
160 }
159 161
160 void SimpleIndexFile::IndexMetadata::Serialize(Pickle* pickle) const { 162 void SimpleIndexFile::IndexMetadata::Serialize(Pickle* pickle) const {
161 DCHECK(pickle); 163 DCHECK(pickle);
162 pickle->WriteUInt64(magic_number_); 164 pickle->WriteUInt64(magic_number_);
163 pickle->WriteUInt32(version_); 165 pickle->WriteUInt32(version_);
164 pickle->WriteUInt64(number_of_entries_); 166 pickle->WriteUInt64(number_of_entries_);
165 pickle->WriteUInt64(cache_size_); 167 pickle->WriteUInt64(cache_size_);
166 } 168 }
167 169
168 // static 170 // static
169 bool SimpleIndexFile::SerializeFinalData(base::Time cache_modified, 171 bool SimpleIndexFile::SerializeFinalData(base::Time cache_modified,
170 Pickle* pickle) { 172 Pickle* pickle) {
171 if (!pickle->WriteInt64(cache_modified.ToInternalValue())) 173 if (!pickle->WriteInt64(cache_modified.ToInternalValue()))
172 return false; 174 return false;
173 SimpleIndexFile::PickleHeader* header_p = pickle->headerT<PickleHeader>(); 175 SimpleIndexFile::PickleHeader* header_p = pickle->headerT<PickleHeader>();
174 header_p->crc = CalculatePickleCRC(*pickle); 176 header_p->crc = CalculatePickleCRC(*pickle);
175 return true; 177 return true;
176 } 178 }
177 179
178 bool SimpleIndexFile::IndexMetadata::Deserialize(PickleIterator* it) { 180 bool SimpleIndexFile::IndexMetadata::Deserialize(PickleIterator* it) {
179 DCHECK(it); 181 DCHECK(it);
180 return it->ReadUInt64(&magic_number_) && 182 return it->ReadUInt64(&magic_number_) && it->ReadUInt32(&version_) &&
181 it->ReadUInt32(&version_) && 183 it->ReadUInt64(&number_of_entries_) && it->ReadUInt64(&cache_size_);
182 it->ReadUInt64(&number_of_entries_)&&
183 it->ReadUInt64(&cache_size_);
184 } 184 }
185 185
186 void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type, 186 void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type,
187 const base::FilePath& cache_directory, 187 const base::FilePath& cache_directory,
188 const base::FilePath& index_filename, 188 const base::FilePath& index_filename,
189 const base::FilePath& temp_index_filename, 189 const base::FilePath& temp_index_filename,
190 scoped_ptr<Pickle> pickle, 190 scoped_ptr<Pickle> pickle,
191 const base::TimeTicks& start_time, 191 const base::TimeTicks& start_time,
192 bool app_on_background) { 192 bool app_on_background) {
193 // There is a chance that the index containing all the necessary data about 193 // There is a chance that the index containing all the necessary data about
(...skipping 17 matching lines...) Expand all
211 return; 211 return;
212 } 212 }
213 } 213 }
214 214
215 // Atomically rename the temporary index file to become the real one. 215 // Atomically rename the temporary index file to become the real one.
216 bool result = base::ReplaceFile(temp_index_filename, index_filename, NULL); 216 bool result = base::ReplaceFile(temp_index_filename, index_filename, NULL);
217 DCHECK(result); 217 DCHECK(result);
218 218
219 if (app_on_background) { 219 if (app_on_background) {
220 SIMPLE_CACHE_UMA(TIMES, 220 SIMPLE_CACHE_UMA(TIMES,
221 "IndexWriteToDiskTime.Background", cache_type, 221 "IndexWriteToDiskTime.Background",
222 cache_type,
222 (base::TimeTicks::Now() - start_time)); 223 (base::TimeTicks::Now() - start_time));
223 } else { 224 } else {
224 SIMPLE_CACHE_UMA(TIMES, 225 SIMPLE_CACHE_UMA(TIMES,
225 "IndexWriteToDiskTime.Foreground", cache_type, 226 "IndexWriteToDiskTime.Foreground",
227 cache_type,
226 (base::TimeTicks::Now() - start_time)); 228 (base::TimeTicks::Now() - start_time));
227 } 229 }
228 } 230 }
229 231
230 bool SimpleIndexFile::IndexMetadata::CheckIndexMetadata() { 232 bool SimpleIndexFile::IndexMetadata::CheckIndexMetadata() {
231 return number_of_entries_ <= kMaxEntiresInIndex && 233 return number_of_entries_ <= kMaxEntiresInIndex &&
232 magic_number_ == kSimpleIndexMagicNumber && 234 magic_number_ == kSimpleIndexMagicNumber && version_ == kSimpleVersion;
233 version_ == kSimpleVersion;
234 } 235 }
235 236
236 SimpleIndexFile::SimpleIndexFile( 237 SimpleIndexFile::SimpleIndexFile(base::SingleThreadTaskRunner* cache_thread,
237 base::SingleThreadTaskRunner* cache_thread, 238 base::TaskRunner* worker_pool,
238 base::TaskRunner* worker_pool, 239 net::CacheType cache_type,
239 net::CacheType cache_type, 240 const base::FilePath& cache_directory)
240 const base::FilePath& cache_directory)
241 : cache_thread_(cache_thread), 241 : cache_thread_(cache_thread),
242 worker_pool_(worker_pool), 242 worker_pool_(worker_pool),
243 cache_type_(cache_type), 243 cache_type_(cache_type),
244 cache_directory_(cache_directory), 244 cache_directory_(cache_directory),
245 index_file_(cache_directory_.AppendASCII(kIndexDirectory) 245 index_file_(cache_directory_.AppendASCII(kIndexDirectory)
246 .AppendASCII(kIndexFileName)), 246 .AppendASCII(kIndexFileName)),
247 temp_index_file_(cache_directory_.AppendASCII(kIndexDirectory) 247 temp_index_file_(cache_directory_.AppendASCII(kIndexDirectory)
248 .AppendASCII(kTempIndexFileName)) { 248 .AppendASCII(kTempIndexFileName)) {
249 } 249 }
250 250
251 SimpleIndexFile::~SimpleIndexFile() {} 251 SimpleIndexFile::~SimpleIndexFile() {
252 }
252 253
253 void SimpleIndexFile::LoadIndexEntries(base::Time cache_last_modified, 254 void SimpleIndexFile::LoadIndexEntries(base::Time cache_last_modified,
254 const base::Closure& callback, 255 const base::Closure& callback,
255 SimpleIndexLoadResult* out_result) { 256 SimpleIndexLoadResult* out_result) {
256 base::Closure task = base::Bind(&SimpleIndexFile::SyncLoadIndexEntries, 257 base::Closure task = base::Bind(&SimpleIndexFile::SyncLoadIndexEntries,
257 cache_type_, 258 cache_type_,
258 cache_last_modified, cache_directory_, 259 cache_last_modified,
259 index_file_, out_result); 260 cache_directory_,
261 index_file_,
262 out_result);
260 worker_pool_->PostTaskAndReply(FROM_HERE, task, callback); 263 worker_pool_->PostTaskAndReply(FROM_HERE, task, callback);
261 } 264 }
262 265
263 void SimpleIndexFile::WriteToDisk(const SimpleIndex::EntrySet& entry_set, 266 void SimpleIndexFile::WriteToDisk(const SimpleIndex::EntrySet& entry_set,
264 uint64 cache_size, 267 uint64 cache_size,
265 const base::TimeTicks& start, 268 const base::TimeTicks& start,
266 bool app_on_background) { 269 bool app_on_background) {
267 IndexMetadata index_metadata(entry_set.size(), cache_size); 270 IndexMetadata index_metadata(entry_set.size(), cache_size);
268 scoped_ptr<Pickle> pickle = Serialize(index_metadata, entry_set); 271 scoped_ptr<Pickle> pickle = Serialize(index_metadata, entry_set);
269 cache_thread_->PostTask(FROM_HERE, base::Bind( 272 cache_thread_->PostTask(FROM_HERE,
270 &SimpleIndexFile::SyncWriteToDisk, 273 base::Bind(&SimpleIndexFile::SyncWriteToDisk,
271 cache_type_, 274 cache_type_,
272 cache_directory_, 275 cache_directory_,
273 index_file_, 276 index_file_,
274 temp_index_file_, 277 temp_index_file_,
275 base::Passed(&pickle), 278 base::Passed(&pickle),
276 base::TimeTicks::Now(), 279 base::TimeTicks::Now(),
277 app_on_background)); 280 app_on_background));
278 } 281 }
279 282
280 // static 283 // static
281 void SimpleIndexFile::SyncLoadIndexEntries( 284 void SimpleIndexFile::SyncLoadIndexEntries(
282 net::CacheType cache_type, 285 net::CacheType cache_type,
283 base::Time cache_last_modified, 286 base::Time cache_last_modified,
284 const base::FilePath& cache_directory, 287 const base::FilePath& cache_directory,
285 const base::FilePath& index_file_path, 288 const base::FilePath& index_file_path,
286 SimpleIndexLoadResult* out_result) { 289 SimpleIndexLoadResult* out_result) {
287 // Load the index and find its age. 290 // Load the index and find its age.
(...skipping 17 matching lines...) Expand all
305 } 308 }
306 UmaRecordIndexInitMethod(INITIALIZE_METHOD_LOADED, cache_type); 309 UmaRecordIndexInitMethod(INITIALIZE_METHOD_LOADED, cache_type);
307 return; 310 return;
308 } 311 }
309 UmaRecordIndexFileState(INDEX_STATE_STALE, cache_type); 312 UmaRecordIndexFileState(INDEX_STATE_STALE, cache_type);
310 } 313 }
311 314
312 // Reconstruct the index by scanning the disk for entries. 315 // Reconstruct the index by scanning the disk for entries.
313 const base::TimeTicks start = base::TimeTicks::Now(); 316 const base::TimeTicks start = base::TimeTicks::Now();
314 SyncRestoreFromDisk(cache_directory, index_file_path, out_result); 317 SyncRestoreFromDisk(cache_directory, index_file_path, out_result);
315 SIMPLE_CACHE_UMA(MEDIUM_TIMES, "IndexRestoreTime", cache_type, 318 SIMPLE_CACHE_UMA(MEDIUM_TIMES,
319 "IndexRestoreTime",
320 cache_type,
316 base::TimeTicks::Now() - start); 321 base::TimeTicks::Now() - start);
317 SIMPLE_CACHE_UMA(COUNTS, "IndexEntriesRestored", cache_type, 322 SIMPLE_CACHE_UMA(
318 out_result->entries.size()); 323 COUNTS, "IndexEntriesRestored", cache_type, out_result->entries.size());
319 if (index_file_existed) { 324 if (index_file_existed) {
320 UmaRecordIndexInitMethod(INITIALIZE_METHOD_RECOVERED, cache_type); 325 UmaRecordIndexInitMethod(INITIALIZE_METHOD_RECOVERED, cache_type);
321 } else { 326 } else {
322 UmaRecordIndexInitMethod(INITIALIZE_METHOD_NEWCACHE, cache_type); 327 UmaRecordIndexInitMethod(INITIALIZE_METHOD_NEWCACHE, cache_type);
323 SIMPLE_CACHE_UMA(COUNTS, 328 SIMPLE_CACHE_UMA(COUNTS,
324 "IndexCreatedEntryCount", cache_type, 329 "IndexCreatedEntryCount",
330 cache_type,
325 out_result->entries.size()); 331 out_result->entries.size());
326 } 332 }
327 } 333 }
328 334
329 // static 335 // static
330 void SimpleIndexFile::SyncLoadFromDisk(const base::FilePath& index_filename, 336 void SimpleIndexFile::SyncLoadFromDisk(const base::FilePath& index_filename,
331 base::Time* out_last_cache_seen_by_index, 337 base::Time* out_last_cache_seen_by_index,
332 SimpleIndexLoadResult* out_result) { 338 SimpleIndexLoadResult* out_result) {
333 out_result->Reset(); 339 out_result->Reset();
334 340
(...skipping 15 matching lines...) Expand all
350 } 356 }
351 357
352 // static 358 // static
353 scoped_ptr<Pickle> SimpleIndexFile::Serialize( 359 scoped_ptr<Pickle> SimpleIndexFile::Serialize(
354 const SimpleIndexFile::IndexMetadata& index_metadata, 360 const SimpleIndexFile::IndexMetadata& index_metadata,
355 const SimpleIndex::EntrySet& entries) { 361 const SimpleIndex::EntrySet& entries) {
356 scoped_ptr<Pickle> pickle(new Pickle(sizeof(SimpleIndexFile::PickleHeader))); 362 scoped_ptr<Pickle> pickle(new Pickle(sizeof(SimpleIndexFile::PickleHeader)));
357 363
358 index_metadata.Serialize(pickle.get()); 364 index_metadata.Serialize(pickle.get());
359 for (SimpleIndex::EntrySet::const_iterator it = entries.begin(); 365 for (SimpleIndex::EntrySet::const_iterator it = entries.begin();
360 it != entries.end(); ++it) { 366 it != entries.end();
367 ++it) {
361 pickle->WriteUInt64(it->first); 368 pickle->WriteUInt64(it->first);
362 it->second.Serialize(pickle.get()); 369 it->second.Serialize(pickle.get());
363 } 370 }
364 return pickle.Pass(); 371 return pickle.Pass();
365 } 372 }
366 373
367 // static 374 // static
368 void SimpleIndexFile::Deserialize(const char* data, int data_len, 375 void SimpleIndexFile::Deserialize(const char* data,
376 int data_len,
369 base::Time* out_cache_last_modified, 377 base::Time* out_cache_last_modified,
370 SimpleIndexLoadResult* out_result) { 378 SimpleIndexLoadResult* out_result) {
371 DCHECK(data); 379 DCHECK(data);
372 380
373 out_result->Reset(); 381 out_result->Reset();
374 SimpleIndex::EntrySet* entries = &out_result->entries; 382 SimpleIndex::EntrySet* entries = &out_result->entries;
375 383
376 Pickle pickle(data, data_len); 384 Pickle pickle(data, data_len);
377 if (!pickle.data()) { 385 if (!pickle.data()) {
378 LOG(WARNING) << "Corrupt Simple Index File."; 386 LOG(WARNING) << "Corrupt Simple Index File.";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 entries->clear(); 430 entries->clear();
423 return; 431 return;
424 } 432 }
425 DCHECK(out_cache_last_modified); 433 DCHECK(out_cache_last_modified);
426 *out_cache_last_modified = base::Time::FromInternalValue(cache_last_modified); 434 *out_cache_last_modified = base::Time::FromInternalValue(cache_last_modified);
427 435
428 out_result->did_load = true; 436 out_result->did_load = true;
429 } 437 }
430 438
431 // static 439 // static
432 void SimpleIndexFile::SyncRestoreFromDisk( 440 void SimpleIndexFile::SyncRestoreFromDisk(const base::FilePath& cache_directory,
433 const base::FilePath& cache_directory, 441 const base::FilePath& index_file_path,
434 const base::FilePath& index_file_path, 442 SimpleIndexLoadResult* out_result) {
435 SimpleIndexLoadResult* out_result) {
436 VLOG(1) << "Simple Cache Index is being restored from disk."; 443 VLOG(1) << "Simple Cache Index is being restored from disk.";
437 base::DeleteFile(index_file_path, /* recursive = */ false); 444 base::DeleteFile(index_file_path, /* recursive = */ false);
438 out_result->Reset(); 445 out_result->Reset();
439 SimpleIndex::EntrySet* entries = &out_result->entries; 446 SimpleIndex::EntrySet* entries = &out_result->entries;
440 447
441 const bool did_succeed = TraverseCacheDirectory( 448 const bool did_succeed = TraverseCacheDirectory(
442 cache_directory, base::Bind(&ProcessEntryFile, entries)); 449 cache_directory, base::Bind(&ProcessEntryFile, entries));
443 if (!did_succeed) { 450 if (!did_succeed) {
444 LOG(ERROR) << "Could not reconstruct index from disk"; 451 LOG(ERROR) << "Could not reconstruct index from disk";
445 return; 452 return;
446 } 453 }
447 out_result->did_load = true; 454 out_result->did_load = true;
448 // When we restore from disk we write the merged index file to disk right 455 // When we restore from disk we write the merged index file to disk right
449 // away, this might save us from having to restore again next time. 456 // away, this might save us from having to restore again next time.
450 out_result->flush_required = true; 457 out_result->flush_required = true;
451 } 458 }
452 459
453 // static 460 // static
454 bool SimpleIndexFile::LegacyIsIndexFileStale( 461 bool SimpleIndexFile::LegacyIsIndexFileStale(
455 base::Time cache_last_modified, 462 base::Time cache_last_modified,
456 const base::FilePath& index_file_path) { 463 const base::FilePath& index_file_path) {
457 base::Time index_mtime; 464 base::Time index_mtime;
458 if (!simple_util::GetMTime(index_file_path, &index_mtime)) 465 if (!simple_util::GetMTime(index_file_path, &index_mtime))
459 return true; 466 return true;
460 return index_mtime < cache_last_modified; 467 return index_mtime < cache_last_modified;
461 } 468 }
462 469
463 } // namespace disk_cache 470 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698