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

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: Updated UMA macro and removed array of costs. 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..44d6f6427d2a796a9ab3b56966d84e9b9bf56bb6 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,16 @@ 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.
Peter Beverloo 2016/05/17 15:54:28 nit: -2 indent
harkness 2016/05/17 16:18:05 Done.
+ }
+ DCHECK(false);
Peter Beverloo 2016/05/17 15:54:28 Since DCHECKS() are removed from release builds, t
harkness 2016/05/17 16:18:05 Done.
+}
+
double BackgroundBudgetService::GetBudget(const GURL& origin) {
DCHECK_EQ(origin, origin.GetOrigin());
@@ -136,6 +148,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