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_BUDGET_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_BUDGET_SERVICE_BUDGET_MANAGER_H_ |
6 #define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_MANAGER_H_ | 6 #define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Spend budget, first consuming a reservation if one exists, or spend | 57 // Spend budget, first consuming a reservation if one exists, or spend |
58 // directly from the budget. | 58 // directly from the budget. |
59 void Consume(const url::Origin& origin, | 59 void Consume(const url::Origin& origin, |
60 blink::mojom::BudgetOperationType type, | 60 blink::mojom::BudgetOperationType type, |
61 const ConsumeCallback& callback); | 61 const ConsumeCallback& callback); |
62 | 62 |
63 private: | 63 private: |
64 friend class BudgetManagerTest; | 64 friend class BudgetManagerTest; |
65 | 65 |
66 // Called as a callback from BudgetDatabase after it made a SpendBudget | 66 void DidGetBudget(const GetBudgetCallback& callback, |
67 // decision. | 67 blink::mojom::BudgetServiceErrorType error, |
| 68 std::vector<blink::mojom::BudgetStatePtr> budget); |
| 69 |
68 void DidConsume(const ConsumeCallback& callback, | 70 void DidConsume(const ConsumeCallback& callback, |
69 blink::mojom::BudgetServiceErrorType error, | 71 blink::mojom::BudgetServiceErrorType error, |
70 bool success); | 72 bool success); |
71 | 73 |
72 // Called as a callback from BudgetDatabase after it has made a reserve | |
73 // decision. | |
74 void DidReserve(const url::Origin& origin, | 74 void DidReserve(const url::Origin& origin, |
75 const ReserveCallback& callback, | 75 const ReserveCallback& callback, |
76 blink::mojom::BudgetServiceErrorType error, | 76 blink::mojom::BudgetServiceErrorType error, |
77 bool success); | 77 bool success); |
78 | 78 |
79 Profile* profile_; | 79 Profile* profile_; |
80 BudgetDatabase db_; | 80 BudgetDatabase db_; |
81 | 81 |
82 std::map<url::Origin, int> reservation_map_; | 82 std::map<url::Origin, int> reservation_map_; |
83 base::WeakPtrFactory<BudgetManager> weak_ptr_factory_; | 83 base::WeakPtrFactory<BudgetManager> weak_ptr_factory_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(BudgetManager); | 85 DISALLOW_COPY_AND_ASSIGN(BudgetManager); |
86 }; | 86 }; |
87 | 87 |
88 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_MANAGER_H_ | 88 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_MANAGER_H_ |
OLD | NEW |