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

Unified Diff: chromeos/dbus/fake_bluetooth_media_transport_client.cc

Issue 939753004: device/bluetooth: Implement Unregister() of BlueotoothAudioSinkChromeOS and disconnection-related c… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised helper functions in FakeBluetoothMediaClient and FakeBluetoothMediaTransportClient and modi… Created 5 years, 10 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
Index: chromeos/dbus/fake_bluetooth_media_transport_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.cc b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
index 26fb832d431df651c0e8ae47cb248e6ffec021cb..ea59ac8c375657e27ccc76b9218d73cc1ac372f1 100644
--- a/chromeos/dbus/fake_bluetooth_media_transport_client.cc
+++ b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
@@ -4,10 +4,14 @@
#include "chromeos/dbus/fake_bluetooth_media_transport_client.h"
+#include <sstream>
+
#include "base/bind.h"
+#include "base/stl_util.h"
#include "chromeos/dbus/bluetooth_media_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_bluetooth_media_client.h"
+#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h"
using dbus::ObjectPath;
@@ -17,13 +21,19 @@ namespace {
const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1";
const char kNotImplemented[] = "org.bluez.NotImplemented";
+ObjectPath GenerateTransportPath() {
+ static unsigned int sequence_number = 0;
+ ++sequence_number;
+ std::stringstream path;
+ path << "fake/hci0/dev_00_00_00_00_00_00/fd" << sequence_number;
armansito 2015/02/23 22:07:06 nit: if you want to truly simulate bluez's behavio
Miao 2015/02/24 01:12:12 Referred to chromeos::FakeBluetoothAdapterClient::
+ return ObjectPath(path.str());
+}
+
} // namespace
namespace chromeos {
// static
-const char FakeBluetoothMediaTransportClient::kTransportPath[] =
- "/fake/hci0/dev_00_00_00_00_00_00/fd0";
const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] =
"/fake/hci0/dev_00_00_00_00_00_00";
armansito 2015/02/23 22:07:06 nit: How about "*/fake_audio_source"? Also, can th
Miao 2015/02/24 01:12:12 Done.
const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00;
@@ -64,8 +74,7 @@ void FakeBluetoothMediaTransportClient::Properties::Set(
callback.Run(false);
}
-FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient()
- : object_path_(ObjectPath(kTransportPath)) {
+FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() {
// TODO(mcchou): Multiple endpoints are sharing one property set for now.
// Add property sets accordingly to separate the
// MediaTransportPropertiesChanged events for different endpoints.
@@ -130,20 +139,36 @@ void FakeBluetoothMediaTransportClient::Release(
}
void FakeBluetoothMediaTransportClient::SetValid(
- const ObjectPath& endpoint_path,
+ FakeBluetoothMediaEndpointServiceProvider* endpoint,
bool valid) {
+ FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>(
+ DBusThreadManager::Get()->GetBluetoothMediaClient());
+ DCHECK(media);
+
+ ObjectPath endpoint_path(endpoint->object_path());
+ if (!media->IsRegistered(endpoint_path))
+ return;
+
if (valid) {
- endpoints_[endpoint_path] = valid;
+ ObjectPath transport_path = GenerateTransportPath();
+ VLOG(1) << "New transport, " << transport_path.value()
+ << " is created for endpoint " << endpoint_path.value();
+ endpoints_[endpoint_path] = transport_path;
return;
}
- endpoints_.erase(endpoint_path);
-
- // TODO(mcchou): Since there is only one transport path, all observers will
- // be notified. Shades irrelevant observers.
// Notifies observers about the state change of the transport.
FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_,
- MediaTransportRemoved(object_path_));
+ MediaTransportRemoved(endpoints_[endpoint_path]));
+ endpoints_.erase(endpoint_path);
+ endpoint->ClearConfiguration(GetTransportPath(endpoint_path));
+}
+
+ObjectPath FakeBluetoothMediaTransportClient::GetTransportPath(
+ ObjectPath endpoint_path) {
+ if (ContainsKey(endpoints_, endpoint_path))
+ return endpoints_[endpoint_path];
+ return ObjectPath("");
}
void FakeBluetoothMediaTransportClient::OnPropertyChanged(

Powered by Google App Engine
This is Rietveld 408576698