| 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/AmbientLightSensor.h" | 5 #include "modules/sensor/AmbientLightSensor.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "modules/sensor/AmbientLightSensorReading.h" | 9 #include "modules/sensor/AmbientLightSensorReading.h" |
| 10 | 10 |
| 11 using device::mojom::blink::SensorType; | 11 using device::mojom::blink::SensorType; |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 AmbientLightSensor* AmbientLightSensor::create(ExecutionContext* context, const
SensorOptions& sensorOptions) | 16 AmbientLightSensor* AmbientLightSensor::create(ScriptState* scriptState, const S
ensorOptions& options, ExceptionState& exceptionState) |
| 17 { | 17 { |
| 18 return new AmbientLightSensor(context, sensorOptions); | 18 return new AmbientLightSensor(scriptState, options, exceptionState); |
| 19 } | 19 } |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 AmbientLightSensor* AmbientLightSensor::create(ExecutionContext* context) | 22 AmbientLightSensor* AmbientLightSensor::create(ScriptState* scriptState, Excepti
onState& exceptionState) |
| 23 { | 23 { |
| 24 return create(context, SensorOptions()); | 24 return create(scriptState, SensorOptions(), exceptionState); |
| 25 } | 25 } |
| 26 | 26 |
| 27 AmbientLightSensor::AmbientLightSensor(ExecutionContext* executionContext, const
SensorOptions& sensorOptions) | 27 AmbientLightSensor::AmbientLightSensor(ScriptState* scriptState, const SensorOpt
ions& options, ExceptionState& exceptionState) |
| 28 : Sensor(executionContext, sensorOptions, SensorType::AMBIENT_LIGHT) | 28 : Sensor(scriptState, options, exceptionState, SensorType::AMBIENT_LIGHT) |
| 29 { | 29 { |
| 30 } | 30 } |
| 31 | 31 |
| 32 AmbientLightSensorReading* AmbientLightSensor::reading() const | 32 AmbientLightSensorReading* AmbientLightSensor::reading() const |
| 33 { | 33 { |
| 34 return static_cast<AmbientLightSensorReading*>(Sensor::reading()); | 34 return static_cast<AmbientLightSensorReading*>(Sensor::reading()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 SensorReading* AmbientLightSensor::createSensorReading(SensorProxy* proxy) | 37 SensorReading* AmbientLightSensor::createSensorReading(SensorProxy* proxy) |
| 38 { | 38 { |
| 39 return AmbientLightSensorReading::create(proxy); | 39 return AmbientLightSensorReading::create(proxy); |
| 40 } | 40 } |
| 41 | 41 |
| 42 auto AmbientLightSensor::createSensorConfig(const SensorOptions& options, const
SensorConfiguration& defaultConfig) -> SensorConfigurationPtr | 42 auto AmbientLightSensor::createSensorConfig(const SensorOptions& options, const
SensorConfiguration& defaultConfig) -> SensorConfigurationPtr |
| 43 { | 43 { |
| 44 auto result = device::mojom::blink::SensorConfiguration::New(); | 44 auto result = device::mojom::blink::SensorConfiguration::New(); |
| 45 result->frequency = options.hasFrequency() ? options.frequency() : defaultCo
nfig.frequency; | 45 result->frequency = options.hasFrequency() ? options.frequency() : defaultCo
nfig.frequency; |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| 48 | 48 |
| 49 DEFINE_TRACE(AmbientLightSensor) | 49 DEFINE_TRACE(AmbientLightSensor) |
| 50 { | 50 { |
| 51 Sensor::trace(visitor); | 51 Sensor::trace(visitor); |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |