Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/sensor/Accelerometer.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ScriptPromise.h" | |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 9 #include "modules/sensor/AccelerometerReading.h" | |
| 10 | |
| 11 using device::mojom::blink::SensorType; | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 Accelerometer* Accelerometer::create(ScriptState* scriptState, | |
| 16 const AccelerometerOptions& options, | |
| 17 ExceptionState& exceptionState) { | |
| 18 return new Accelerometer(scriptState, options, exceptionState); | |
| 19 } | |
| 20 | |
| 21 // static | |
| 22 Accelerometer* Accelerometer::create(ScriptState* scriptState, | |
| 23 ExceptionState& exceptionState) { | |
| 24 return create(scriptState, AccelerometerOptions(), exceptionState); | |
| 25 } | |
| 26 | |
| 27 Accelerometer::Accelerometer(ScriptState* scriptState, | |
| 28 const AccelerometerOptions& options, | |
| 29 ExceptionState& exceptionState) | |
| 30 : Sensor(scriptState, options, exceptionState, SensorType::ACCELEROMETER), | |
|
shalamov
2016/11/02 14:25:14
Sensor(scriptState, options, exceptionState, optio
| |
| 31 m_accelerometerOptions(options) {} | |
| 32 | |
| 33 AccelerometerReading* Accelerometer::reading() const { | |
| 34 return static_cast<AccelerometerReading*>(Sensor::reading()); | |
| 35 } | |
| 36 | |
| 37 bool Accelerometer::includesGravity() const { | |
| 38 return m_accelerometerOptions.includeGravity(); | |
| 39 } | |
| 40 | |
| 41 SensorReading* Accelerometer::createSensorReading(SensorProxy* proxy) { | |
| 42 return AccelerometerReading::create(proxy); | |
| 43 } | |
| 44 | |
| 45 auto Accelerometer::createSensorConfig(const SensorOptions& options, | |
| 46 const SensorConfiguration& defaultConfig) | |
| 47 -> SensorConfigurationPtr { | |
| 48 auto result = device::mojom::blink::SensorConfiguration::New(); | |
| 49 result->frequency = | |
| 50 options.hasFrequency() ? options.frequency() : defaultConfig.frequency; | |
| 51 return result; | |
| 52 } | |
| 53 | |
| 54 DEFINE_TRACE(Accelerometer) { | |
| 55 Sensor::trace(visitor); | |
| 56 } | |
| 57 | |
| 58 } // namespace blink | |
| OLD | NEW |