Chromium Code Reviews| 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" | |
|
Peter Beverloo
2016/07/01 13:21:59
unused
harkness
2016/07/20 09:41:48
It's used now.
| |
| 10 #include "core/dom/ExceptionCode.h" | |
|
Peter Beverloo
2016/07/01 13:21:59
unused
harkness
2016/07/20 09:41:48
It's used now. :)
| |
| 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 | |
|
Peter Beverloo
2016/07/01 13:21:59
nit: // static (no capital)
dito on lines 27, 41
harkness
2016/07/20 09:41:48
Done.
| |
| 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) | |
|
Peter Beverloo
2016/07/01 13:21:59
nit: here (and with the other method definitions):
harkness
2016/07/20 09:41:48
Done.
| |
| 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 // Static | |
| 66 ScriptPromise NavigatorBudget::getBudgetDetails(ScriptState* state, | |
| 67 Navigator& navigator, | |
| 68 ExceptionState& exception) | |
| 69 { | |
| 70 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state); | |
| 71 ScriptPromise promise = resolver->promise(); | |
| 72 | |
| 73 // TODO(harkness): Trigger the budget calculation. | |
| 74 return promise; | |
| 75 } | |
| 76 | |
| 77 } // namespace blink | |
| OLD | NEW |