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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 1908443003: Set site engagement timestamps to privacy-respectful values when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index 9cee47e892206bc47375990ca108894dcadbdcfa..c332cb67d743f66827b43dd8e822c5d400d7060e 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -424,24 +424,29 @@ TopHostsList HistoryBackend::TopHosts(size_t num_hosts) const {
return top_hosts;
}
-OriginCountMap HistoryBackend::GetCountsForOrigins(
+OriginCountAndLastVisitMap HistoryBackend::GetCountsAndLastVisitForOrigins(
const std::set<GURL>& origins) const {
if (!db_)
- return OriginCountMap();
+ return OriginCountAndLastVisitMap();
URLDatabase::URLEnumerator it;
if (!db_->InitURLEnumeratorForEverything(&it))
- return OriginCountMap();
+ return OriginCountAndLastVisitMap();
- OriginCountMap origin_count_map;
+ OriginCountAndLastVisitMap origin_count_map;
for (const GURL& origin : origins)
- origin_count_map[origin] = 0;
+ origin_count_map[origin] = std::make_pair(0, base::Time());
URLRow row;
while (it.GetNextURL(&row)) {
GURL origin = row.url().GetOrigin();
- if (ContainsValue(origins, origin))
- ++origin_count_map[origin];
+ auto iter = origin_count_map.find(origin);
+ if (iter != origin_count_map.end()) {
+ std::pair<int, base::Time>& value = iter->second;
+ ++(value.first);
+ if (value.second.is_null() || value.second < row.last_visit())
+ value.second = row.last_visit();
+ }
}
return origin_count_map;
« no previous file with comments | « components/history/core/browser/history_backend.h ('k') | components/history/core/browser/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698