Chromium Code Reviews| 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; |
| } |