| 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" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void BatteryManager::suspend() { | 101 void BatteryManager::suspend() { |
| 102 m_hasEventListener = false; | 102 m_hasEventListener = false; |
| 103 stopUpdating(); | 103 stopUpdating(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void BatteryManager::resume() { | 106 void BatteryManager::resume() { |
| 107 m_hasEventListener = true; | 107 m_hasEventListener = true; |
| 108 startUpdating(); | 108 startUpdating(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void BatteryManager::stop() { | 111 void BatteryManager::contextDestroyed() { |
| 112 m_hasEventListener = false; | 112 m_hasEventListener = false; |
| 113 m_batteryProperty.clear(); | 113 m_batteryProperty.clear(); |
| 114 stopUpdating(); | 114 stopUpdating(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool BatteryManager::hasPendingActivity() const { | 117 bool BatteryManager::hasPendingActivity() const { |
| 118 // Prevent V8 from garbage collecting the wrapper object if there are | 118 // Prevent V8 from garbage collecting the wrapper object if there are |
| 119 // event listeners attached to it. | 119 // event listeners attached to it. |
| 120 return hasEventListeners(); | 120 return hasEventListeners(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 DEFINE_TRACE(BatteryManager) { | 123 DEFINE_TRACE(BatteryManager) { |
| 124 visitor->trace(m_batteryProperty); | 124 visitor->trace(m_batteryProperty); |
| 125 PlatformEventController::trace(visitor); | 125 PlatformEventController::trace(visitor); |
| 126 EventTargetWithInlineData::trace(visitor); | 126 EventTargetWithInlineData::trace(visitor); |
| 127 ActiveDOMObject::trace(visitor); | 127 ActiveDOMObject::trace(visitor); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |