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