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

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

Issue 2039283002: Create new directory for budget_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added PRESUMBIT.py Created 4 years, 6 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
(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 <memory>
9 #include <string>
10
11 #include "base/gtest_prod_util.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "url/gurl.h"
14
15 class Profile;
16
17 namespace base {
18 class Clock;
19 }
20
21 namespace user_prefs {
22 class PrefRegistrySyncable;
23 }
24
25 // A budget service to help Chrome decide how much background work a service
26 // worker should be able to do on behalf of the user. The budget is calculated
27 // based on the Site Engagment Score and is consumed when a service worker does
28 // background work on behalf of the user.
29 class BackgroundBudgetService : public KeyedService {
30 public:
31 explicit BackgroundBudgetService(Profile* profile);
32 ~BackgroundBudgetService() override;
33
34 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
35
36 enum class CostType {
37 // The cost of silencing a push message.
38 SILENT_PUSH = 0,
39 };
40
41 // Query for the base cost for any background processing.
42 static double GetCost(CostType type);
43
44 // Get the budget associated with the origin. This is returned as the double
45 // budget. Budget will be a value between 0.0 and
46 // SiteEngagementScore::kMaxPoints.
47 double GetBudget(const GURL& origin);
48
49 // Store the budget associated with the origin. Budget should be a value
50 // between 0.0 and SiteEngagementScore::kMaxPoints.
51 void StoreBudget(const GURL& origin, double budget);
52
53 private:
54 friend class BackgroundBudgetServiceTest;
55
56 // Used to allow tests to fast forward/reverse time.
57 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
58
59 // The clock used to vend times.
60 std::unique_ptr<base::Clock> clock_;
61
62 Profile* profile_;
63 DISALLOW_COPY_AND_ASSIGN(BackgroundBudgetService);
64 };
65
66 #endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/browser/push_messaging/background_budget_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698