Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/Source/modules/budget/BudgetService.h

Issue 2231873002: Added budget_service.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@budget_api
Patch Set: Add a connection error handler to BudgetService Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
31 DEFINE_INLINE_TRACE() {} 36 DEFINE_INLINE_TRACE() {}
32 37
33 private: 38 private:
39 // Callbacks from the BudgetService to the blink layer.
40 void gotCost(ScriptPromiseResolver*, double cost) const;
41 void gotBudget(ScriptPromiseResolver*, const mojo::WTFArray<mojom::blink::Bu dgetStatePtr> expectations) const;
42
43 // Error handler for use if mojo service doesn't connect.
44 void onConnectionError();
45
34 BudgetService(); 46 BudgetService();
47
48 // Pointer to the Mojo service which will proxy calls to the browser.
49 mojom::blink::BudgetServicePtr m_service;
35 }; 50 };
36 51
37 } // namespace blink 52 } // namespace blink
38 53
39 #endif // BudgetService_h 54 #endif // BudgetService_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698