Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" | 5 #include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" |
| 6 | 6 |
| 7 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 8 #include "chromeos/dbus/fake_bluetooth_media_client.h" | |
| 9 #include "chromeos/dbus/fake_bluetooth_media_transport_client.h" | |
| 10 | |
| 11 using dbus::ObjectPath; | |
| 12 | |
| 7 namespace chromeos { | 13 namespace chromeos { |
| 8 | 14 |
| 9 // TODO(mcchou): Add the logic of the behavior. | 15 // TODO(mcchou): Add the logic of the behavior. |
| 10 FakeBluetoothMediaEndpointServiceProvider:: | 16 FakeBluetoothMediaEndpointServiceProvider:: |
| 11 FakeBluetoothMediaEndpointServiceProvider( | 17 FakeBluetoothMediaEndpointServiceProvider(const ObjectPath object_path, |
| 12 const dbus::ObjectPath object_path, Delegate* delegate) | 18 Delegate* delegate) |
| 13 : object_path_(object_path) , delegate_(delegate) { | 19 : visible_(false), object_path_(object_path), delegate_(delegate) { |
| 14 VLOG(1) << "Create Bluetooth Media Endpoint: " << object_path_.value(); | 20 VLOG(1) << "Create Bluetooth Media Endpoint: " << object_path_.value(); |
| 15 // TODO(mcchou): Use the FakeBluetoothMediaClient in DBusThreadManager | |
| 16 // to register the FakeBluetoothMediaEndpoint object. | |
| 17 } | 21 } |
| 18 | 22 |
| 19 FakeBluetoothMediaEndpointServiceProvider:: | 23 FakeBluetoothMediaEndpointServiceProvider:: |
| 20 ~FakeBluetoothMediaEndpointServiceProvider() { | 24 ~FakeBluetoothMediaEndpointServiceProvider() { |
| 21 VLOG(1) << "Cleaning up Bluetooth Media Endpoint: " << object_path_.value(); | 25 VLOG(1) << "Cleaning up Bluetooth Media Endpoint: " << object_path_.value(); |
| 22 // TODO(mcchou): Use the FakeBluetoothMediaClient in DBusThreadManager | 26 // TODO(mcchou): Use the FakeBluetoothMediaClient in DBusThreadManager |
| 23 // to unregister the FakeBluetoothMediaEndpoint object. | 27 // to unregister the FakeBluetoothMediaEndpoint object. |
| 24 } | 28 } |
| 25 | 29 |
| 26 void FakeBluetoothMediaEndpointServiceProvider::SetConfiguration( | 30 void FakeBluetoothMediaEndpointServiceProvider::SetConfiguration( |
| 27 const dbus::ObjectPath& transport_path, | 31 const ObjectPath& transport_path, |
| 28 const dbus::MessageReader& properties) { | 32 const Delegate::TransportProperties& properties) { |
| 29 VLOG(1) << object_path_.value() << ": SetConfiguration for " | 33 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.
| |
| 30 << transport_path.value(); | 34 VLOG(1) << object_path_.value() << ": SetConfiguration for " |
| 31 delegate_->SetConfiguration(transport_path, properties); | 35 << transport_path.value(); |
| 36 | |
| 37 // Sets the visibility to the transport object to true if the media object | |
| 38 // is valid. | |
| 39 FakeBluetoothMediaTransportClient* transport = | |
| 40 static_cast<FakeBluetoothMediaTransportClient*>( | |
| 41 DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); | |
| 42 transport->SetVisible(object_path_, true); | |
| 43 | |
| 44 delegate_->SetConfiguration(transport_path, properties); | |
| 45 } | |
| 32 } | 46 } |
| 33 | 47 |
| 34 void FakeBluetoothMediaEndpointServiceProvider::SelectConfiguration( | 48 void FakeBluetoothMediaEndpointServiceProvider::SelectConfiguration( |
| 35 const std::vector<uint8_t>& capabilities, | 49 const std::vector<uint8_t>& capabilities, |
| 36 const Delegate::SelectConfigurationCallback& callback) { | 50 const Delegate::SelectConfigurationCallback& callback) { |
| 37 VLOG(1) << object_path_.value() << ": SelectConfiguration"; | 51 if (visible_) { |
| 38 delegate_->SelectConfiguration(capabilities, callback); | 52 VLOG(1) << object_path_.value() << ": SelectConfiguration"; |
| 53 delegate_->SelectConfiguration(capabilities, callback); | |
| 54 } | |
| 39 } | 55 } |
| 40 | 56 |
| 41 void FakeBluetoothMediaEndpointServiceProvider::ClearConfiguration( | 57 void FakeBluetoothMediaEndpointServiceProvider::ClearConfiguration( |
| 42 const dbus::ObjectPath& transport_path) { | 58 const ObjectPath& transport_path) { |
| 43 VLOG(1) << object_path_.value() << ": ClearConfiguration for" | 59 if (visible_) { |
| 44 << transport_path.value(); | 60 VLOG(1) << object_path_.value() << ": ClearConfiguration on " |
| 45 delegate_->ClearConfiguration(transport_path); | 61 << transport_path.value(); |
| 62 delegate_->ClearConfiguration(transport_path); | |
| 63 } | |
| 46 } | 64 } |
| 47 | 65 |
| 48 void FakeBluetoothMediaEndpointServiceProvider::Release() { | 66 void FakeBluetoothMediaEndpointServiceProvider::Released() { |
| 49 VLOG(1) << object_path_.value() << ": Release"; | 67 if (visible_) { |
| 50 delegate_->Release(); | 68 VLOG(1) << object_path_.value() << ": Released"; |
| 69 delegate_->Released(); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 void FakeBluetoothMediaEndpointServiceProvider::SetVisible(bool visible) { | |
| 74 visible_ = visible; | |
| 75 | |
| 76 FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>( | |
| 77 DBusThreadManager::Get()->GetBluetoothMediaClient()); | |
| 78 media->SetEndpointVisible(object_path_, visible_); | |
| 51 } | 79 } |
| 52 | 80 |
| 53 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |