| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BudgetService_h | 5 #ifndef BudgetService_h |
| 6 #define BudgetService_h | 6 #define BudgetService_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "public/platform/modules/budget_service/budget_service.mojom-blink.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 class ScriptPromise; | 14 class ScriptPromise; |
| 15 class ScriptPromiseResolver; |
| 14 class ScriptState; | 16 class ScriptState; |
| 15 | 17 |
| 16 // This is the entry point into the browser for the BudgetService API, which is | 18 // This is the entry point into the browser for the BudgetService API, which is |
| 17 // designed to give origins the ability to perform background operations | 19 // designed to give origins the ability to perform background operations |
| 18 // on the user's behalf. | 20 // on the user's behalf. |
| 19 class BudgetService final : public GarbageCollected<BudgetService>, public Scrip
tWrappable { | 21 class BudgetService final : public GarbageCollectedFinalized<BudgetService>, pub
lic ScriptWrappable { |
| 20 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
| 21 | 23 |
| 22 public: | 24 public: |
| 23 static BudgetService* create() | 25 static BudgetService* create() |
| 24 { | 26 { |
| 25 return new BudgetService(); | 27 return new BudgetService(); |
| 26 } | 28 } |
| 27 | 29 |
| 30 ~BudgetService(); |
| 31 |
| 28 ScriptPromise getCost(ScriptState*, const AtomicString& actionType); | 32 ScriptPromise getCost(ScriptState*, const AtomicString& actionType); |
| 29 ScriptPromise getBudget(ScriptState*); | 33 ScriptPromise getBudget(ScriptState*); |
| 34 void asyncGetCost(ScriptPromiseResolver*, double) const; |
| 35 void asyncGetBudget(ScriptState*, ScriptPromiseResolver*, const mojo::WTFArr
ay<mojom::blink::BudgetStatePtr>) const; |
| 30 | 36 |
| 31 DEFINE_INLINE_TRACE() {} | 37 DEFINE_INLINE_TRACE() {} |
| 32 | 38 |
| 33 private: | 39 private: |
| 34 BudgetService(); | 40 BudgetService(); |
| 41 |
| 42 // Pointer to the Mojo service which will proxy calls to the browser. |
| 43 mojom::blink::BudgetServicePtr m_service; |
| 35 }; | 44 }; |
| 36 | 45 |
| 37 } // namespace blink | 46 } // namespace blink |
| 38 | 47 |
| 39 #endif // BudgetService_h | 48 #endif // BudgetService_h |
| OLD | NEW |