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

Side by Side Diff: chrome/browser/push_messaging/background_budget_service.h

Issue 1889513004: Make BackgroundBudgetService a KeyedService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ses_integration
Patch Set: Apply diffs to master branch to remove SES dependency Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ 6 #define CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "components/keyed_service/core/keyed_service.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 class Profile; 13 class Profile;
14 14
15 namespace user_prefs { 15 namespace user_prefs {
16 class PrefRegistrySyncable; 16 class PrefRegistrySyncable;
17 } 17 }
18 18
19 // A budget service to help Chrome decide how much background work a service 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 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. 21 // implements a grace period of 1 non-visual notification in 10.
22 class BackgroundBudgetService { 22 class BackgroundBudgetService : public KeyedService {
23 public: 23 public:
24 explicit BackgroundBudgetService(Profile* profile);
25 ~BackgroundBudgetService() override {}
26
24 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
25 28
26 // Get the budget associated with the origin. This currently tracks a string 29 // Get the budget associated with the origin. This currently tracks a string
27 // which holds 0 and 1 for the last 10 push messages and whether they 30 // which holds 0 and 1 for the last 10 push messages and whether they
28 // triggered a visual notification. 31 // triggered a visual notification.
29 static std::string GetBudget(Profile* profile, const GURL& origin); 32 std::string GetBudget(const GURL& origin);
30 33
31 // Store the budget associated with the origin. notifications_shown is 34 // Store the budget associated with the origin. notifications_shown is
32 // expected to be a string encoding whether the last 10 push messages 35 // expected to be a string encoding whether the last 10 push messages
33 // triggered 36 // triggered
34 // a visual notification. 37 // a visual notification.
35 static void StoreBudget(Profile* profile, 38 void StoreBudget(const GURL& origin, const std::string& notifications_shown);
36 const GURL& origin,
37 const std::string& notifications_shown);
38 39
39 private: 40 private:
40 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundBudgetService); 41 Profile* profile_;
42 DISALLOW_COPY_AND_ASSIGN(BackgroundBudgetService);
41 }; 43 };
42 44
43 #endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_ 45 #endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698