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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_device_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_device_client.h" 5 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 properties->paired.ReplaceValue(false); 758 properties->paired.ReplaceValue(false);
759 properties->name.ReplaceValue("Connected Pairable Device"); 759 properties->name.ReplaceValue("Connected Pairable Device");
760 properties->alias.ReplaceValue(kConnectedTrustedNotPairedDeviceName); 760 properties->alias.ReplaceValue(kConnectedTrustedNotPairedDeviceName);
761 } else { 761 } else {
762 NOTREACHED(); 762 NOTREACHED();
763 } 763 }
764 764
765 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 765 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
766 device_list_.push_back(device_path); 766 device_list_.push_back(device_path);
767 767
768 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 768 for (auto& observer : observers_)
769 DeviceAdded(device_path)); 769 observer.DeviceAdded(device_path);
770 } 770 }
771 771
772 void FakeBluetoothDeviceClient::CreateDeviceWithProperties( 772 void FakeBluetoothDeviceClient::CreateDeviceWithProperties(
773 const dbus::ObjectPath& adapter_path, 773 const dbus::ObjectPath& adapter_path,
774 const IncomingDeviceProperties& props) { 774 const IncomingDeviceProperties& props) {
775 dbus::ObjectPath device_path(props.device_path); 775 dbus::ObjectPath device_path(props.device_path);
776 if (std::find(device_list_.begin(), device_list_.end(), device_path) != 776 if (std::find(device_list_.begin(), device_list_.end(), device_path) !=
777 device_list_.end()) 777 device_list_.end())
778 return; 778 return;
779 779
(...skipping 12 matching lines...) Expand all
792 792
793 std::unique_ptr<SimulatedPairingOptions> options(new SimulatedPairingOptions); 793 std::unique_ptr<SimulatedPairingOptions> options(new SimulatedPairingOptions);
794 options->pairing_method = props.pairing_method; 794 options->pairing_method = props.pairing_method;
795 options->pairing_auth_token = props.pairing_auth_token; 795 options->pairing_auth_token = props.pairing_auth_token;
796 options->pairing_action = props.pairing_action; 796 options->pairing_action = props.pairing_action;
797 options->incoming = props.incoming; 797 options->incoming = props.incoming;
798 798
799 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 799 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
800 device_list_.push_back(device_path); 800 device_list_.push_back(device_path);
801 pairing_options_map_.insert(std::make_pair(device_path, std::move(options))); 801 pairing_options_map_.insert(std::make_pair(device_path, std::move(options)));
802 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 802 for (auto& observer : observers_)
803 DeviceAdded(device_path)); 803 observer.DeviceAdded(device_path);
804 } 804 }
805 805
806 std::unique_ptr<base::ListValue> 806 std::unique_ptr<base::ListValue>
807 FakeBluetoothDeviceClient::GetBluetoothDevicesAsDictionaries() const { 807 FakeBluetoothDeviceClient::GetBluetoothDevicesAsDictionaries() const {
808 std::unique_ptr<base::ListValue> predefined_devices(new base::ListValue); 808 std::unique_ptr<base::ListValue> predefined_devices(new base::ListValue);
809 std::unique_ptr<base::DictionaryValue> pairedDevice( 809 std::unique_ptr<base::DictionaryValue> pairedDevice(
810 new base::DictionaryValue); 810 new base::DictionaryValue);
811 pairedDevice->SetString("path", kPairedDevicePath); 811 pairedDevice->SetString("path", kPairedDevicePath);
812 pairedDevice->SetString("address", kPairedDeviceAddress); 812 pairedDevice->SetString("address", kPairedDeviceAddress);
813 pairedDevice->SetString("name", kPairedDeviceName); 813 pairedDevice->SetString("name", kPairedDeviceName);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 bluez::BluezDBusManager::Get()->GetBluetoothInputClient()); 1069 bluez::BluezDBusManager::Get()->GetBluetoothInputClient());
1070 fake_bluetooth_input_client->RemoveInputDevice(device_path); 1070 fake_bluetooth_input_client->RemoveInputDevice(device_path);
1071 1071
1072 if (device_path == dbus::ObjectPath(kLowEnergyPath)) { 1072 if (device_path == dbus::ObjectPath(kLowEnergyPath)) {
1073 FakeBluetoothGattServiceClient* gatt_service_client = 1073 FakeBluetoothGattServiceClient* gatt_service_client =
1074 static_cast<FakeBluetoothGattServiceClient*>( 1074 static_cast<FakeBluetoothGattServiceClient*>(
1075 bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()); 1075 bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient());
1076 gatt_service_client->HideHeartRateService(); 1076 gatt_service_client->HideHeartRateService();
1077 } 1077 }
1078 1078
1079 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 1079 for (auto& observer : observers_)
1080 DeviceRemoved(device_path)); 1080 observer.DeviceRemoved(device_path);
1081 1081
1082 properties_map_.erase(iter); 1082 properties_map_.erase(iter);
1083 PairingOptionsMap::const_iterator options_iter = 1083 PairingOptionsMap::const_iterator options_iter =
1084 pairing_options_map_.find(device_path); 1084 pairing_options_map_.find(device_path);
1085 1085
1086 if (options_iter != pairing_options_map_.end()) { 1086 if (options_iter != pairing_options_map_.end()) {
1087 pairing_options_map_.erase(options_iter); 1087 pairing_options_map_.erase(options_iter);
1088 } 1088 }
1089 } 1089 }
1090 1090
1091 void FakeBluetoothDeviceClient::OnPropertyChanged( 1091 void FakeBluetoothDeviceClient::OnPropertyChanged(
1092 const dbus::ObjectPath& object_path, 1092 const dbus::ObjectPath& object_path,
1093 const std::string& property_name) { 1093 const std::string& property_name) {
1094 VLOG(2) << "Fake Bluetooth device property changed: " << object_path.value() 1094 VLOG(2) << "Fake Bluetooth device property changed: " << object_path.value()
1095 << ": " << property_name; 1095 << ": " << property_name;
1096 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 1096 for (auto& observer : observers_)
1097 DevicePropertyChanged(object_path, property_name)); 1097 observer.DevicePropertyChanged(object_path, property_name);
1098 } 1098 }
1099 1099
1100 void FakeBluetoothDeviceClient::DiscoverySimulationTimer() { 1100 void FakeBluetoothDeviceClient::DiscoverySimulationTimer() {
1101 if (!discovery_simulation_step_) 1101 if (!discovery_simulation_step_)
1102 return; 1102 return;
1103 1103
1104 // Timer fires every .75s, the numbers below are arbitrary to give a feel 1104 // Timer fires every .75s, the numbers below are arbitrary to give a feel
1105 // for a discovery process. 1105 // for a discovery process.
1106 VLOG(1) << "discovery simulation, step " << discovery_simulation_step_; 1106 VLOG(1) << "discovery simulation, step " << discovery_simulation_step_;
1107 uint32_t initial_step = delay_start_discovery_ ? 2 : 1; 1107 uint32_t initial_step = delay_start_discovery_ ? 2 : 1;
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 case device::BLUETOOTH_TRANSPORT_DUAL: 1783 case device::BLUETOOTH_TRANSPORT_DUAL:
1784 properties->type.ReplaceValue(BluetoothDeviceClient::kTypeDual); 1784 properties->type.ReplaceValue(BluetoothDeviceClient::kTypeDual);
1785 break; 1785 break;
1786 default: 1786 default:
1787 NOTREACHED(); 1787 NOTREACHED();
1788 } 1788 }
1789 properties->type.set_valid(true); 1789 properties->type.set_valid(true);
1790 1790
1791 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 1791 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
1792 device_list_.push_back(device_path); 1792 device_list_.push_back(device_path);
1793 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 1793 for (auto& observer : observers_)
1794 DeviceAdded(device_path)); 1794 observer.DeviceAdded(device_path);
1795 } 1795 }
1796 1796
1797 } // namespace bluez 1797 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698