Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 class Profile; | |
| 14 | |
| 15 namespace user_prefs { | |
| 16 class PrefRegistrySyncable; | |
| 17 } | |
| 18 | |
| 19 // A budget service to help chrome decide how much background work a service | |
| 20 // worker should be able to do on behalf of the user. The budget currently | |
| 21 // implements a grace period of 1 non-visual notification in 10. | |
| 22 // TODO(harkness) do I need a CHROME_EXPORT? | |
|
Peter Beverloo
2016/04/08 14:29:38
Note: Personally I like using class headers as a T
harkness
2016/04/11 09:37:37
I'll consider doing that in my next patch, but it
| |
| 23 class BackgroundBudgetService { | |
| 24 public: | |
| 25 BackgroundBudgetService() {} | |
|
Peter Beverloo
2016/04/08 14:29:38
If you're going the all static route (we need to t
harkness
2016/04/11 09:37:37
For this patch, I'll go ahead and do that.
| |
| 26 ~BackgroundBudgetService() override {} | |
|
Peter Beverloo
2016/04/08 14:29:38
Note: This (and line 28) will cause a compile fail
harkness
2016/04/11 09:37:37
Done.
| |
| 27 | |
| 28 void Shutdown() override {} | |
| 29 | |
| 30 using BudgetCallback = base::Callback<void(const std::string& data)>; | |
| 31 | |
| 32 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 33 | |
| 34 // Get the budget associated with the origin. This currently tracks a string | |
| 35 // which holds 0 and 1 for the last 10 push messages and whether they | |
| 36 // triggered a visual notification. | |
| 37 static void GetBudget(Profile* profile, | |
| 38 const GURL& origin, | |
| 39 const BudgetCallback& callback); | |
| 40 | |
| 41 // Store the budget associated with the origin. notifications_shown is | |
| 42 // expected to be a sting encoding whether the last 10 push messages triggered | |
| 43 // a visual notification. | |
| 44 static void StoreBudget(Profile* profile, | |
| 45 const GURL& origin, | |
| 46 const std::string& notifications_shown); | |
| 47 }; | |
| 48 | |
| 49 #endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ | |
| OLD | NEW |