OLD | NEW |
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/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (!index_metadata.Deserialize(&pickle_it)) { | 415 if (!index_metadata.Deserialize(&pickle_it)) { |
416 LOG(ERROR) << "Invalid index_metadata on Simple Cache Index."; | 416 LOG(ERROR) << "Invalid index_metadata on Simple Cache Index."; |
417 return; | 417 return; |
418 } | 418 } |
419 | 419 |
420 if (!index_metadata.CheckIndexMetadata()) { | 420 if (!index_metadata.CheckIndexMetadata()) { |
421 LOG(ERROR) << "Invalid index_metadata on Simple Cache Index."; | 421 LOG(ERROR) << "Invalid index_metadata on Simple Cache Index."; |
422 return; | 422 return; |
423 } | 423 } |
424 | 424 |
425 #if !defined(OS_WIN) | 425 entries->reserve(index_metadata.GetNumberOfEntries() + kExtraSizeForMerge); |
426 // TODO(gavinp): Consider using std::unordered_map. | |
427 entries->resize(index_metadata.GetNumberOfEntries() + kExtraSizeForMerge); | |
428 #endif | |
429 while (entries->size() < index_metadata.GetNumberOfEntries()) { | 426 while (entries->size() < index_metadata.GetNumberOfEntries()) { |
430 uint64 hash_key; | 427 uint64 hash_key; |
431 EntryMetadata entry_metadata; | 428 EntryMetadata entry_metadata; |
432 if (!pickle_it.ReadUInt64(&hash_key) || | 429 if (!pickle_it.ReadUInt64(&hash_key) || |
433 !entry_metadata.Deserialize(&pickle_it)) { | 430 !entry_metadata.Deserialize(&pickle_it)) { |
434 LOG(WARNING) << "Invalid EntryMetadata in Simple Index file."; | 431 LOG(WARNING) << "Invalid EntryMetadata in Simple Index file."; |
435 entries->clear(); | 432 entries->clear(); |
436 return; | 433 return; |
437 } | 434 } |
438 SimpleIndex::InsertInEntrySet(hash_key, entry_metadata, entries); | 435 SimpleIndex::InsertInEntrySet(hash_key, entry_metadata, entries); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 bool SimpleIndexFile::LegacyIsIndexFileStale( | 472 bool SimpleIndexFile::LegacyIsIndexFileStale( |
476 base::Time cache_last_modified, | 473 base::Time cache_last_modified, |
477 const base::FilePath& index_file_path) { | 474 const base::FilePath& index_file_path) { |
478 base::Time index_mtime; | 475 base::Time index_mtime; |
479 if (!simple_util::GetMTime(index_file_path, &index_mtime)) | 476 if (!simple_util::GetMTime(index_file_path, &index_mtime)) |
480 return true; | 477 return true; |
481 return index_mtime < cache_last_modified; | 478 return index_mtime < cache_last_modified; |
482 } | 479 } |
483 | 480 |
484 } // namespace disk_cache | 481 } // namespace disk_cache |
OLD | NEW |