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 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 AmbientLightSensorReading* AmbientLightSensor::reading() const { | 33 AmbientLightSensorReading* AmbientLightSensor::reading() const { |
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 return AmbientLightSensorReading::create(proxy); | 38 return AmbientLightSensorReading::create(proxy); |
39 } | 39 } |
40 | 40 |
41 auto AmbientLightSensor::createSensorConfig( | 41 auto AmbientLightSensor::createSensorConfig( |
42 const SensorOptions& options, | 42 const SensorOptions& options, |
43 const SensorConfiguration& defaultConfig) -> SensorConfigurationPtr { | 43 const SensorConfiguration& defaultConfig, |
44 double maxSupportedFrequency) -> SensorConfigurationPtr { | |
44 auto result = device::mojom::blink::SensorConfiguration::New(); | 45 auto result = device::mojom::blink::SensorConfiguration::New(); |
45 result->frequency = | 46 double frequency = |
46 options.hasFrequency() ? options.frequency() : defaultConfig.frequency; | 47 options.hasFrequency() ? options.frequency() : defaultConfig.frequency; |
48 | |
49 if (maxSupportedFrequency && frequency > maxSupportedFrequency) | |
shalamov
2016/11/02 14:42:45
Can this be moved to Sensor or another place, so t
| |
50 frequency = maxSupportedFrequency; | |
51 | |
52 result->frequency = frequency; | |
47 return result; | 53 return result; |
48 } | 54 } |
49 | 55 |
50 DEFINE_TRACE(AmbientLightSensor) { | 56 DEFINE_TRACE(AmbientLightSensor) { |
51 Sensor::trace(visitor); | 57 Sensor::trace(visitor); |
52 } | 58 } |
53 | 59 |
54 } // namespace blink | 60 } // namespace blink |
OLD | NEW |