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

Side by Side Diff: chrome/browser/engagement/site_engagement_service.h

Issue 2788413003: Add SiteEngagementService::GetAllDetails(), to return detailed scores. (Closed)
Patch Set: Tweak names, add std::move() in Mojo get path Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
dominickn 2017/04/10 00:58:11 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/engagement/site_engagement_details.mojom.h"
18 #include "chrome/browser/engagement/site_engagement_metrics.h" 19 #include "chrome/browser/engagement/site_engagement_metrics.h"
19 #include "chrome/browser/engagement/site_engagement_observer.h" 20 #include "chrome/browser/engagement/site_engagement_observer.h"
20 #include "components/history/core/browser/history_service_observer.h" 21 #include "components/history/core/browser/history_service_observer.h"
21 #include "components/keyed_service/core/keyed_service.h" 22 #include "components/keyed_service/core/keyed_service.h"
22 #include "third_party/WebKit/public/platform/site_engagement.mojom.h" 23 #include "third_party/WebKit/public/platform/site_engagement.mojom.h"
23 #include "ui/base/page_transition_types.h" 24 #include "ui/base/page_transition_types.h"
24 25
25 namespace base { 26 namespace base {
26 class Clock; 27 class Clock;
27 } 28 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 explicit SiteEngagementService(Profile* profile); 111 explicit SiteEngagementService(Profile* profile);
111 ~SiteEngagementService() override; 112 ~SiteEngagementService() override;
112 113
113 // KeyedService support: 114 // KeyedService support:
114 void Shutdown() override; 115 void Shutdown() override;
115 116
116 // Returns the engagement level of |url|. 117 // Returns the engagement level of |url|.
117 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const; 118 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const;
118 119
120 // Returns an array of engagement score details for all origins which have
121 // a score, whether due to direct engagement, or other factors that cause
122 // an engagement bonus to be applied.
123 std::vector<mojom::SiteEngagementDetails> GetAllDetails() const;
124
119 // Returns a map of all stored origins and their engagement scores. 125 // Returns a map of all stored origins and their engagement scores.
126 // TODO(wez): Replace calls to this with GetAllDetails()?
120 std::map<GURL, double> GetScoreMap() const; 127 std::map<GURL, double> GetScoreMap() const;
121 128
122 // Update the engagement score of |url| for a notification interaction. 129 // Update the engagement score of |url| for a notification interaction.
123 void HandleNotificationInteraction(const GURL& url); 130 void HandleNotificationInteraction(const GURL& url);
124 131
125 // Returns whether the engagement service has enough data to make meaningful 132 // Returns whether the engagement service has enough data to make meaningful
126 // decisions. Clients should avoid using engagement in their heuristic until 133 // decisions. Clients should avoid using engagement in their heuristic until
127 // this is true. 134 // this is true.
128 bool IsBootstrapped() const; 135 bool IsBootstrapped() const;
129 136
130 // Returns whether |url| has at least the given |level| of engagement. 137 // Returns whether |url| has at least the given |level| of engagement.
131 bool IsEngagementAtLeast(const GURL& url, 138 bool IsEngagementAtLeast(const GURL& url,
132 blink::mojom::EngagementLevel level) const; 139 blink::mojom::EngagementLevel level) const;
133 140
134 // Resets the base engagement for |url| to |score|, clearing daily limits. Any 141 // Resets the base engagement for |url| to |score|, clearing daily limits. Any
135 // bonus engagement that |url| has acquired is not affected by this method, so 142 // bonus engagement that |url| has acquired is not affected by this method, so
136 // the result of GetScore(|url|) may not be the same as |score|. 143 // the result of GetScore(|url|) may not be the same as |score|.
137 void ResetBaseScoreForURL(const GURL& url, double score); 144 void ResetBaseScoreForURL(const GURL& url, double score);
138 145
139 // Update the last time |url| was opened from an installed shortcut to be 146 // Update the last time |url| was opened from an installed shortcut to be
140 // clock_->Now(). 147 // clock_->Now().
141 void SetLastShortcutLaunchTime(const GURL& url); 148 void SetLastShortcutLaunchTime(const GURL& url);
142 149
143 void HelperCreated(SiteEngagementService::Helper* helper); 150 void HelperCreated(SiteEngagementService::Helper* helper);
144 void HelperDeleted(SiteEngagementService::Helper* helper); 151 void HelperDeleted(SiteEngagementService::Helper* helper);
145 152
153 // Returns the site engagement details for the specified |url|.
154 mojom::SiteEngagementDetails GetDetails(const GURL& url) const;
155
146 // Overridden from SiteEngagementScoreProvider. 156 // Overridden from SiteEngagementScoreProvider.
147 double GetScore(const GURL& url) const override; 157 double GetScore(const GURL& url) const override;
148 double GetTotalEngagementPoints() const override; 158 double GetTotalEngagementPoints() const override;
149 159
150 private: 160 private:
151 friend class SiteEngagementObserver; 161 friend class SiteEngagementObserver;
152 friend class SiteEngagementServiceAndroid; 162 friend class SiteEngagementServiceAndroid;
153 friend class SiteEngagementServiceTest; 163 friend class SiteEngagementServiceTest;
154 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); 164 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms);
155 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); 165 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // A list of observers. When any origin registers an engagement-increasing 314 // A list of observers. When any origin registers an engagement-increasing
305 // event, each observer's OnEngagementIncreased method will be called. 315 // event, each observer's OnEngagementIncreased method will be called.
306 base::ObserverList<SiteEngagementObserver> observer_list_; 316 base::ObserverList<SiteEngagementObserver> observer_list_;
307 317
308 base::WeakPtrFactory<SiteEngagementService> weak_factory_; 318 base::WeakPtrFactory<SiteEngagementService> weak_factory_;
309 319
310 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 320 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
311 }; 321 };
312 322
313 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 323 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698