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

Unified Diff: chrome/browser/push_messaging/background_budget_service.cc

Issue 1889513004: Make BackgroundBudgetService a KeyedService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ses_integration
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: chrome/browser/push_messaging/background_budget_service.cc
diff --git a/chrome/browser/push_messaging/background_budget_service.cc b/chrome/browser/push_messaging/background_budget_service.cc
index 12fa3c8a5b78fa2d4da30ce95bdb4228bee72dbd..4b7654ee9087f72b22e0f84e5b05e04b0474dda6 100644
--- a/chrome/browser/push_messaging/background_budget_service.cc
+++ b/chrome/browser/push_messaging/background_budget_service.cc
@@ -72,23 +72,25 @@ bool GetBudgetDataFromPrefValue(const std::string& pref_value,
} // namespace
+BackgroundBudgetService::BackgroundBudgetService(Profile* profile)
+ : profile_(profile) {
+ DCHECK(profile);
+}
+
// static
void BackgroundBudgetService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kBackgroundBudgetMap);
}
-// static
-void BackgroundBudgetService::GetBudget(Profile* profile,
- const GURL& origin,
- double& budget) {
+void BackgroundBudgetService::GetBudget(const GURL& origin, double& budget) {
// Get the current SES score, which we'll use to set a new budget.
- SiteEngagementService* service = SiteEngagementService::Get(profile);
+ SiteEngagementService* service = SiteEngagementService::Get(profile_);
double ses_score = service->GetScore(origin);
// Get the last used budget data. This is a triple of last calculated time,
// budget at that time, and Site Engagement Score (ses) at that time.
- const std::string map_value = GetBudgetDataFromPrefs(profile, origin);
+ const std::string map_value = GetBudgetDataFromPrefs(profile_, origin);
// If there is no stored data, just return data based on the SES.
if (map_value.empty()) {
@@ -120,13 +122,12 @@ void BackgroundBudgetService::GetBudget(Profile* profile,
}
// static
Michael van Ouwerkerk 2016/04/14 14:36:31 nit: no longer
harkness 2016/04/14 17:44:19 Done.
-void BackgroundBudgetService::StoreBudget(Profile* profile,
- const GURL& origin,
+void BackgroundBudgetService::StoreBudget(const GURL& origin,
const double budget) {
// Get the current SES score to write into the prefs with the new budget.
- SiteEngagementService* service = SiteEngagementService::Get(profile);
+ SiteEngagementService* service = SiteEngagementService::Get(profile_);
double ses_score = service->GetScore(origin);
std::string budget_string = MakePrefValueFromBudgetData(budget, ses_score);
- SetBudgetDataInPrefs(profile, origin, budget_string);
+ SetBudgetDataInPrefs(profile_, origin, budget_string);
}

Powered by Google App Engine
This is Rietveld 408576698