| 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(this), | 24 : ActiveScriptWrappable<BatteryManager>(this), |
| 25 SuspendableObject(context), | 25 SuspendableObject(context), |
| 26 PlatformEventController(toDocument(context)->page()) {} | 26 PlatformEventController(toDocument(context)->page()) {} |
| 27 | 27 |
| 28 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { | 28 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { |
| 29 if (!m_batteryProperty) { | 29 if (!m_batteryProperty) { |
| 30 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), | 30 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), |
| 31 this, BatteryProperty::Ready); | 31 this, BatteryProperty::Ready); |
| 32 | 32 |
| 33 // If the context is in a stopped state already, do not start updating. | 33 // If the context is in a stopped state already, do not start updating. |
| 34 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { | 34 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 DEFINE_TRACE(BatteryManager) { | 122 DEFINE_TRACE(BatteryManager) { |
| 123 visitor->trace(m_batteryProperty); | 123 visitor->trace(m_batteryProperty); |
| 124 PlatformEventController::trace(visitor); | 124 PlatformEventController::trace(visitor); |
| 125 EventTargetWithInlineData::trace(visitor); | 125 EventTargetWithInlineData::trace(visitor); |
| 126 SuspendableObject::trace(visitor); | 126 SuspendableObject::trace(visitor); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |