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

Side by Side Diff: device/bluetooth/bluez/bluetooth_adapter_bluez.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/bluez/bluetooth_adapter_bluez.h" 5 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdint> 8 #include <cstdint>
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 return; 532 return;
533 DCHECK(IsPresent()); 533 DCHECK(IsPresent());
534 534
535 BluetoothDeviceBlueZ* device_bluez = new BluetoothDeviceBlueZ( 535 BluetoothDeviceBlueZ* device_bluez = new BluetoothDeviceBlueZ(
536 this, object_path, ui_task_runner_, socket_thread_); 536 this, object_path, ui_task_runner_, socket_thread_);
537 DCHECK(devices_.find(device_bluez->GetAddress()) == devices_.end()); 537 DCHECK(devices_.find(device_bluez->GetAddress()) == devices_.end());
538 538
539 devices_.set(device_bluez->GetAddress(), 539 devices_.set(device_bluez->GetAddress(),
540 std::unique_ptr<BluetoothDevice>(device_bluez)); 540 std::unique_ptr<BluetoothDevice>(device_bluez));
541 541
542 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 542 for (auto& observer : observers_)
543 DeviceAdded(this, device_bluez)); 543 observer.DeviceAdded(this, device_bluez);
544 } 544 }
545 545
546 void BluetoothAdapterBlueZ::DeviceRemoved(const dbus::ObjectPath& object_path) { 546 void BluetoothAdapterBlueZ::DeviceRemoved(const dbus::ObjectPath& object_path) {
547 for (DevicesMap::const_iterator iter = devices_.begin(); 547 for (DevicesMap::const_iterator iter = devices_.begin();
548 iter != devices_.end(); ++iter) { 548 iter != devices_.end(); ++iter) {
549 BluetoothDeviceBlueZ* device_bluez = 549 BluetoothDeviceBlueZ* device_bluez =
550 static_cast<BluetoothDeviceBlueZ*>(iter->second); 550 static_cast<BluetoothDeviceBlueZ*>(iter->second);
551 if (device_bluez->object_path() == object_path) { 551 if (device_bluez->object_path() == object_path) {
552 std::unique_ptr<BluetoothDevice> scoped_device = 552 std::unique_ptr<BluetoothDevice> scoped_device =
553 devices_.take_and_erase(iter->first); 553 devices_.take_and_erase(iter->first);
554 554
555 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 555 for (auto& observer : observers_)
556 DeviceRemoved(this, device_bluez)); 556 observer.DeviceRemoved(this, device_bluez);
557 return; 557 return;
558 } 558 }
559 } 559 }
560 } 560 }
561 561
562 void BluetoothAdapterBlueZ::DevicePropertyChanged( 562 void BluetoothAdapterBlueZ::DevicePropertyChanged(
563 const dbus::ObjectPath& object_path, 563 const dbus::ObjectPath& object_path,
564 const std::string& property_name) { 564 const std::string& property_name) {
565 BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(object_path); 565 BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(object_path);
566 if (!device_bluez) 566 if (!device_bluez)
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 if (properties->discovering.value()) 997 if (properties->discovering.value())
998 DiscoveringChanged(false); 998 DiscoveringChanged(false);
999 999
1000 // Move all elements of the original devices list to a new list here, 1000 // Move all elements of the original devices list to a new list here,
1001 // leaving the original list empty so that when we send DeviceRemoved(), 1001 // leaving the original list empty so that when we send DeviceRemoved(),
1002 // GetDevices() returns no devices. 1002 // GetDevices() returns no devices.
1003 DevicesMap devices_swapped; 1003 DevicesMap devices_swapped;
1004 devices_swapped.swap(devices_); 1004 devices_swapped.swap(devices_);
1005 1005
1006 for (auto& iter : devices_swapped) { 1006 for (auto& iter : devices_swapped) {
1007 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 1007 for (auto& observer : observers_)
1008 DeviceRemoved(this, iter.second)); 1008 observer.DeviceRemoved(this, iter.second);
1009 } 1009 }
1010 1010
1011 PresentChanged(false); 1011 PresentChanged(false);
1012 } 1012 }
1013 1013
1014 void BluetoothAdapterBlueZ::DiscoverableChanged(bool discoverable) { 1014 void BluetoothAdapterBlueZ::DiscoverableChanged(bool discoverable) {
1015 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 1015 for (auto& observer : observers_)
1016 AdapterDiscoverableChanged(this, discoverable)); 1016 observer.AdapterDiscoverableChanged(this, discoverable);
1017 } 1017 }
1018 1018
1019 void BluetoothAdapterBlueZ::DiscoveringChanged(bool discovering) { 1019 void BluetoothAdapterBlueZ::DiscoveringChanged(bool discovering) {
1020 // If the adapter stopped discovery due to a reason other than a request by 1020 // If the adapter stopped discovery due to a reason other than a request by
1021 // us, reset the count to 0. 1021 // us, reset the count to 0.
1022 VLOG(1) << "Discovering changed: " << discovering; 1022 VLOG(1) << "Discovering changed: " << discovering;
1023 if (!discovering && !discovery_request_pending_ && 1023 if (!discovering && !discovery_request_pending_ &&
1024 num_discovery_sessions_ > 0) { 1024 num_discovery_sessions_ > 0) {
1025 VLOG(1) << "Marking sessions as inactive."; 1025 VLOG(1) << "Marking sessions as inactive.";
1026 num_discovery_sessions_ = 0; 1026 num_discovery_sessions_ = 0;
1027 MarkDiscoverySessionsAsInactive(); 1027 MarkDiscoverySessionsAsInactive();
1028 } 1028 }
1029 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 1029 for (auto& observer : observers_)
1030 AdapterDiscoveringChanged(this, discovering)); 1030 observer.AdapterDiscoveringChanged(this, discovering);
1031 } 1031 }
1032 1032
1033 void BluetoothAdapterBlueZ::PresentChanged(bool present) { 1033 void BluetoothAdapterBlueZ::PresentChanged(bool present) {
1034 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 1034 for (auto& observer : observers_)
1035 AdapterPresentChanged(this, present)); 1035 observer.AdapterPresentChanged(this, present);
1036 } 1036 }
1037 1037
1038 void BluetoothAdapterBlueZ::NotifyDeviceAddressChanged( 1038 void BluetoothAdapterBlueZ::NotifyDeviceAddressChanged(
1039 BluetoothDeviceBlueZ* device, 1039 BluetoothDeviceBlueZ* device,
1040 const std::string& old_address) { 1040 const std::string& old_address) {
1041 DCHECK(device->adapter_ == this); 1041 DCHECK(device->adapter_ == this);
1042 1042
1043 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 1043 for (auto& observer : observers_)
1044 DeviceAddressChanged(this, device, old_address)); 1044 observer.DeviceAddressChanged(this, device, old_address);
1045 } 1045 }
1046 1046
1047 void BluetoothAdapterBlueZ::UseProfile( 1047 void BluetoothAdapterBlueZ::UseProfile(
1048 const BluetoothUUID& uuid, 1048 const BluetoothUUID& uuid,
1049 const dbus::ObjectPath& device_path, 1049 const dbus::ObjectPath& device_path,
1050 const bluez::BluetoothProfileManagerClient::Options& options, 1050 const bluez::BluetoothProfileManagerClient::Options& options,
1051 bluez::BluetoothProfileServiceProvider::Delegate* delegate, 1051 bluez::BluetoothProfileServiceProvider::Delegate* delegate,
1052 const ProfileRegisteredCallback& success_callback, 1052 const ProfileRegisteredCallback& success_callback,
1053 const ErrorCompletionCallback& error_callback) { 1053 const ErrorCompletionCallback& error_callback) {
1054 DCHECK(delegate); 1054 DCHECK(delegate);
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) { 1698 } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) {
1699 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS; 1699 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS;
1700 } else if (error_name == bluetooth_adapter::kErrorNotReady) { 1700 } else if (error_name == bluetooth_adapter::kErrorNotReady) {
1701 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY; 1701 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY;
1702 } 1702 }
1703 1703
1704 error_callback.Run(code); 1704 error_callback.Run(code);
1705 } 1705 }
1706 1706
1707 } // namespace bluez 1707 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_task_manager_win.cc ('k') | device/bluetooth/bluez/bluetooth_advertisement_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698