Chromium Code Reviews| Index: chromeos/dbus/bluetooth_manager_client.cc |
| diff --git a/chromeos/dbus/bluetooth_manager_client.cc b/chromeos/dbus/bluetooth_manager_client.cc |
| index 1ff3f625c2bc253be27d79c82b34518f28d2c054..b2fa1d3f0a7375412d6a5121927f004b9fb761cc 100644 |
| --- a/chromeos/dbus/bluetooth_manager_client.cc |
| +++ b/chromeos/dbus/bluetooth_manager_client.cc |
| @@ -4,8 +4,11 @@ |
| #include "chromeos/dbus/bluetooth_manager_client.h" |
| +#include <vector> |
| + |
| #include "base/bind.h" |
| #include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "chromeos/dbus/bluetooth_property.h" |
| #include "dbus/bus.h" |
| #include "dbus/message.h" |
| @@ -270,32 +273,84 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { |
| // nothing. |
| class BluetoothManagerClientStubImpl : public BluetoothManagerClient { |
| public: |
| + struct Properties : public BluetoothManagerClient::Properties { |
| + explicit Properties(PropertyChangedCallback callback) |
|
satorux1
2012/08/14 16:54:19
const &
keybuk
2012/08/14 17:40:32
Done.
|
| + : BluetoothManagerClient::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); |
| + } |
| + }; |
| + |
| + BluetoothManagerClientStubImpl() { |
| + properties_.reset(new Properties(base::Bind( |
| + &BluetoothManagerClientStubImpl::OnPropertyChanged, |
| + base::Unretained(this)))); |
| + |
| + std::vector<dbus::ObjectPath> adapters; |
| + adapters.push_back(dbus::ObjectPath("/fake/hci0")); |
| + properties_->adapters.ReplaceValue(adapters); |
| + } |
| + |
| // BluetoothManagerClient override. |
| virtual void AddObserver(Observer* observer) OVERRIDE { |
| + observers_.AddObserver(observer); |
| } |
| // BluetoothManagerClient override. |
| virtual void RemoveObserver(Observer* observer) OVERRIDE { |
| + observers_.RemoveObserver(observer); |
| } |
| // BluetoothManagerClient override. |
| virtual Properties* GetProperties() OVERRIDE { |
| VLOG(1) << "GetProperties"; |
| - return NULL; |
| + return properties_.get(); |
| } |
| // BluetoothManagerClient override. |
| virtual void DefaultAdapter(const AdapterCallback& callback) OVERRIDE { |
| VLOG(1) << "DefaultAdapter."; |
| - callback.Run(dbus::ObjectPath(), false); |
| + callback.Run(dbus::ObjectPath("/fake/hci0"), true); |
| } |
| // BluetoothManagerClient override. |
| virtual void FindAdapter(const std::string& address, |
| const AdapterCallback& callback) { |
| VLOG(1) << "FindAdapter: " << address; |
| - callback.Run(dbus::ObjectPath(), false); |
| + if (address == "hci0") |
| + callback.Run(dbus::ObjectPath("/fake/hci0"), true); |
| + else |
| + callback.Run(dbus::ObjectPath(), false); |
| } |
| + |
| + private: |
| + void OnPropertyChanged(const std::string& property_name) { |
| + FOR_EACH_OBSERVER(BluetoothManagerClient::Observer, observers_, |
| + ManagerPropertyChanged(property_name)); |
| + } |
| + |
| + // List of observers interested in event notifications from us. |
| + ObserverList<Observer> observers_; |
| + |
| + // Static properties we return. |
| + scoped_ptr<Properties> properties_; |
| }; |
| BluetoothManagerClient::BluetoothManagerClient() { |