Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 auto sensor_impl = base::MakeUnique<SensorImpl>(sensor); | 84 auto sensor_impl = base::MakeUnique<SensorImpl>(sensor); |
| 85 | 85 |
| 86 auto init_params = mojom::SensorInitParams::New(); | 86 auto init_params = mojom::SensorInitParams::New(); |
| 87 init_params->memory = std::move(cloned_handle); | 87 init_params->memory = std::move(cloned_handle); |
| 88 init_params->buffer_offset = SensorReadingSharedBuffer::GetOffset(type); | 88 init_params->buffer_offset = SensorReadingSharedBuffer::GetOffset(type); |
| 89 init_params->mode = sensor->GetReportingMode(); | 89 init_params->mode = sensor->GetReportingMode(); |
| 90 init_params->default_configuration = sensor->GetDefaultConfiguration(); | 90 init_params->default_configuration = sensor->GetDefaultConfiguration(); |
| 91 | 91 |
| 92 double maximum_frequency = sensor->GetMaximumSupportedFrequency(); | |
|
shalamov
2016/11/03 12:54:05
If platform returns 0, should we cap max to defaul
Mikhail
2016/11/03 13:28:16
It should not return 0. Implementation must cap ma
| |
| 93 DCHECK(maximum_frequency); | |
| 94 if (maximum_frequency > mojom::SensorConfiguration::kMaxAllowedFrequency) | |
| 95 maximum_frequency = mojom::SensorConfiguration::kMaxAllowedFrequency; | |
| 96 | |
| 97 init_params->maximum_frequency = maximum_frequency; | |
| 98 | |
| 92 NotifySensorCreated(std::move(init_params), sensor_impl->GetClient(), | 99 NotifySensorCreated(std::move(init_params), sensor_impl->GetClient(), |
| 93 callback); | 100 callback); |
| 94 | 101 |
| 95 mojo::MakeStrongBinding(std::move(sensor_impl), std::move(sensor_request)); | 102 mojo::MakeStrongBinding(std::move(sensor_impl), std::move(sensor_request)); |
| 96 } | 103 } |
| 97 | 104 |
| 98 } // namespace device | 105 } // namespace device |
| OLD | NEW |