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 #include "modules/budget/NavigatorBudget.h" | 5 #include "modules/budget/NavigatorBudget.h" |
6 | 6 |
7 #include "core/frame/Navigator.h" | 7 #include "core/frame/Navigator.h" |
8 #include "modules/budget/Budget.h" | 8 #include "modules/budget/BudgetService.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 NavigatorBudget::NavigatorBudget() | 12 NavigatorBudget::NavigatorBudget() |
13 { | 13 { |
14 } | 14 } |
15 | 15 |
16 // static | 16 // static |
17 const char* NavigatorBudget::supplementName() | 17 const char* NavigatorBudget::supplementName() |
18 { | 18 { |
19 return "NavigatorBudget"; | 19 return "NavigatorBudget"; |
20 } | 20 } |
21 | 21 |
22 // static | 22 // static |
23 NavigatorBudget& NavigatorBudget::from(Navigator& navigator) | 23 NavigatorBudget& NavigatorBudget::from(Navigator& navigator) |
24 { | 24 { |
25 // Get the unique NavigatorBudget associated with this navigator. | 25 // Get the unique NavigatorBudget associated with this navigator. |
26 NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement<
Navigator>::from(navigator, supplementName())); | 26 NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement<
Navigator>::from(navigator, supplementName())); |
27 if (!navigatorBudget) { | 27 if (!navigatorBudget) { |
28 // If there isn't one already, create it now and associate it. | 28 // If there isn't one already, create it now and associate it. |
29 navigatorBudget = new NavigatorBudget(); | 29 navigatorBudget = new NavigatorBudget(); |
30 Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorB
udget); | 30 Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorB
udget); |
31 } | 31 } |
32 return *navigatorBudget; | 32 return *navigatorBudget; |
33 } | 33 } |
34 | 34 |
35 Budget* NavigatorBudget::budget() | 35 BudgetService* NavigatorBudget::budget() |
36 { | 36 { |
37 if (!m_budget) | 37 if (!m_budget) |
38 m_budget = Budget::create(); | 38 m_budget = BudgetService::create(); |
39 return m_budget.get(); | 39 return m_budget.get(); |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
43 Budget* NavigatorBudget::budget(Navigator& navigator) | 43 BudgetService* NavigatorBudget::budget(Navigator& navigator) |
44 { | 44 { |
45 return NavigatorBudget::from(navigator).budget(); | 45 return NavigatorBudget::from(navigator).budget(); |
46 } | 46 } |
47 | 47 |
48 DEFINE_TRACE(NavigatorBudget) | 48 DEFINE_TRACE(NavigatorBudget) |
49 { | 49 { |
50 visitor->trace(m_budget); | 50 visitor->trace(m_budget); |
51 Supplement<Navigator>::trace(visitor); | 51 Supplement<Navigator>::trace(visitor); |
52 } | 52 } |
53 | 53 |
54 } // namespace blink | 54 } // namespace blink |
OLD | NEW |