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

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

Issue 2749823002: Restore KeyedServiceFactory diagnostics for context use-after-destroy. (Closed)
Patch Set: Refactor SiteEngagementService tests. 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 unified diff | Download patch
« no previous file with comments | « apps/app_load_service.cc ('k') | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // thread and does not cause any cleanup, decay, etc. 98 // thread and does not cause any cleanup, decay, etc.
99 // 99 //
100 // Should only be used if you cannot create a SiteEngagementService (i.e. you 100 // Should only be used if you cannot create a SiteEngagementService (i.e. you
101 // cannot run on the UI thread). 101 // cannot run on the UI thread).
102 static double GetScoreFromSettings(HostContentSettingsMap* settings, 102 static double GetScoreFromSettings(HostContentSettingsMap* settings,
103 const GURL& origin); 103 const GURL& origin);
104 104
105 explicit SiteEngagementService(Profile* profile); 105 explicit SiteEngagementService(Profile* profile);
106 ~SiteEngagementService() override; 106 ~SiteEngagementService() override;
107 107
108 // KeyedService support:
109 void Shutdown() override;
110
108 // Returns the engagement level of |url|. 111 // Returns the engagement level of |url|.
109 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const; 112 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const;
110 113
111 // Returns a map of all stored origins and their engagement scores. 114 // Returns a map of all stored origins and their engagement scores.
112 std::map<GURL, double> GetScoreMap() const; 115 std::map<GURL, double> GetScoreMap() const;
113 116
114 // Returns whether the engagement service has enough data to make meaningful 117 // Returns whether the engagement service has enough data to make meaningful
115 // decisions. Clients should avoid using engagement in their heuristic until 118 // decisions. Clients should avoid using engagement in their heuristic until
116 // this is true. 119 // this is true.
117 bool IsBootstrapped() const; 120 bool IsBootstrapped() const;
(...skipping 14 matching lines...) Expand all
132 void HelperCreated(SiteEngagementService::Helper* helper); 135 void HelperCreated(SiteEngagementService::Helper* helper);
133 void HelperDeleted(SiteEngagementService::Helper* helper); 136 void HelperDeleted(SiteEngagementService::Helper* helper);
134 137
135 // Overridden from SiteEngagementScoreProvider. 138 // Overridden from SiteEngagementScoreProvider.
136 double GetScore(const GURL& url) const override; 139 double GetScore(const GURL& url) const override;
137 double GetTotalEngagementPoints() const override; 140 double GetTotalEngagementPoints() const override;
138 141
139 private: 142 private:
140 friend class SiteEngagementObserver; 143 friend class SiteEngagementObserver;
141 friend class SiteEngagementServiceAndroid; 144 friend class SiteEngagementServiceAndroid;
145 friend class SiteEngagementServiceTest;
142 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); 146 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms);
143 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); 147 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores);
144 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, 148 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest,
145 CleanupMovesScoreBackToNow); 149 CleanupMovesScoreBackToNow);
146 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, 150 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest,
147 CleanupMovesScoreBackToRebase); 151 CleanupMovesScoreBackToRebase);
148 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, 152 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest,
149 CleanupEngagementScoresProportional); 153 CleanupEngagementScoresProportional);
150 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); 154 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs);
151 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); 155 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // A list of observers. When any origin registers an engagement-increasing 292 // A list of observers. When any origin registers an engagement-increasing
289 // event, each observer's OnEngagementIncreased method will be called. 293 // event, each observer's OnEngagementIncreased method will be called.
290 base::ObserverList<SiteEngagementObserver> observer_list_; 294 base::ObserverList<SiteEngagementObserver> observer_list_;
291 295
292 base::WeakPtrFactory<SiteEngagementService> weak_factory_; 296 base::WeakPtrFactory<SiteEngagementService> weak_factory_;
293 297
294 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 298 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
295 }; 299 };
296 300
297 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 301 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « apps/app_load_service.cc ('k') | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698