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

Unified Diff: chrome/browser/engagement/site_engagement_service.cc

Issue 2788413003: Add SiteEngagementService::GetAllDetails(), to return detailed scores. (Closed)
Patch Set: Created 3 years, 9 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: chrome/browser/engagement/site_engagement_service.cc
diff --git a/chrome/browser/engagement/site_engagement_service.cc b/chrome/browser/engagement/site_engagement_service.cc
index 43b83532572753245b9cc3450ba3c21d540158c9..33ac63de28bf557f18667e38b59c404eaf88ba48 100644
--- a/chrome/browser/engagement/site_engagement_service.cc
+++ b/chrome/browser/engagement/site_engagement_service.cc
@@ -139,19 +139,31 @@ SiteEngagementService::GetEngagementLevel(const GURL& url) const {
return CreateEngagementScore(url).GetEngagementLevel();
}
-std::map<GURL, double> SiteEngagementService::GetScoreMap() const {
+std::vector<mojom::SiteEngagementDetails>
+SiteEngagementService::GetScoreDetails() const {
HostContentSettingsMap* settings_map =
HostContentSettingsMapFactory::GetForProfile(profile_);
std::unique_ptr<ContentSettingsForOneType> engagement_settings =
GetEngagementContentSettings(settings_map);
- std::map<GURL, double> score_map;
+ std::vector<mojom::SiteEngagementDetails> scores;
+ scores.reserve(engagement_settings->size());
for (const auto& site : *engagement_settings) {
dominickn 2017/04/06 01:47:16 A nuance here is that sites with only a notificati
Wez 2017/04/08 01:52:53 IIUC correctly what you're saying is basically: s
dominickn 2017/04/10 00:58:11 This is what I had in mind (slight difference to y
Wez 2017/04/10 03:45:28 That makes sense; what I've actually done in the l
dominickn 2017/04/10 04:41:26 It's done using content::PostAfterStartupTask, so
Wez 2017/04/10 21:18:09 Acknowledged.
GURL origin(site.primary_pattern.ToString());
if (!origin.is_valid())
continue;
+ scores.push_back(GetScoreDetails(origin));
+ }
+
+ return scores;
+}
- score_map[origin] = GetScore(origin);
+std::map<GURL, double> SiteEngagementService::GetScoreMap() const {
+ std::vector<mojom::SiteEngagementDetails> scores = GetScoreDetails();
+
+ std::map<GURL, double> score_map;
+ for (const auto& info : scores) {
+ score_map[info.origin] = info.score;
Wez 2017/04/08 01:52:53 Note to self; this also leads to loads of memory c
dominickn 2017/04/10 00:58:11 Even better: we should be able to remove this meth
Wez 2017/04/10 03:45:28 Acknowledged.
}
return score_map;
@@ -244,12 +256,17 @@ void SiteEngagementService::HelperDeleted(
}
double SiteEngagementService::GetScore(const GURL& url) const {
+ return GetScoreDetails(url).score;
+}
+
+mojom::SiteEngagementDetails SiteEngagementService::GetScoreDetails(
Wez 2017/04/08 01:52:53 Note to self: This clashes with GetScoreDetails()
Wez 2017/04/10 03:45:28 Renamed the two in the latest patch.
+ const GURL& url) const {
// Ensure that if engagement is stale, we clean things up before fetching the
// score.
if (IsLastEngagementStale())
CleanupEngagementScores(true);
- return CreateEngagementScore(url).GetScore();
+ return CreateEngagementScore(url).GetDetails();
}
double SiteEngagementService::GetTotalEngagementPoints() const {

Powered by Google App Engine
This is Rietveld 408576698