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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return; | 160 return; |
161 | 161 |
162 Document* document = toDocument(getExecutionContext()); | 162 Document* document = toDocument(getExecutionContext()); |
163 if (!document || !document->frame()) | 163 if (!document || !document->frame()) |
164 return; | 164 return; |
165 | 165 |
166 auto provider = SensorProviderProxy::from(document->frame()); | 166 auto provider = SensorProviderProxy::from(document->frame()); |
167 m_sensorProxy = provider->getSensor(m_type); | 167 m_sensorProxy = provider->getSensor(m_type); |
168 | 168 |
169 if (!m_sensorProxy) { | 169 if (!m_sensorProxy) { |
170 m_sensorProxy = | 170 RefPtr<SecurityOrigin> origin = getExecutionContext()->getSecurityOrigin(); |
171 provider->createSensor(m_type, createSensorReadingFactory()); | 171 DCHECK(origin); |
| 172 m_sensorProxy = provider->createSensor(m_type, std::move(origin), |
| 173 createSensorReadingFactory()); |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 void Sensor::contextDestroyed() { | 177 void Sensor::contextDestroyed() { |
176 if (m_state == Sensor::SensorState::Active || | 178 if (m_state == Sensor::SensorState::Active || |
177 m_state == Sensor::SensorState::Activating) | 179 m_state == Sensor::SensorState::Activating) |
178 stopListening(); | 180 stopListening(); |
179 } | 181 } |
180 | 182 |
181 void Sensor::onSensorInitialized() { | 183 void Sensor::onSensorInitialized() { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 void Sensor::notifyOnActivate() { | 352 void Sensor::notifyOnActivate() { |
351 dispatchEvent(Event::create(EventTypeNames::activate)); | 353 dispatchEvent(Event::create(EventTypeNames::activate)); |
352 } | 354 } |
353 | 355 |
354 void Sensor::notifyError(DOMException* error) { | 356 void Sensor::notifyError(DOMException* error) { |
355 dispatchEvent( | 357 dispatchEvent( |
356 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 358 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
357 } | 359 } |
358 | 360 |
359 } // namespace blink | 361 } // namespace blink |
OLD | NEW |