| 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 : SuspendableObject(context), | 24 : SuspendableObject(context), |
| 25 PlatformEventController(toDocument(context)->page()) {} | 25 PlatformEventController(toDocument(context)->frame()) {} |
| 26 | 26 |
| 27 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { | 27 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) { |
| 28 if (!m_batteryProperty) { | 28 if (!m_batteryProperty) { |
| 29 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), | 29 m_batteryProperty = new BatteryProperty(scriptState->getExecutionContext(), |
| 30 this, BatteryProperty::Ready); | 30 this, BatteryProperty::Ready); |
| 31 | 31 |
| 32 // 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. |
| 33 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { | 33 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) { |
| 34 m_batteryProperty->resolve(this); | 34 m_batteryProperty->resolve(this); |
| 35 } else { | 35 } else { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 DEFINE_TRACE(BatteryManager) { | 120 DEFINE_TRACE(BatteryManager) { |
| 121 visitor->trace(m_batteryProperty); | 121 visitor->trace(m_batteryProperty); |
| 122 PlatformEventController::trace(visitor); | 122 PlatformEventController::trace(visitor); |
| 123 EventTargetWithInlineData::trace(visitor); | 123 EventTargetWithInlineData::trace(visitor); |
| 124 SuspendableObject::trace(visitor); | 124 SuspendableObject::trace(visitor); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |