| 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 "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "device/generic_sensor/platform_sensor_provider.h" | 10 #include "device/generic_sensor/platform_sensor_provider.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 void PlatformSensor::NotifySensorReadingChanged() { | 100 void PlatformSensor::NotifySensorReadingChanged() { |
| 101 for (auto& client : clients_) { | 101 for (auto& client : clients_) { |
| 102 if (!client.IsNotificationSuspended()) | 102 if (!client.IsNotificationSuspended()) |
| 103 client.OnSensorReadingChanged(); | 103 client.OnSensorReadingChanged(); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void PlatformSensor::NotifySensorError() { | 107 void PlatformSensor::NotifySensorError() { |
| 108 FOR_EACH_OBSERVER(Client, clients_, OnSensorError()); | 108 for (auto& observer : clients_) |
| 109 observer.OnSensorError(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) { | 112 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) { |
| 112 const PlatformSensorConfiguration* optimal_configuration = nullptr; | 113 const PlatformSensorConfiguration* optimal_configuration = nullptr; |
| 113 for (const auto& pair : configurations) { | 114 for (const auto& pair : configurations) { |
| 114 if (pair.first->IsNotificationSuspended()) | 115 if (pair.first->IsNotificationSuspended()) |
| 115 continue; | 116 continue; |
| 116 | 117 |
| 117 const auto& conf_list = pair.second; | 118 const auto& conf_list = pair.second; |
| 118 for (const auto& configuration : conf_list) { | 119 for (const auto& configuration : conf_list) { |
| 119 if (!optimal_configuration || configuration > *optimal_configuration) { | 120 if (!optimal_configuration || configuration > *optimal_configuration) { |
| 120 optimal_configuration = &configuration; | 121 optimal_configuration = &configuration; |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 125 if (!optimal_configuration) { | 126 if (!optimal_configuration) { |
| 126 StopSensor(); | 127 StopSensor(); |
| 127 return true; | 128 return true; |
| 128 } | 129 } |
| 129 | 130 |
| 130 return StartSensor(*optimal_configuration); | 131 return StartSensor(*optimal_configuration); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace device | 134 } // namespace device |
| OLD | NEW |