Index: chromeos/dbus/experimental_bluetooth_device_client.cc |
diff --git a/chromeos/dbus/experimental_bluetooth_device_client.cc b/chromeos/dbus/experimental_bluetooth_device_client.cc |
index 7015e5f27a70f86b5d95234471a68390f8595f13..9de3c940e9f3d66eae2d9058779921525f5f8263 100644 |
--- a/chromeos/dbus/experimental_bluetooth_device_client.cc |
+++ b/chromeos/dbus/experimental_bluetooth_device_client.cc |
@@ -4,13 +4,10 @@ |
#include "chromeos/dbus/experimental_bluetooth_device_client.h" |
-#include <map> |
-#include <utility> |
- |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/stl_util.h" |
-#include "chromeos/dbus/bluetooth_property.h" |
+#include "chromeos/dbus/fake_bluetooth_device_client.h" |
#include "dbus/bus.h" |
#include "dbus/message.h" |
#include "dbus/object_manager.h" |
@@ -343,155 +340,6 @@ class ExperimentalBluetoothDeviceClientImpl |
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothDeviceClientImpl); |
}; |
-// The ExperimentalBluetoothDeviceClient implementation used on Linux desktop, |
-// which does nothing. |
-class ExperimentalBluetoothDeviceClientStubImpl |
- : public ExperimentalBluetoothDeviceClient { |
- public: |
- struct Properties : public ExperimentalBluetoothDeviceClient::Properties { |
- explicit Properties(const PropertyChangedCallback& callback) |
- : ExperimentalBluetoothDeviceClient::Properties( |
- NULL, |
- bluetooth_device::kExperimentalBluetoothDeviceInterface, |
- 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); |
- } |
- }; |
- |
- ExperimentalBluetoothDeviceClientStubImpl() { |
- dbus::ObjectPath dev0("/fake/hci0/dev0"); |
- |
- Properties* properties = new Properties(base::Bind( |
- &ExperimentalBluetoothDeviceClientStubImpl::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 ~ExperimentalBluetoothDeviceClientStubImpl() { |
- // Clean up Properties structures |
- STLDeleteValues(&properties_map_); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void AddObserver(Observer* observer) OVERRIDE { |
- observers_.AddObserver(observer); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void RemoveObserver(Observer* observer) OVERRIDE { |
- observers_.RemoveObserver(observer); |
- } |
- |
- virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter( |
- const dbus::ObjectPath& adapter_path) OVERRIDE { |
- std::vector<dbus::ObjectPath> object_paths; |
- if (adapter_path.value() == "/fake/hci0") |
- object_paths.push_back(dbus::ObjectPath("/fake/hci0/dev0")); |
- return object_paths; |
- } |
- |
- // ExperimentalBluetoothDeviceClient 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; |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void Connect(const dbus::ObjectPath& object_path, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) OVERRIDE { |
- VLOG(1) << "Connect: " << object_path.value(); |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void Disconnect(const dbus::ObjectPath& object_path, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) OVERRIDE { |
- VLOG(1) << "Disconnect: " << object_path.value(); |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void ConnectProfile(const dbus::ObjectPath& object_path, |
- const std::string& uuid, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) |
- OVERRIDE { |
- VLOG(1) << "ConnectProfile: " << object_path.value() << " " << uuid; |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void DisconnectProfile(const dbus::ObjectPath& object_path, |
- const std::string& uuid, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) |
- OVERRIDE { |
- VLOG(1) << "DisconnectProfile: " << object_path.value() << " " << uuid; |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void Pair(const dbus::ObjectPath& object_path, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) OVERRIDE { |
- VLOG(1) << "Pair: " << object_path.value(); |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- // ExperimentalBluetoothDeviceClient override. |
- virtual void CancelPairing(const dbus::ObjectPath& object_path, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback) |
- OVERRIDE { |
- VLOG(1) << "CancelPairing: " << object_path.value(); |
- error_callback.Run(kNoResponseError, ""); |
- } |
- |
- private: |
- void OnPropertyChanged(dbus::ObjectPath object_path, |
- const std::string& property_name) { |
- FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
- DevicePropertyChanged(object_path, property_name)); |
- } |
- |
- // List of observers interested in event notifications from us. |
- ObserverList<Observer> observers_; |
- |
- // Static properties we typedef. |
- typedef std::map<const dbus::ObjectPath, Properties *> PropertiesMap; |
- PropertiesMap properties_map_; |
-}; |
- |
ExperimentalBluetoothDeviceClient::ExperimentalBluetoothDeviceClient() { |
} |
@@ -504,7 +352,7 @@ ExperimentalBluetoothDeviceClient* ExperimentalBluetoothDeviceClient::Create( |
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
return new ExperimentalBluetoothDeviceClientImpl(bus); |
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
- return new ExperimentalBluetoothDeviceClientStubImpl(); |
+ return new FakeBluetoothDeviceClient(); |
} |
} // namespace chromeos |