Index: third_party/WebKit/Source/modules/budget/NavigatorBudget.cpp |
diff --git a/third_party/WebKit/Source/modules/budget/NavigatorBudget.cpp b/third_party/WebKit/Source/modules/budget/NavigatorBudget.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b7a7a09e2bc0f73fca5852fee2ea513acd7b2371 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/budget/NavigatorBudget.cpp |
@@ -0,0 +1,67 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "modules/budget/NavigatorBudget.h" |
+ |
+#include "bindings/core/v8/ScriptPromise.h" |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "bindings/core/v8/ScriptState.h" |
+#include "core/dom/DOMException.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "core/frame/Navigator.h" |
+ |
+namespace blink { |
+ |
+NavigatorBudget::NavigatorBudget(Navigator& navigator) |
+{ |
+} |
+ |
+// static |
+const char* NavigatorBudget::supplementName() |
+{ |
+ return "NavigatorBudget"; |
+} |
+ |
+// static |
+NavigatorBudget& NavigatorBudget::from(Navigator& navigator) |
+{ |
+ // Get the unique NavigatorBudget associated with this navigator. |
+ NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement<Navigator>::from(navigator, supplementName())); |
+ if (!navigatorBudget) { |
+ // If there has not already been a NavigatorBudget created for |
+ // this navigator, create one now and associate it. |
+ navigatorBudget = new NavigatorBudget(navigator); |
+ Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorBudget); |
+ } |
+ return *navigatorBudget; |
+} |
+ |
+// static |
+ScriptPromise NavigatorBudget::getCost(ScriptState* state, Navigator& navigator, const AtomicString& actionType) |
+{ |
+ // TODO(harkness): Trigger the cost calculation. |
+ return ScriptPromise::rejectWithDOMException(state, DOMException::create(NotSupportedError, "Not yet implemented")); |
+} |
+ |
+// static |
+ScriptPromise NavigatorBudget::getBudget(ScriptState* state, Navigator& navigator, ExceptionState& exception) |
+{ |
+ // TODO(harkness): Trigger the budget calculation. |
+ return ScriptPromise::rejectWithDOMException(state, DOMException::create(NotSupportedError, "Not yet implemented")); |
+} |
+ |
+// static |
+ScriptPromise NavigatorBudget::getBudgetDetails(ScriptState* state, Navigator& navigator, ExceptionState& exception) |
+{ |
+ // TODO(harkness): Trigger the budget calculation. |
+ return ScriptPromise::rejectWithDOMException(state, DOMException::create(NotSupportedError, "Not yet implemented")); |
+} |
+ |
+DEFINE_TRACE(NavigatorBudget) |
+{ |
+ Supplement<Navigator>::trace(visitor); |
+ // ContextLifecycleObserver::trace(visitor); |
Peter Beverloo
2016/07/22 12:27:01
remove
harkness
2016/08/03 09:34:05
Done.
|
+} |
+ |
+} // namespace blink |