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" |
11 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" | 11 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" |
12 #include "modules/sensor/SensorErrorEvent.h" | 12 #include "modules/sensor/SensorErrorEvent.h" |
13 #include "modules/sensor/SensorProviderProxy.h" | 13 #include "modules/sensor/SensorProviderProxy.h" |
14 #include "modules/sensor/SensorReading.h" | 14 #include "modules/sensor/SensorReading.h" |
15 #include "modules/sensor/SensorUpdateNotificationStrategy.h" | 15 #include "modules/sensor/SensorUpdateNotificationStrategy.h" |
16 | 16 |
17 using namespace device::mojom::blink; | 17 using namespace device::mojom::blink; |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 Sensor::Sensor(ExecutionContext* executionContext, | 21 Sensor::Sensor(ExecutionContext* executionContext, |
22 const SensorOptions& sensorOptions, | 22 const SensorOptions& sensorOptions, |
23 ExceptionState& exceptionState, | 23 ExceptionState& exceptionState, |
24 SensorType type) | 24 SensorType type) |
25 : ActiveScriptWrappable<Sensor>(this), | 25 : ContextLifecycleObserver(executionContext), |
26 ContextLifecycleObserver(executionContext), | |
27 m_sensorOptions(sensorOptions), | 26 m_sensorOptions(sensorOptions), |
28 m_type(type), | 27 m_type(type), |
29 m_state(Sensor::SensorState::Idle) { | 28 m_state(Sensor::SensorState::Idle) { |
30 // Check secure context. | 29 // Check secure context. |
31 String errorMessage; | 30 String errorMessage; |
32 if (!executionContext->isSecureContext(errorMessage)) { | 31 if (!executionContext->isSecureContext(errorMessage)) { |
33 exceptionState.throwDOMException(SecurityError, errorMessage); | 32 exceptionState.throwDOMException(SecurityError, errorMessage); |
34 return; | 33 return; |
35 } | 34 } |
36 | 35 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 void Sensor::notifyOnActivate() { | 313 void Sensor::notifyOnActivate() { |
315 dispatchEvent(Event::create(EventTypeNames::activate)); | 314 dispatchEvent(Event::create(EventTypeNames::activate)); |
316 } | 315 } |
317 | 316 |
318 void Sensor::notifyError(DOMException* error) { | 317 void Sensor::notifyError(DOMException* error) { |
319 dispatchEvent( | 318 dispatchEvent( |
320 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 319 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
321 } | 320 } |
322 | 321 |
323 } // namespace blink | 322 } // namespace blink |
OLD | NEW |