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

Unified Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 876153002: device/bluetooth:Implement Register() for BluetoothAudioSinkChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: device/bluetooth/bluetooth_adapter_chromeos.cc
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index 9bc4c55f724414b00ec42b39dbcaac279a6dfc64..2c5ae52d3481d1f6e9fa77ef8fcd70ab3babd7fb 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -20,6 +20,7 @@
#include "chromeos/dbus/bluetooth_device_client.h"
#include "chromeos/dbus/bluetooth_input_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "device/bluetooth/bluetooth_audio_sink_chromeos.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_device_chromeos.h"
#include "device/bluetooth/bluetooth_pairing_chromeos.h"
@@ -305,11 +306,14 @@ void BluetoothAdapterChromeOS::RegisterAudioSink(
const device::BluetoothAudioSink::Options& options,
const device::BluetoothAdapter::AcquiredCallback& callback,
const device::BluetoothAudioSink::ErrorCallback& error_callback) {
- // TODO(mcchou): Create and register a BluetoothAudioSink. Add the
- // newly-created audio sink as an observer of the adapter.
- // Add OnRegisterAudioSink(AcquiredCallback& , BluetoothAudioSink*) and pass
- // it as an argument to BluetoothAudioSinkChromeOS::Register.
- error_callback.Run(device::BluetoothAudioSink::ERROR_UNSUPPORTED_PLATFORM);
+ VLOG(1) << "Registering audio sink";
+ BluetoothAudioSinkChromeOS* audio_sink = new BluetoothAudioSinkChromeOS(this);
+ audio_sink->Register(
+ options,
+ base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink,
+ weak_ptr_factory_.GetWeakPtr(), callback,
+ scoped_refptr<device::BluetoothAudioSink>(audio_sink)),
+ error_callback);
}
void BluetoothAdapterChromeOS::RemovePairingDelegateInternal(
@@ -651,6 +655,13 @@ void BluetoothAdapterChromeOS::OnRequestDefaultAgentError(
<< error_name << ": " << error_message;
}
+void BluetoothAdapterChromeOS::OnRegisterAudioSink(
+ const device::BluetoothAdapter::AcquiredCallback& callback,
+ scoped_refptr<device::BluetoothAudioSink> audio_sink) {
+ DCHECK(audio_sink);
armansito 2015/01/27 04:38:05 DCHECK(audio_sink.get())?
Miao 2015/01/28 02:05:01 Done.
+ callback.Run(audio_sink);
+}
+
BluetoothDeviceChromeOS*
BluetoothAdapterChromeOS::GetDeviceWithPath(
const dbus::ObjectPath& object_path) {
@@ -984,7 +995,7 @@ void BluetoothAdapterChromeOS::AddDiscoverySession(
}
// There are no active discovery sessions.
- DCHECK(num_discovery_sessions_ == 0);
+ DCHECK_EQ(num_discovery_sessions_, 0);
armansito 2015/01/27 04:38:05 Is this refactor related to this CL?
Miao 2015/01/28 02:05:01 It is not related to this CL. Lint complained abou
// This is the first request to start device discovery.
discovery_request_pending_ = true;
@@ -1034,7 +1045,7 @@ void BluetoothAdapterChromeOS::RemoveDiscoverySession(
// There is exactly one active discovery session. Request BlueZ to stop
// discovery.
- DCHECK(num_discovery_sessions_ == 1);
+ DCHECK_EQ(num_discovery_sessions_, 1);
discovery_request_pending_ = true;
DBusThreadManager::Get()->GetBluetoothAdapterClient()->
StopDiscovery(
@@ -1052,7 +1063,7 @@ void BluetoothAdapterChromeOS::OnStartDiscovery(const base::Closure& callback) {
// Report success on the original request and increment the count.
VLOG(1) << __func__;
DCHECK(discovery_request_pending_);
- DCHECK(num_discovery_sessions_ == 0);
+ DCHECK_EQ(num_discovery_sessions_, 0);
discovery_request_pending_ = false;
num_discovery_sessions_++;
callback.Run();
@@ -1071,7 +1082,7 @@ void BluetoothAdapterChromeOS::OnStartDiscoveryError(
<< error_name << ": " << error_message;
// Failed to start discovery. This can only happen if the count is at 0.
- DCHECK(num_discovery_sessions_ == 0);
+ DCHECK_EQ(num_discovery_sessions_, 0);
DCHECK(discovery_request_pending_);
discovery_request_pending_ = false;
@@ -1095,7 +1106,7 @@ void BluetoothAdapterChromeOS::OnStopDiscovery(const base::Closure& callback) {
// Report success on the original request and decrement the count.
VLOG(1) << __func__;
DCHECK(discovery_request_pending_);
- DCHECK(num_discovery_sessions_ == 1);
+ DCHECK_EQ(num_discovery_sessions_, 1);
discovery_request_pending_ = false;
num_discovery_sessions_--;
callback.Run();
@@ -1114,7 +1125,7 @@ void BluetoothAdapterChromeOS::OnStopDiscoveryError(
// Failed to stop discovery. This can only happen if the count is at 1.
DCHECK(discovery_request_pending_);
- DCHECK(num_discovery_sessions_ == 1);
+ DCHECK_EQ(num_discovery_sessions_, 1);
discovery_request_pending_ = false;
error_callback.Run();

Powered by Google App Engine
This is Rietveld 408576698