OLD | NEW |
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 #include "modules/battery/BatteryManager.h" | 5 #include "modules/battery/BatteryManager.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
10 #include "modules/battery/BatteryDispatcher.h" | 10 #include "modules/battery/BatteryDispatcher.h" |
11 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 BatteryManager* BatteryManager::create(ExecutionContext* context) { | 15 BatteryManager* BatteryManager::create(ExecutionContext* context) { |
16 BatteryManager* batteryManager = new BatteryManager(context); | 16 BatteryManager* batteryManager = new BatteryManager(context); |
17 batteryManager->suspendIfNeeded(); | 17 batteryManager->suspendIfNeeded(); |
18 return batteryManager; | 18 return batteryManager; |
19 } | 19 } |
20 | 20 |
21 BatteryManager::~BatteryManager() {} | 21 BatteryManager::~BatteryManager() {} |
22 | 22 |
23 BatteryManager::BatteryManager(ExecutionContext* context) | 23 BatteryManager::BatteryManager(ExecutionContext* context) |
24 : ActiveScriptWrappable<BatteryManager>(this), | 24 : SuspendableObject(context), |
25 SuspendableObject(context), | |
26 PlatformEventController(toDocument(context)->page()) {} | 25 PlatformEventController(toDocument(context)->page()) {} |
27 | 26 |
28 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { | 27 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { |
29 if (!m_batteryProperty) { | 28 if (!m_batteryProperty) { |
30 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), | 29 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), |
31 this, BatteryProperty::Ready); | 30 this, BatteryProperty::Ready); |
32 | 31 |
33 // If the context is in a stopped state already, do not start updating. | 32 // If the context is in a stopped state already, do not start updating. |
34 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { | 33 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { |
35 m_batteryProperty->resolve(this); | 34 m_batteryProperty->resolve(this); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 119 } |
121 | 120 |
122 DEFINE_TRACE(BatteryManager) { | 121 DEFINE_TRACE(BatteryManager) { |
123 visitor->trace(m_batteryProperty); | 122 visitor->trace(m_batteryProperty); |
124 PlatformEventController::trace(visitor); | 123 PlatformEventController::trace(visitor); |
125 EventTargetWithInlineData::trace(visitor); | 124 EventTargetWithInlineData::trace(visitor); |
126 SuspendableObject::trace(visitor); | 125 SuspendableObject::trace(visitor); |
127 } | 126 } |
128 | 127 |
129 } // namespace blink | 128 } // namespace blink |
OLD | NEW |