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_service/NavigatorBudget.h" |
| 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "core/frame/Navigator.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 NavigatorBudget::NavigatorBudget(Navigator& navigator) |
| 16 { |
| 17 } |
| 18 |
| 19 NavigatorBudget::~NavigatorBudget() {} |
| 20 |
| 21 // Static |
| 22 const char* NavigatorBudget::supplementName() |
| 23 { |
| 24 return "NavigatorBudget"; |
| 25 } |
| 26 |
| 27 // Static |
| 28 NavigatorBudget& NavigatorBudget::from(Navigator& navigator) |
| 29 { |
| 30 // Get the unique NavigatorBudget associated with this navigator. |
| 31 NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement<
Navigator>::from(navigator, supplementName())); |
| 32 if (!navigatorBudget) { |
| 33 // If there has not already been a NavigatorBudget created for |
| 34 // this navigator, create one now and associate it. |
| 35 navigatorBudget = new NavigatorBudget(navigator); |
| 36 Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorB
udget); |
| 37 } |
| 38 return *navigatorBudget; |
| 39 } |
| 40 |
| 41 // Static |
| 42 ScriptPromise NavigatorBudget::getCost(ScriptState* state, |
| 43 Navigator& navigator, |
| 44 const AtomicString& actionType) |
| 45 { |
| 46 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state); |
| 47 ScriptPromise promise = resolver->promise(); |
| 48 |
| 49 // TODO(harkness): Trigger the cost calculation. |
| 50 return promise; |
| 51 } |
| 52 |
| 53 // Static |
| 54 ScriptPromise NavigatorBudget::getBudget(ScriptState* state, |
| 55 Navigator& navigator, |
| 56 ExceptionState& exception) |
| 57 { |
| 58 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state); |
| 59 ScriptPromise promise = resolver->promise(); |
| 60 |
| 61 // TODO(harkness): Trigger the budget calculation. |
| 62 return promise; |
| 63 } |
| 64 |
| 65 } // namespace blink |
OLD | NEW |