Chromium Code Reviews| Index: chromeos/dbus/bluetooth_adapter_client.cc |
| diff --git a/chromeos/dbus/bluetooth_adapter_client.cc b/chromeos/dbus/bluetooth_adapter_client.cc |
| index 4173c625ba459b1cff40f80d14bb215a9b52e637..688e2dff30fb0e79fec9e9669070b73e0e2c212c 100644 |
| --- a/chromeos/dbus/bluetooth_adapter_client.cc |
| +++ b/chromeos/dbus/bluetooth_adapter_client.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/bind.h" |
| #include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/stl_util.h" |
| #include "chromeos/dbus/bluetooth_device_client.h" |
| #include "chromeos/dbus/bluetooth_manager_client.h" |
| @@ -729,19 +730,69 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, |
| // nothing. |
| class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient { |
| public: |
| + struct Properties : public BluetoothAdapterClient::Properties { |
| + explicit Properties(PropertyChangedCallback callback) |
|
satorux1
2012/08/14 16:54:19
you can make it const PropertyChangedCallback&
keybuk
2012/08/14 17:40:32
Done.
|
| + : BluetoothAdapterClient::Properties(NULL, callback) { |
| + } |
| + |
| + virtual ~Properties() { |
| + } |
| + |
| + virtual void Get(dbus::PropertyBase* property, |
| + dbus::PropertySet::GetCallback callback) OVERRIDE { |
| + VLOG(1) << "Get " << property->name(); |
|
bryeung
2012/08/14 13:10:29
Probably better as DVLOG?
satorux1
2012/08/14 16:54:19
agreed
keybuk
2012/08/14 17:40:32
we've argued about this before - these are used on
satorux1
2012/08/14 17:52:04
IIRC, the reason why DVLOG(1) is preferred was tha
keybuk
2012/08/14 17:58:46
UI designers don't build anything
|
| + callback.Run(false); |
| + } |
| + |
| + virtual void GetAll() OVERRIDE { |
| + VLOG(1) << "GetAll"; |
|
satorux1
2012/08/14 16:54:19
ditto. please fix other places too.
|
| + } |
| + |
| + virtual void Set(dbus::PropertyBase *property, |
| + dbus::PropertySet::SetCallback callback) OVERRIDE { |
| + VLOG(1) << "Set " << property->name(); |
| + if (property->name() == "Powered") { |
| + property->ReplaceValueWithSetValue(); |
| + NotifyPropertyChanged(property->name()); |
| + callback.Run(true); |
| + } else { |
| + callback.Run(false); |
| + } |
| + } |
| + }; |
| + |
| + BluetoothAdapterClientStubImpl() { |
| + properties_.reset(new Properties(base::Bind( |
| + &BluetoothAdapterClientStubImpl::OnPropertyChanged, |
| + base::Unretained(this)))); |
| + |
| + properties_->address.ReplaceValue("hci0"); |
| + properties_->name.ReplaceValue("Fake Adapter"); |
| + properties_->pairable.ReplaceValue(true); |
| + |
| + std::vector<dbus::ObjectPath> devices; |
| + devices.push_back(dbus::ObjectPath("/fake/hci0/dev0")); |
| + properties_->devices.ReplaceValue(devices); |
| + } |
| + |
| // BluetoothAdapterClient override. |
| virtual void AddObserver(Observer* observer) OVERRIDE { |
| + observers_.AddObserver(observer); |
| } |
| // BluetoothAdapterClient override. |
| virtual void RemoveObserver(Observer* observer) OVERRIDE { |
| + observers_.RemoveObserver(observer); |
| } |
| // BluetoothAdapterClient override. |
| virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
| OVERRIDE { |
| VLOG(1) << "GetProperties: " << object_path.value(); |
| - return NULL; |
| + if (object_path.value() == "/fake/hci0") |
| + return properties_.get(); |
| + else |
| + return NULL; |
| } |
| // BluetoothAdapterClient override. |
| @@ -837,6 +888,19 @@ class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient { |
| << " " << agent_path.value(); |
| callback.Run(object_path, false); |
| } |
| + |
| + private: |
| + // List of observers interested in event notifications from us. |
|
bryeung
2012/08/14 13:10:29
looks like this belongs with the variable below
keybuk
2012/08/14 17:40:32
Done.
|
| + void OnPropertyChanged(const std::string& property_name) { |
| + FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, |
| + AdapterPropertyChanged(dbus::ObjectPath("/fake/hci0"), |
|
satorux1
2012/08/14 16:54:19
I saw this before. you might want to define consta
keybuk
2012/08/14 17:40:32
I couldn't find a useful place to put them, since
satorux1
2012/08/14 17:52:04
You could add a new file like bluetooth_stub_const
|
| + property_name)); |
| + } |
| + |
| + ObserverList<Observer> observers_; |
| + |
| + // Static properties we return. |
| + scoped_ptr<Properties> properties_; |
| }; |
| BluetoothAdapterClient::BluetoothAdapterClient() { |