Chromium Code Reviews| Index: chromeos/dbus/bluetooth_device_client.cc |
| diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc |
| index 264de0d1f181e5e3cf76eb1cad7a6cbe51cd9307..1b5d2686a82a2587fefeb25c96a3d2a1a8278676 100644 |
| --- a/chromeos/dbus/bluetooth_device_client.cc |
| +++ b/chromeos/dbus/bluetooth_device_client.cc |
| @@ -464,18 +464,70 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, |
| // nothing. |
| class BluetoothDeviceClientStubImpl : public BluetoothDeviceClient { |
| public: |
| + struct Properties : public BluetoothDeviceClient::Properties { |
| + explicit Properties(PropertyChangedCallback callback) |
|
satorux1
2012/08/14 16:54:19
const PropertyChangedCallback&
keybuk
2012/08/14 17:40:32
Done.
|
| + : BluetoothDeviceClient::Properties(NULL, callback) { |
| + } |
| + |
| + virtual ~Properties() { |
| + } |
| + |
| + virtual void Get(dbus::PropertyBase* property, |
| + dbus::PropertySet::GetCallback callback) OVERRIDE { |
| + VLOG(1) << "Get " << property->name(); |
| + callback.Run(false); |
| + } |
| + |
| + virtual void GetAll() OVERRIDE { |
| + VLOG(1) << "GetAll"; |
| + } |
| + |
| + virtual void Set(dbus::PropertyBase *property, |
| + dbus::PropertySet::SetCallback callback) OVERRIDE { |
| + VLOG(1) << "Set " << property->name(); |
| + callback.Run(false); |
| + } |
| + }; |
| + |
| + BluetoothDeviceClientStubImpl() { |
| + dbus::ObjectPath dev0("/fake/hci0/dev0"); |
| + |
| + Properties* properties = new Properties(base::Bind( |
| + &BluetoothDeviceClientStubImpl::OnPropertyChanged, |
| + base::Unretained(this), |
| + dev0)); |
| + properties->address.ReplaceValue("00:11:22:33:44:55"); |
| + properties->name.ReplaceValue("Fake Device"); |
| + properties->paired.ReplaceValue(true); |
| + properties->trusted.ReplaceValue(true); |
| + |
| + properties_map_[dev0] = properties; |
| + } |
| + |
| + virtual ~BluetoothDeviceClientStubImpl() { |
| + // Clean up Properties structures |
|
bryeung
2012/08/14 13:10:30
This could be done with STLDeleteContainerPairSeco
satorux1
2012/08/14 16:54:19
You meant STLDeleteValues?
keybuk
2012/08/14 17:40:32
Done.
|
| + for (PropertiesMap::iterator iter = properties_map_.begin(); |
| + iter != properties_map_.end(); ++iter) |
| + delete iter->second; |
| + } |
| + |
| // BluetoothDeviceClient override. |
| virtual void AddObserver(Observer* observer) OVERRIDE { |
| + observers_.AddObserver(observer); |
| } |
| // BluetoothDeviceClient override. |
| virtual void RemoveObserver(Observer* observer) OVERRIDE { |
| + observers_.RemoveObserver(observer); |
| } |
| // BluetoothDeviceClient override. |
| virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
| OVERRIDE { |
| VLOG(1) << "GetProperties: " << object_path.value(); |
| + PropertiesMap::iterator iter = properties_map_.find(object_path); |
| + if (iter != properties_map_.end()) |
| + return iter->second; |
| return NULL; |
| } |
| @@ -519,6 +571,20 @@ class BluetoothDeviceClientStubImpl : public BluetoothDeviceClient { |
| << " " << node_path.value(); |
| callback.Run(object_path, false); |
| } |
| + |
| + private: |
| + // List of observers interested in event notifications from us. |
|
satorux1
2012/08/14 16:54:19
move this to |observers_|; below?
keybuk
2012/08/14 17:40:32
Done.
|
| + void OnPropertyChanged(dbus::ObjectPath object_path, |
| + const std::string& property_name) { |
| + FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| + DevicePropertyChanged(object_path, property_name)); |
| + } |
| + |
| + ObserverList<Observer> observers_; |
| + |
| + // Static properties we typedef. |
| + typedef std::map<const dbus::ObjectPath, Properties *> PropertiesMap; |
| + PropertiesMap properties_map_; |
| }; |
| BluetoothDeviceClient::BluetoothDeviceClient() { |