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 "device/generic_sensor/sensor_provider_impl.h" | 5 #include "device/generic_sensor/sensor_provider_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "device/generic_sensor/platform_sensor_provider.h" | 9 #include "device/generic_sensor/platform_sensor_provider.h" |
10 #include "device/generic_sensor/sensor_impl.h" | 10 #include "device/generic_sensor/sensor_impl.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 auto sensor_impl = base::MakeUnique<SensorImpl>(sensor); | 87 auto sensor_impl = base::MakeUnique<SensorImpl>(sensor); |
88 | 88 |
89 auto init_params = mojom::SensorInitParams::New(); | 89 auto init_params = mojom::SensorInitParams::New(); |
90 init_params->memory = std::move(cloned_handle); | 90 init_params->memory = std::move(cloned_handle); |
91 init_params->buffer_offset = SensorReadingSharedBuffer::GetOffset(type); | 91 init_params->buffer_offset = SensorReadingSharedBuffer::GetOffset(type); |
92 init_params->mode = sensor->GetReportingMode(); | 92 init_params->mode = sensor->GetReportingMode(); |
93 init_params->default_configuration = sensor->GetDefaultConfiguration(); | 93 init_params->default_configuration = sensor->GetDefaultConfiguration(); |
94 | 94 |
| 95 double maximum_frequency = sensor->GetMaximumSupportedFrequency(); |
| 96 DCHECK(maximum_frequency > 0); |
| 97 if (maximum_frequency > mojom::SensorConfiguration::kMaxAllowedFrequency) |
| 98 maximum_frequency = mojom::SensorConfiguration::kMaxAllowedFrequency; |
| 99 |
| 100 init_params->maximum_frequency = maximum_frequency; |
| 101 |
95 NotifySensorCreated(std::move(init_params), sensor_impl->GetClient(), | 102 NotifySensorCreated(std::move(init_params), sensor_impl->GetClient(), |
96 callback); | 103 callback); |
97 | 104 |
98 mojo::MakeStrongBinding(std::move(sensor_impl), std::move(sensor_request)); | 105 mojo::MakeStrongBinding(std::move(sensor_impl), std::move(sensor_request)); |
99 } | 106 } |
100 | 107 |
101 } // namespace device | 108 } // namespace device |
OLD | NEW |