| Index: third_party/WebKit/Source/modules/budget_service/NavigatorBudget.cpp
|
| diff --git a/third_party/WebKit/Source/modules/budget_service/NavigatorBudget.cpp b/third_party/WebKit/Source/modules/budget_service/NavigatorBudget.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..311c57027677d84da6b54fb81f9ae2a324e691aa
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/budget_service/NavigatorBudget.cpp
|
| @@ -0,0 +1,65 @@
|
| +// 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_service/NavigatorBudget.h"
|
| +
|
| +#include "bindings/core/v8/ScriptPromise.h"
|
| +#include "bindings/core/v8/ScriptPromiseResolver.h"
|
| +#include "bindings/core/v8/ScriptState.h"
|
| +#include "core/dom/ExceptionCode.h"
|
| +#include "core/frame/Navigator.h"
|
| +
|
| +namespace blink {
|
| +
|
| +NavigatorBudget::NavigatorBudget(Navigator& navigator)
|
| +{
|
| +}
|
| +
|
| +NavigatorBudget::~NavigatorBudget() {}
|
| +
|
| +// 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)
|
| +{
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state);
|
| + ScriptPromise promise = resolver->promise();
|
| +
|
| + // TODO(harkness): Trigger the cost calculation.
|
| + return promise;
|
| +}
|
| +
|
| +// Static
|
| +ScriptPromise NavigatorBudget::getBudget(ScriptState* state,
|
| + Navigator& navigator,
|
| + ExceptionState& exception)
|
| +{
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state);
|
| + ScriptPromise promise = resolver->promise();
|
| +
|
| + // TODO(harkness): Trigger the budget calculation.
|
| + return promise;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|