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/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/events/Event.h" | 8 #include "core/events/Event.h" |
9 #include "modules/battery/BatteryDispatcher.h" | 9 #include "modules/battery/BatteryDispatcher.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 BatteryManager* BatteryManager::create(ExecutionContext* context) | 13 BatteryManager* BatteryManager::create(ExecutionContext* context) |
14 { | 14 { |
15 BatteryManager* batteryManager = new BatteryManager(context); | 15 BatteryManager* batteryManager = new BatteryManager(context); |
16 batteryManager->suspendIfNeeded(); | 16 batteryManager->suspendIfNeeded(); |
17 return batteryManager; | 17 return batteryManager; |
18 } | 18 } |
19 | 19 |
20 BatteryManager::~BatteryManager() | 20 BatteryManager::~BatteryManager() |
21 { | 21 { |
22 #if !ENABLE(OILPAN) | 22 #if !ENABLE(OILPAN) |
23 stopUpdating(); | 23 stopUpdating(); |
24 #endif | 24 #endif |
25 } | 25 } |
26 | 26 |
27 BatteryManager::BatteryManager(ExecutionContext* context) | 27 BatteryManager::BatteryManager(ExecutionContext* context) |
28 : ActiveDOMObject(context) | 28 : ActiveScriptWrappable(this) |
| 29 , ActiveDOMObject(context) |
29 , PlatformEventController(toDocument(context)->page()) | 30 , PlatformEventController(toDocument(context)->page()) |
30 { | 31 { |
31 } | 32 } |
32 | 33 |
33 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) | 34 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) |
34 { | 35 { |
35 if (!m_batteryProperty) { | 36 if (!m_batteryProperty) { |
36 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext
(), this, BatteryProperty::Ready); | 37 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext
(), this, BatteryProperty::Ready); |
37 | 38 |
38 // If the context is in a stopped state already, do not start updating. | 39 // If the context is in a stopped state already, do not start updating. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 138 |
138 DEFINE_TRACE(BatteryManager) | 139 DEFINE_TRACE(BatteryManager) |
139 { | 140 { |
140 visitor->trace(m_batteryProperty); | 141 visitor->trace(m_batteryProperty); |
141 PlatformEventController::trace(visitor); | 142 PlatformEventController::trace(visitor); |
142 RefCountedGarbageCollectedEventTargetWithInlineData<BatteryManager>::trace(v
isitor); | 143 RefCountedGarbageCollectedEventTargetWithInlineData<BatteryManager>::trace(v
isitor); |
143 ActiveDOMObject::trace(visitor); | 144 ActiveDOMObject::trace(visitor); |
144 } | 145 } |
145 | 146 |
146 } // namespace blink | 147 } // namespace blink |
OLD | NEW |