Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: device/generic_sensor/platform_sensor.cc

Issue 2418653002: Remove usage of base::ObserverList<T>::Iter::GetNext() in //device. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 buffer->reading = reading; 91 buffer->reading = reading;
92 seqlock.WriteEnd(); 92 seqlock.WriteEnd();
93 93
94 if (notify_clients) 94 if (notify_clients)
95 task_runner_->PostTask( 95 task_runner_->PostTask(
96 FROM_HERE, base::Bind(&PlatformSensor::NotifySensorReadingChanged, 96 FROM_HERE, base::Bind(&PlatformSensor::NotifySensorReadingChanged,
97 weak_factory_.GetWeakPtr())); 97 weak_factory_.GetWeakPtr()));
98 } 98 }
99 99
100 void PlatformSensor::NotifySensorReadingChanged() { 100 void PlatformSensor::NotifySensorReadingChanged() {
101 using ClientsList = decltype(clients_); 101 for (auto& client : clients_) {
102 ClientsList::Iterator it(&clients_); 102 if (!client.IsNotificationSuspended())
103 Client* client; 103 client.OnSensorReadingChanged();
104 while ((client = it.GetNext()) != nullptr) {
105 if (!client->IsNotificationSuspended())
106 client->OnSensorReadingChanged();
107 } 104 }
108 } 105 }
109 106
110 void PlatformSensor::NotifySensorError() { 107 void PlatformSensor::NotifySensorError() {
111 FOR_EACH_OBSERVER(Client, clients_, OnSensorError()); 108 FOR_EACH_OBSERVER(Client, clients_, OnSensorError());
112 } 109 }
113 110
114 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) { 111 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) {
115 const PlatformSensorConfiguration* optimal_configuration = nullptr; 112 const PlatformSensorConfiguration* optimal_configuration = nullptr;
116 for (const auto& pair : configurations) { 113 for (const auto& pair : configurations) {
(...skipping 10 matching lines...) Expand all
127 124
128 if (!optimal_configuration) { 125 if (!optimal_configuration) {
129 StopSensor(); 126 StopSensor();
130 return true; 127 return true;
131 } 128 }
132 129
133 return StartSensor(*optimal_configuration); 130 return StartSensor(*optimal_configuration);
134 } 131 }
135 132
136 } // namespace device 133 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698