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

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

Issue 2626173003: Calculate the size of all cache entries between two points in time. (Closed)
Patch Set: revert cache_storage_cache_unittest.cc Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_index.h ('k') | net/net.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « net/disk_cache/simple/simple_index.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698