OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/sensor/Sensor.h" | 5 #include "modules/sensor/Sensor.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 #include "core/dom/ExecutionContextTask.h" | 9 #include "core/dom/ExecutionContextTask.h" |
10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 visitor->trace(m_sensorProxy); | 125 visitor->trace(m_sensorProxy); |
126 ActiveScriptWrappable::trace(visitor); | 126 ActiveScriptWrappable::trace(visitor); |
127 ContextLifecycleObserver::trace(visitor); | 127 ContextLifecycleObserver::trace(visitor); |
128 EventTargetWithInlineData::trace(visitor); | 128 EventTargetWithInlineData::trace(visitor); |
129 } | 129 } |
130 | 130 |
131 bool Sensor::hasPendingActivity() const { | 131 bool Sensor::hasPendingActivity() const { |
132 if (m_state == Sensor::SensorState::Idle || | 132 if (m_state == Sensor::SensorState::Idle || |
133 m_state == Sensor::SensorState::Errored) | 133 m_state == Sensor::SensorState::Errored) |
134 return false; | 134 return false; |
135 return hasEventListeners(); | 135 return getExecutionContext() && hasEventListeners(); |
136 } | 136 } |
137 | 137 |
138 auto Sensor::createSensorConfig() -> SensorConfigurationPtr { | 138 auto Sensor::createSensorConfig() -> SensorConfigurationPtr { |
139 auto result = SensorConfiguration::New(); | 139 auto result = SensorConfiguration::New(); |
140 | 140 |
141 double defaultFrequency = m_sensorProxy->defaultConfig()->frequency; | 141 double defaultFrequency = m_sensorProxy->defaultConfig()->frequency; |
142 double maximumFrequency = m_sensorProxy->maximumFrequency(); | 142 double maximumFrequency = m_sensorProxy->maximumFrequency(); |
143 | 143 |
144 double frequency = m_sensorOptions.hasFrequency() | 144 double frequency = m_sensorOptions.hasFrequency() |
145 ? m_sensorOptions.frequency() | 145 ? m_sensorOptions.frequency() |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 void Sensor::notifyOnActivate() { | 314 void Sensor::notifyOnActivate() { |
315 dispatchEvent(Event::create(EventTypeNames::activate)); | 315 dispatchEvent(Event::create(EventTypeNames::activate)); |
316 } | 316 } |
317 | 317 |
318 void Sensor::notifyError(DOMException* error) { | 318 void Sensor::notifyError(DOMException* error) { |
319 dispatchEvent( | 319 dispatchEvent( |
320 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 320 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
321 } | 321 } |
322 | 322 |
323 } // namespace blink | 323 } // namespace blink |
OLD | NEW |