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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_adapter_client.cc

Issue 2423793002: Remove usage of FOR_EACH_OBSERVER macro in device/ (Closed)
Patch Set: rebase 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/bluetooth/dbus/fake_bluetooth_adapter_client.h" 5 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 BluetoothAdapterClient::DiscoveryFilter* 267 BluetoothAdapterClient::DiscoveryFilter*
268 FakeBluetoothAdapterClient::GetDiscoveryFilter() { 268 FakeBluetoothAdapterClient::GetDiscoveryFilter() {
269 return discovery_filter_.get(); 269 return discovery_filter_.get();
270 } 270 }
271 271
272 void FakeBluetoothAdapterClient::SetVisible(bool visible) { 272 void FakeBluetoothAdapterClient::SetVisible(bool visible) {
273 if (visible && !visible_) { 273 if (visible && !visible_) {
274 // Adapter becoming visible 274 // Adapter becoming visible
275 visible_ = visible; 275 visible_ = visible;
276 276
277 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 277 for (auto& observer : observers_)
278 AdapterAdded(dbus::ObjectPath(kAdapterPath))); 278 observer.AdapterAdded(dbus::ObjectPath(kAdapterPath));
279 279
280 } else if (visible_ && !visible) { 280 } else if (visible_ && !visible) {
281 // Adapter becoming invisible 281 // Adapter becoming invisible
282 visible_ = visible; 282 visible_ = visible;
283 283
284 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 284 for (auto& observer : observers_)
285 AdapterRemoved(dbus::ObjectPath(kAdapterPath))); 285 observer.AdapterRemoved(dbus::ObjectPath(kAdapterPath));
286 } 286 }
287 } 287 }
288 288
289 void FakeBluetoothAdapterClient::SetSecondVisible(bool visible) { 289 void FakeBluetoothAdapterClient::SetSecondVisible(bool visible) {
290 if (visible && !second_visible_) { 290 if (visible && !second_visible_) {
291 // Second adapter becoming visible 291 // Second adapter becoming visible
292 second_visible_ = visible; 292 second_visible_ = visible;
293 293
294 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 294 for (auto& observer : observers_)
295 AdapterAdded(dbus::ObjectPath(kSecondAdapterPath))); 295 observer.AdapterAdded(dbus::ObjectPath(kSecondAdapterPath));
296 296
297 } else if (second_visible_ && !visible) { 297 } else if (second_visible_ && !visible) {
298 // Second adapter becoming invisible 298 // Second adapter becoming invisible
299 second_visible_ = visible; 299 second_visible_ = visible;
300 300
301 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 301 for (auto& observer : observers_)
302 AdapterRemoved(dbus::ObjectPath(kSecondAdapterPath))); 302 observer.AdapterRemoved(dbus::ObjectPath(kSecondAdapterPath));
303 } 303 }
304 } 304 }
305 305
306 void FakeBluetoothAdapterClient::SetUUIDs( 306 void FakeBluetoothAdapterClient::SetUUIDs(
307 const std::vector<std::string>& uuids) { 307 const std::vector<std::string>& uuids) {
308 properties_->uuids.ReplaceValue(uuids); 308 properties_->uuids.ReplaceValue(uuids);
309 } 309 }
310 310
311 void FakeBluetoothAdapterClient::SetSecondUUIDs( 311 void FakeBluetoothAdapterClient::SetSecondUUIDs(
312 const std::vector<std::string>& uuids) { 312 const std::vector<std::string>& uuids) {
313 second_properties_->uuids.ReplaceValue(uuids); 313 second_properties_->uuids.ReplaceValue(uuids);
314 } 314 }
315 315
316 void FakeBluetoothAdapterClient::SetDiscoverableTimeout(uint32_t timeout) { 316 void FakeBluetoothAdapterClient::SetDiscoverableTimeout(uint32_t timeout) {
317 properties_->discoverable_timeout.ReplaceValue(timeout); 317 properties_->discoverable_timeout.ReplaceValue(timeout);
318 } 318 }
319 319
320 void FakeBluetoothAdapterClient::OnPropertyChanged( 320 void FakeBluetoothAdapterClient::OnPropertyChanged(
321 const std::string& property_name) { 321 const std::string& property_name) {
322 if (property_name == properties_->powered.name() && 322 if (property_name == properties_->powered.name() &&
323 !properties_->powered.value()) { 323 !properties_->powered.value()) {
324 VLOG(1) << "Adapter powered off"; 324 VLOG(1) << "Adapter powered off";
325 325
326 if (discovering_count_) { 326 if (discovering_count_) {
327 discovering_count_ = 0; 327 discovering_count_ = 0;
328 properties_->discovering.ReplaceValue(false); 328 properties_->discovering.ReplaceValue(false);
329 } 329 }
330 } 330 }
331 331
332 FOR_EACH_OBSERVER( 332 for (auto& observer : observers_) {
333 BluetoothAdapterClient::Observer, observers_, 333 observer.AdapterPropertyChanged(dbus::ObjectPath(kAdapterPath),
334 AdapterPropertyChanged(dbus::ObjectPath(kAdapterPath), property_name)); 334 property_name);
335 }
335 } 336 }
336 337
337 void FakeBluetoothAdapterClient::PostDelayedTask( 338 void FakeBluetoothAdapterClient::PostDelayedTask(
338 const base::Closure& callback) { 339 const base::Closure& callback) {
339 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 340 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
340 FROM_HERE, callback, 341 FROM_HERE, callback,
341 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); 342 base::TimeDelta::FromMilliseconds(simulation_interval_ms_));
342 } 343 }
343 344
344 } // namespace bluez 345 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/bluetooth_media_transport_client.cc ('k') | device/bluetooth/dbus/fake_bluetooth_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698