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 "config.h" | 5 #include "config.h" |
6 #include "modules/battery/BatteryManager.h" | 6 #include "modules/battery/BatteryManager.h" |
7 | 7 |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 m_batteryStatus = BatteryDispatcher::instance().latestData(); | 82 m_batteryStatus = BatteryDispatcher::instance().latestData(); |
83 | 83 |
84 if (m_state == Pending) { | 84 if (m_state == Pending) { |
85 ASSERT(m_resolver); | 85 ASSERT(m_resolver); |
86 m_state = Resolved; | 86 m_state = Resolved; |
87 m_resolver->resolve(this); | 87 m_resolver->resolve(this); |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 Document* document = toDocument(executionContext()); | 91 Document* document = toDocument(executionContext()); |
92 if (document->activeDOMObjectsAreSuspended() || document->activeDOMObjectsAr eStopped()) | 92 if (!document || document->activeDOMObjectsAreSuspended() || document->activ eDOMObjectsAreStopped()) |
mlamouri (slow - plz ping)
2014/09/30 17:08:49
Is there any situation where we expect !document?
| |
93 return; | 93 return; |
94 | 94 |
95 ASSERT(oldStatus); | 95 ASSERT(oldStatus); |
96 | 96 |
97 if (m_batteryStatus->charging() != oldStatus->charging()) | 97 if (m_batteryStatus->charging() != oldStatus->charging()) |
98 dispatchEvent(Event::create(EventTypeNames::chargingchange)); | 98 dispatchEvent(Event::create(EventTypeNames::chargingchange)); |
99 if (m_batteryStatus->chargingTime() != oldStatus->chargingTime()) | 99 if (m_batteryStatus->chargingTime() != oldStatus->chargingTime()) |
100 dispatchEvent(Event::create(EventTypeNames::chargingtimechange)); | 100 dispatchEvent(Event::create(EventTypeNames::chargingtimechange)); |
101 if (m_batteryStatus->dischargingTime() != oldStatus->dischargingTime()) | 101 if (m_batteryStatus->dischargingTime() != oldStatus->dischargingTime()) |
102 dispatchEvent(Event::create(EventTypeNames::dischargingtimechange)); | 102 dispatchEvent(Event::create(EventTypeNames::dischargingtimechange)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 bool BatteryManager::hasPendingActivity() const | 141 bool BatteryManager::hasPendingActivity() const |
142 { | 142 { |
143 // Prevent V8 from garbage collecting the wrapper object if there are | 143 // Prevent V8 from garbage collecting the wrapper object if there are |
144 // event listeners attached to it. | 144 // event listeners attached to it. |
145 return m_state == Resolved && hasEventListeners(); | 145 return m_state == Resolved && hasEventListeners(); |
146 } | 146 } |
147 | 147 |
148 void BatteryManager::trace(Visitor* visitor) | 148 void BatteryManager::trace(Visitor* visitor) |
149 { | 149 { |
150 visitor->trace(m_batteryStatus); | 150 visitor->trace(m_batteryStatus); |
151 PlatformEventController::trace(visitor); | |
151 EventTargetWithInlineData::trace(visitor); | 152 EventTargetWithInlineData::trace(visitor); |
152 } | 153 } |
153 | 154 |
154 } // namespace blink | 155 } // namespace blink |
OLD | NEW |