| Index: net/disk_cache/simple/simple_index.cc
|
| diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc
|
| index e68e7468f2071c0f4d27489d57c447c2d8ed0cdf..a654faf37182e5287f715c87cce96efc9bc37045 100644
|
| --- a/net/disk_cache/simple/simple_index.cc
|
| +++ b/net/disk_cache/simple/simple_index.cc
|
| @@ -220,16 +220,14 @@ std::unique_ptr<SimpleIndex::HashList> SimpleIndex::GetEntriesBetween(
|
| end_time = base::Time::Max();
|
| else
|
| end_time += EntryMetadata::GetUpperEpsilonForTimeComparisons();
|
| - const base::Time extended_end_time =
|
| - end_time.is_null() ? base::Time::Max() : end_time;
|
| - DCHECK(extended_end_time >= initial_time);
|
| + DCHECK(end_time >= initial_time);
|
| +
|
| std::unique_ptr<HashList> ret_hashes(new HashList());
|
| - for (EntrySet::iterator it = entries_set_.begin(), end = entries_set_.end();
|
| - it != end; ++it) {
|
| - EntryMetadata& metadata = it->second;
|
| + for (const auto& entry : entries_set_) {
|
| + const EntryMetadata& metadata = entry.second;
|
| base::Time entry_time = metadata.GetLastUsedTime();
|
| - if (initial_time <= entry_time && entry_time < extended_end_time)
|
| - ret_hashes->push_back(it->first);
|
| + if (initial_time <= entry_time && entry_time < end_time)
|
| + ret_hashes->push_back(entry.first);
|
| }
|
| return ret_hashes;
|
| }
|
| @@ -248,6 +246,28 @@ uint64_t SimpleIndex::GetCacheSize() const {
|
| return cache_size_;
|
| }
|
|
|
| +uint64_t SimpleIndex::GetCacheSizeBetween(base::Time initial_time,
|
| + base::Time end_time) const {
|
| + DCHECK_EQ(true, initialized_);
|
| +
|
| + if (!initial_time.is_null())
|
| + initial_time -= EntryMetadata::GetLowerEpsilonForTimeComparisons();
|
| + if (end_time.is_null())
|
| + end_time = base::Time::Max();
|
| + else
|
| + end_time += EntryMetadata::GetUpperEpsilonForTimeComparisons();
|
| +
|
| + DCHECK(end_time >= initial_time);
|
| + uint64_t size = 0;
|
| + for (const auto& entry : entries_set_) {
|
| + const EntryMetadata& metadata = entry.second;
|
| + base::Time entry_time = metadata.GetLastUsedTime();
|
| + if (initial_time <= entry_time && entry_time < end_time)
|
| + size += metadata.GetEntrySize();
|
| + }
|
| + return size;
|
| +}
|
| +
|
| void SimpleIndex::Insert(uint64_t entry_hash) {
|
| DCHECK(io_thread_checker_.CalledOnValidThread());
|
| // Upon insert we don't know yet the size of the entry.
|
|
|