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

Side by Side Diff: Source/modules/battery/BatteryManager.h

Issue 976373002: Return same promise consistently when using navigator.getBattery() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 BatteryManager_h 5 #ifndef BatteryManager_h
6 #define BatteryManager_h 6 #define BatteryManager_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseProperty.h"
10 #include "core/dom/ActiveDOMObject.h"
10 #include "core/dom/ContextLifecycleObserver.h" 11 #include "core/dom/ContextLifecycleObserver.h"
11 #include "core/frame/PlatformEventController.h" 12 #include "core/frame/PlatformEventController.h"
12 #include "modules/EventTargetModules.h" 13 #include "modules/EventTargetModules.h"
13 #include "platform/heap/Handle.h" 14 #include "platform/heap/Handle.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class BatteryStatus; 18 class BatteryStatus;
18 19
19 class BatteryManager final : public RefCountedGarbageCollectedEventTargetWithInl ineData<BatteryManager>, public ActiveDOMObject, public PlatformEventController { 20 class BatteryManager final : public RefCountedGarbageCollectedEventTargetWithInl ineData<BatteryManager>, public ActiveDOMObject, public PlatformEventController {
(...skipping 29 matching lines...) Expand all
49 50
50 // ActiveDOMObject implementation. 51 // ActiveDOMObject implementation.
51 virtual void suspend() override; 52 virtual void suspend() override;
52 virtual void resume() override; 53 virtual void resume() override;
53 virtual void stop() override; 54 virtual void stop() override;
54 virtual bool hasPendingActivity() const override; 55 virtual bool hasPendingActivity() const override;
55 56
56 DECLARE_VIRTUAL_TRACE(); 57 DECLARE_VIRTUAL_TRACE();
57 58
58 private: 59 private:
59 enum State {
60 NotStarted,
61 Pending,
62 Resolved,
63 };
64
65 explicit BatteryManager(ExecutionContext*); 60 explicit BatteryManager(ExecutionContext*);
66 61
67 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; 62 typedef ScriptPromiseProperty<Member<BatteryManager>, Member<BatteryManager> , RefPtrWillBeMember<DOMException>> BatteryProperty;
mlamouri (slow - plz ping) 2015/03/07 14:54:42 nit: you can use C++11 form which I think is more
timvolodine 2015/03/12 13:53:11 Done.
63 Member<BatteryProperty> m_batteryProperty;
68 Member<BatteryStatus> m_batteryStatus; 64 Member<BatteryStatus> m_batteryStatus;
69 State m_state; 65 bool m_isResolved;
70 }; 66 };
71 67
72 } // namespace blink 68 } // namespace blink
73 69
74 #endif // BatteryManager_h 70 #endif // BatteryManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698