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