| 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/platform_sensor.h" | 5 #include "device/generic_sensor/platform_sensor.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "device/generic_sensor/platform_sensor_configuration.h" | 9 #include "device/generic_sensor/platform_sensor_configuration.h" |
| 10 #include "device/generic_sensor/platform_sensor_provider.h" | 10 #include "device/generic_sensor/platform_sensor_provider.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 void PlatformSensor::NotifySensorReadingChanged() { | 83 void PlatformSensor::NotifySensorReadingChanged() { |
| 84 FOR_EACH_OBSERVER(Client, clients_, OnSensorReadingChanged()); | 84 FOR_EACH_OBSERVER(Client, clients_, OnSensorReadingChanged()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PlatformSensor::NotifySensorError() { | 87 void PlatformSensor::NotifySensorError() { |
| 88 FOR_EACH_OBSERVER(Client, clients_, OnSensorError()); | 88 FOR_EACH_OBSERVER(Client, clients_, OnSensorError()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) { |
| 92 const PlatformSensorConfiguration* optimal_configuration = nullptr; |
| 93 for (const auto& pair : configurations) { |
| 94 if (pair.first->IsNotificationSuspended()) |
| 95 continue; |
| 96 |
| 97 const auto& conf_list = pair.second; |
| 98 for (const auto& configuration : conf_list) { |
| 99 if (!optimal_configuration || configuration > *optimal_configuration) { |
| 100 optimal_configuration = &configuration; |
| 101 } |
| 102 } |
| 103 } |
| 104 |
| 105 if (!optimal_configuration) { |
| 106 StopSensor(); |
| 107 return true; |
| 108 } |
| 109 |
| 110 return StartSensor(*optimal_configuration); |
| 111 } |
| 112 |
| 91 } // namespace device | 113 } // namespace device |
| OLD | NEW |