Chromium Code Reviews| 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..fae8f59f36c9fbeff4426dadeefaf1eb2e0e6b18 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) { |
|
armansito
2015/01/29 04:22:55
You should check here that adapter_->IsPresent is
Miao
2015/01/29 23:58:38
Done.
|
| - // 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"; |
| + scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink( |
| + new BluetoothAudioSinkChromeOS(this)); |
| + audio_sink->Register( |
| + options, |
| + base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink, |
| + weak_ptr_factory_.GetWeakPtr(), callback, 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.get()); |
| + 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); |
| // 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(); |