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

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

Issue 1977423002: Added UMA stats to track the budget for any service worker which receives a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NOTREACHED and nits Created 4 years, 7 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 5963bc288873b2ae56b54911f30177f9bb108c42..636dc32ce77e308396eac114e5b0a07621e06ad6 100644
--- a/chrome/browser/push_messaging/background_budget_service.cc
+++ b/chrome/browser/push_messaging/background_budget_service.cc
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
@@ -24,7 +25,8 @@
namespace {
constexpr char kSeparator = '#';
-// We calculate the ratio of the different components of a budget with respect
+
+// Calculate the ratio of the different components of a budget with respect
// to a maximum time period of 10 days = 864000.0 seconds.
constexpr double kSecondsToAccumulate = 864000.0;
@@ -95,6 +97,17 @@ void BackgroundBudgetService::RegisterProfilePrefs(
registry->RegisterDictionaryPref(prefs::kBackgroundBudgetMap);
}
+// static
+double BackgroundBudgetService::GetCost(CostType type) {
+ switch (type) {
+ case CostType::SILENT_PUSH:
+ return 2.0;
+ // No default case.
+ }
+ NOTREACHED();
+ return SiteEngagementScore::kMaxPoints + 1.0;
+}
+
double BackgroundBudgetService::GetBudget(const GURL& origin) {
DCHECK_EQ(origin, origin.GetOrigin());
@@ -136,6 +149,7 @@ double BackgroundBudgetService::GetBudget(const GURL& origin) {
// component, which gives extra budget to sites that have a high ses score.
double budget = budget_carryover + ses_component;
DCHECK_GE(budget, 0.0);
+
return budget;
}

Powered by Google App Engine
This is Rietveld 408576698