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

Unified Diff: chromeos/dbus/bluetooth_manager_client.cc

Issue 10823301: bluetooth: Create stub manager, adapter and device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/bluetooth_manager_client.h ('k') | chromeos/dbus/bluetooth_node_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b4c01dba70b41ac121e1111c97a8c611e6ce83a1 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"
@@ -15,8 +18,9 @@
namespace chromeos {
-BluetoothManagerClient::Properties::Properties(dbus::ObjectProxy* object_proxy,
- PropertyChangedCallback callback)
+BluetoothManagerClient::Properties::Properties(
+ dbus::ObjectProxy* object_proxy,
+ const PropertyChangedCallback& callback)
: BluetoothPropertySet(object_proxy,
bluetooth_manager::kBluetoothManagerInterface,
callback) {
@@ -270,32 +274,84 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
// nothing.
class BluetoothManagerClientStubImpl : public BluetoothManagerClient {
public:
+ struct Properties : public BluetoothManagerClient::Properties {
+ explicit Properties(const PropertyChangedCallback& callback)
+ : 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() {
« no previous file with comments | « chromeos/dbus/bluetooth_manager_client.h ('k') | chromeos/dbus/bluetooth_node_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698