| 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/Gyroscope.h" | 5 #include "modules/sensor/Gyroscope.h" |
| 6 | 6 |
| 7 #include "modules/sensor/GyroscopeReading.h" | |
| 8 | 7 |
| 9 using device::mojom::blink::SensorType; | 8 using device::mojom::blink::SensorType; |
| 10 | 9 |
| 11 namespace blink { | 10 namespace blink { |
| 12 | 11 |
| 13 Gyroscope* Gyroscope::create(ExecutionContext* executionContext, | 12 Gyroscope* Gyroscope::create(ExecutionContext* executionContext, |
| 14 const SensorOptions& options, | 13 const SensorOptions& options, |
| 15 ExceptionState& exceptionState) { | 14 ExceptionState& exceptionState) { |
| 16 return new Gyroscope(executionContext, options, exceptionState); | 15 return new Gyroscope(executionContext, options, exceptionState); |
| 17 } | 16 } |
| 18 | 17 |
| 19 // static | 18 // static |
| 20 Gyroscope* Gyroscope::create(ExecutionContext* executionContext, | 19 Gyroscope* Gyroscope::create(ExecutionContext* executionContext, |
| 21 ExceptionState& exceptionState) { | 20 ExceptionState& exceptionState) { |
| 22 return create(executionContext, SensorOptions(), exceptionState); | 21 return create(executionContext, SensorOptions(), exceptionState); |
| 23 } | 22 } |
| 24 | 23 |
| 25 Gyroscope::Gyroscope(ExecutionContext* executionContext, | 24 Gyroscope::Gyroscope(ExecutionContext* executionContext, |
| 26 const SensorOptions& options, | 25 const SensorOptions& options, |
| 27 ExceptionState& exceptionState) | 26 ExceptionState& exceptionState) |
| 28 : Sensor(executionContext, options, exceptionState, SensorType::GYROSCOPE) { | 27 : Sensor(executionContext, options, exceptionState, SensorType::GYROSCOPE) { |
| 29 } | 28 } |
| 30 | 29 |
| 31 GyroscopeReading* Gyroscope::reading() const { | 30 double Gyroscope::x(bool& isNull) const { |
| 32 return static_cast<GyroscopeReading*>(Sensor::reading()); | 31 return readingValue(0, isNull); |
| 33 } | 32 } |
| 34 | 33 |
| 35 std::unique_ptr<SensorReadingFactory> Gyroscope::createSensorReadingFactory() { | 34 double Gyroscope::y(bool& isNull) const { |
| 36 return WTF::makeUnique<SensorReadingFactoryImpl<GyroscopeReading>>(); | 35 return readingValue(1, isNull); |
| 36 } |
| 37 |
| 38 double Gyroscope::z(bool& isNull) const { |
| 39 return readingValue(2, isNull); |
| 37 } | 40 } |
| 38 | 41 |
| 39 DEFINE_TRACE(Gyroscope) { | 42 DEFINE_TRACE(Gyroscope) { |
| 40 Sensor::trace(visitor); | 43 Sensor::trace(visitor); |
| 41 } | 44 } |
| 42 | 45 |
| 43 } // namespace blink | 46 } // namespace blink |
| OLD | NEW |