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

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: Integrated code review comments 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..17a95835302470475e4d3c23a00be82d5e84851e 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,15 @@ void BackgroundBudgetService::RegisterProfilePrefs(
registry->RegisterDictionaryPref(prefs::kBackgroundBudgetMap);
}
+double BackgroundBudgetService::costs_[] = {
+ 2.0, // SILENT_PUSH_COST
+};
+
+// static
+double BackgroundBudgetService::GetBackgroundProcessingCost(CostType type) {
+ return costs_[type];
+}
+
double BackgroundBudgetService::GetBudget(const GURL& origin) {
DCHECK_EQ(origin, origin.GetOrigin());
@@ -136,6 +147,15 @@ 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);
+
+ // Generate histograms for the GetBudget calls which would return "no budget"
+ // or "low budget" if an API was available to app developers.
+ double cost = GetBackgroundProcessingCost(SILENT_PUSH_COST);
+ if (budget < cost)
+ UMA_HISTOGRAM_COUNTS("PushMessaging.SESForNoBudgetOrigin", ses_score);
+ else if (budget < 2.0 * cost)
+ UMA_HISTOGRAM_COUNTS("PushMessaging.SESForLowBudgetOrigin", ses_score);
Peter Beverloo 2016/05/17 13:51:01 To this and the other histograms: UMA_HISTOGRAM_C
Peter Beverloo 2016/05/17 14:03:23 Scratch this part, sorry! You're recording the *SE
harkness 2016/05/17 15:49:32 I updated to UMA_HISTOGRAM_COUNTS_100 for all thre
+
return budget;
}

Powered by Google App Engine
This is Rietveld 408576698