OLD | NEW |
---|---|
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_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ |
6 #define CHROME_BROWSER_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ | 6 #define CHROME_BROWSER_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback_forward.h" | |
11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | |
Michael van Ouwerkerk
2016/06/10 12:10:19
Why is this include needed in the header?
harkness
2016/06/10 14:52:56
Removed.
| |
12 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
15 #include "content/public/browser/browser_thread.h" | |
Michael van Ouwerkerk
2016/06/10 12:10:19
Why is this include needed in the header?
harkness
2016/06/10 14:52:56
This was a bigger review, including some of the in
| |
13 #include "url/gurl.h" | 16 #include "url/gurl.h" |
14 | 17 |
15 class Profile; | 18 class Profile; |
16 | 19 |
17 namespace base { | 20 namespace base { |
18 class Clock; | 21 class Clock; |
19 } | 22 } |
20 | 23 |
21 namespace user_prefs { | 24 namespace user_prefs { |
22 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
(...skipping 11 matching lines...) Expand all Loading... | |
34 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 37 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
35 | 38 |
36 enum class CostType { | 39 enum class CostType { |
37 // The cost of silencing a push message. | 40 // The cost of silencing a push message. |
38 SILENT_PUSH = 0, | 41 SILENT_PUSH = 0, |
39 }; | 42 }; |
40 | 43 |
41 // Query for the base cost for any background processing. | 44 // Query for the base cost for any background processing. |
42 static double GetCost(CostType type); | 45 static double GetCost(CostType type); |
43 | 46 |
44 // Get the budget associated with the origin. This is returned as the double | 47 using GetBudgetCallback = base::Callback<void(double /* budget */)>; |
45 // budget. Budget will be a value between 0.0 and | 48 |
49 // Get the budget associated with the origin. This is passed to the | |
50 // callback. Budget will be a value between 0.0 and | |
46 // SiteEngagementScore::kMaxPoints. | 51 // SiteEngagementScore::kMaxPoints. |
47 double GetBudget(const GURL& origin); | 52 void GetBudget(const GURL& origin, const GetBudgetCallback& callback); |
48 | 53 |
49 // Store the budget associated with the origin. Budget should be a value | 54 // Store the budget associated with the origin. Budget should be a value |
50 // between 0.0 and SiteEngagementScore::kMaxPoints. | 55 // between 0.0 and SiteEngagementScore::kMaxPoints. |
51 void StoreBudget(const GURL& origin, double budget); | 56 void StoreBudget(const GURL& origin, |
57 double budget, | |
58 const base::Closure& closure); | |
Michael van Ouwerkerk
2016/06/10 12:10:19
I expect in future this will become a callback tha
harkness
2016/06/10 14:52:56
Correct. That will happen when I add in the level
| |
52 | 59 |
53 private: | 60 private: |
54 friend class BackgroundBudgetServiceTest; | 61 friend class BackgroundBudgetServiceTest; |
55 | 62 |
56 // Used to allow tests to fast forward/reverse time. | 63 // Used to allow tests to fast forward/reverse time. |
57 void SetClockForTesting(std::unique_ptr<base::Clock> clock); | 64 void SetClockForTesting(std::unique_ptr<base::Clock> clock); |
58 | 65 |
59 // The clock used to vend times. | 66 // The clock used to vend times. |
60 std::unique_ptr<base::Clock> clock_; | 67 std::unique_ptr<base::Clock> clock_; |
61 | 68 |
62 Profile* profile_; | 69 Profile* profile_; |
63 DISALLOW_COPY_AND_ASSIGN(BackgroundBudgetService); | 70 DISALLOW_COPY_AND_ASSIGN(BackgroundBudgetService); |
64 }; | 71 }; |
65 | 72 |
66 #endif // CHROME_BROWSER_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ | 73 #endif // CHROME_BROWSER_BUDGET_SERVICE_BACKGROUND_BUDGET_SERVICE_H_ |
OLD | NEW |