Index: chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc |
diff --git a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc b/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc |
index 2929cc92a356043deca35cbae5aa21c2714c2260..e8e78eda9099cfe89c4967f55aa1e3c32cf75196 100644 |
--- a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc |
+++ b/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc |
@@ -4,16 +4,20 @@ |
#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/fake_bluetooth_media_client.h" |
+#include "chromeos/dbus/fake_bluetooth_media_transport_client.h" |
+ |
+using dbus::ObjectPath; |
+ |
namespace chromeos { |
// TODO(mcchou): Add the logic of the behavior. |
FakeBluetoothMediaEndpointServiceProvider:: |
- FakeBluetoothMediaEndpointServiceProvider( |
- const dbus::ObjectPath object_path, Delegate* delegate) |
- : object_path_(object_path) , delegate_(delegate) { |
+ FakeBluetoothMediaEndpointServiceProvider(const ObjectPath object_path, |
+ Delegate* delegate) |
+ : visible_(false), object_path_(object_path), delegate_(delegate) { |
VLOG(1) << "Create Bluetooth Media Endpoint: " << object_path_.value(); |
- // TODO(mcchou): Use the FakeBluetoothMediaClient in DBusThreadManager |
- // to register the FakeBluetoothMediaEndpoint object. |
} |
FakeBluetoothMediaEndpointServiceProvider:: |
@@ -24,30 +28,54 @@ FakeBluetoothMediaEndpointServiceProvider:: |
} |
void FakeBluetoothMediaEndpointServiceProvider::SetConfiguration( |
- const dbus::ObjectPath& transport_path, |
- const dbus::MessageReader& properties) { |
- VLOG(1) << object_path_.value() << ": SetConfiguration for " |
- << transport_path.value(); |
- delegate_->SetConfiguration(transport_path, properties); |
+ const ObjectPath& transport_path, |
+ const Delegate::TransportProperties& properties) { |
+ if (visible_) { |
armansito
2015/02/10 00:17:01
nit: Turn this around and early-return if !visible
Miao
2015/02/10 22:15:21
|visible_| removed.
|
+ VLOG(1) << object_path_.value() << ": SetConfiguration for " |
+ << transport_path.value(); |
+ |
+ // Sets the visibility to the transport object to true if the media object |
+ // is valid. |
+ FakeBluetoothMediaTransportClient* transport = |
+ static_cast<FakeBluetoothMediaTransportClient*>( |
+ DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); |
+ transport->SetVisible(object_path_, true); |
+ |
+ delegate_->SetConfiguration(transport_path, properties); |
+ } |
} |
void FakeBluetoothMediaEndpointServiceProvider::SelectConfiguration( |
const std::vector<uint8_t>& capabilities, |
const Delegate::SelectConfigurationCallback& callback) { |
- VLOG(1) << object_path_.value() << ": SelectConfiguration"; |
- delegate_->SelectConfiguration(capabilities, callback); |
+ if (visible_) { |
+ VLOG(1) << object_path_.value() << ": SelectConfiguration"; |
+ delegate_->SelectConfiguration(capabilities, callback); |
+ } |
} |
void FakeBluetoothMediaEndpointServiceProvider::ClearConfiguration( |
- const dbus::ObjectPath& transport_path) { |
- VLOG(1) << object_path_.value() << ": ClearConfiguration for" |
- << transport_path.value(); |
- delegate_->ClearConfiguration(transport_path); |
+ const ObjectPath& transport_path) { |
+ if (visible_) { |
+ VLOG(1) << object_path_.value() << ": ClearConfiguration on " |
+ << transport_path.value(); |
+ delegate_->ClearConfiguration(transport_path); |
+ } |
+} |
+ |
+void FakeBluetoothMediaEndpointServiceProvider::Released() { |
+ if (visible_) { |
+ VLOG(1) << object_path_.value() << ": Released"; |
+ delegate_->Released(); |
+ } |
} |
-void FakeBluetoothMediaEndpointServiceProvider::Release() { |
- VLOG(1) << object_path_.value() << ": Release"; |
- delegate_->Release(); |
+void FakeBluetoothMediaEndpointServiceProvider::SetVisible(bool visible) { |
+ visible_ = visible; |
+ |
+ FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>( |
+ DBusThreadManager::Get()->GetBluetoothMediaClient()); |
+ media->SetEndpointVisible(object_path_, visible_); |
} |
} // namespace chromeos |