Chromium Code Reviews| 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 | |
| 32 // Implementation of the Budget API interface. | |
| 28 ScriptPromise getCost(ScriptState*, const AtomicString& actionType); | 33 ScriptPromise getCost(ScriptState*, const AtomicString& actionType); |
| 29 ScriptPromise getBudget(ScriptState*); | 34 ScriptPromise getBudget(ScriptState*); |
| 30 | 35 |
| 36 // Callbacks from the BudgetService to the blink layer. | |
|
Peter Beverloo
2016/08/22 17:57:55
nit: both can be private
harkness
2016/08/23 09:38:18
Done.
| |
| 37 void gotCost(ScriptPromiseResolver*, double) const; | |
|
Peter Beverloo
2016/08/22 17:57:55
nit: name the double
harkness
2016/08/23 09:38:18
Done.
| |
| 38 void gotBudget(ScriptPromiseResolver*, const mojo::WTFArray<mojom::blink::Bu dgetStatePtr>) const; | |
| 39 | |
| 31 DEFINE_INLINE_TRACE() {} | 40 DEFINE_INLINE_TRACE() {} |
| 32 | 41 |
| 33 private: | 42 private: |
| 34 BudgetService(); | 43 BudgetService(); |
| 44 | |
| 45 // Pointer to the Mojo service which will proxy calls to the browser. | |
| 46 mojom::blink::BudgetServicePtr m_service; | |
| 35 }; | 47 }; |
| 36 | 48 |
| 37 } // namespace blink | 49 } // namespace blink |
| 38 | 50 |
| 39 #endif // BudgetService_h | 51 #endif // BudgetService_h |
| OLD | NEW |