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/dom/TaskRunnerHelper.h" | 10 #include "core/dom/TaskRunnerHelper.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return; | 157 return; |
158 | 158 |
159 Document* document = toDocument(getExecutionContext()); | 159 Document* document = toDocument(getExecutionContext()); |
160 if (!document || !document->frame()) | 160 if (!document || !document->frame()) |
161 return; | 161 return; |
162 | 162 |
163 auto provider = SensorProviderProxy::from(document->frame()); | 163 auto provider = SensorProviderProxy::from(document->frame()); |
164 m_sensorProxy = provider->getSensorProxy(m_type); | 164 m_sensorProxy = provider->getSensorProxy(m_type); |
165 | 165 |
166 if (!m_sensorProxy) { | 166 if (!m_sensorProxy) { |
167 m_sensorProxy = provider->createSensorProxy(m_type, document, | 167 m_sensorProxy = provider->createSensorProxy(m_type, document->page(), |
168 createSensorReadingFactory()); | 168 createSensorReadingFactory()); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 void Sensor::contextDestroyed(ExecutionContext*) { | 172 void Sensor::contextDestroyed(ExecutionContext*) { |
173 if (m_state == Sensor::SensorState::Activated || | 173 if (m_state == Sensor::SensorState::Activated || |
174 m_state == Sensor::SensorState::Activating) | 174 m_state == Sensor::SensorState::Activating) |
175 stopListening(); | 175 stopListening(); |
176 } | 176 } |
177 | 177 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 void Sensor::notifyOnActivate() { | 294 void Sensor::notifyOnActivate() { |
295 dispatchEvent(Event::create(EventTypeNames::activate)); | 295 dispatchEvent(Event::create(EventTypeNames::activate)); |
296 } | 296 } |
297 | 297 |
298 void Sensor::notifyError(DOMException* error) { | 298 void Sensor::notifyError(DOMException* error) { |
299 dispatchEvent( | 299 dispatchEvent( |
300 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 300 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
301 } | 301 } |
302 | 302 |
303 } // namespace blink | 303 } // namespace blink |
OLD | NEW |