Chromium Code Reviews| Index: device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| index 98124e87263c207558a893d1c378b0fefaf91684..1fd5f9d14e6d7a8eb6e5cbb9b61206e7ca043f49 100644 |
| --- a/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| +++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| @@ -6,6 +6,7 @@ |
| #include <algorithm> |
| #include <sstream> |
| +#include <string> |
| #include <vector> |
| #include "base/debug/stack_trace.h" |
| @@ -22,6 +23,14 @@ namespace { |
| // TODO(mcchou): Add the constant to dbus/service_constants.h. |
| const char kBluetoothAudioSinkServicePath[] = "/org/chromium/AudioSink"; |
| +// Used in VLOG. Translates a BluetoothAudioSink::State to verbose description. |
| +const std::vector<std::string> kState = { |
| + "invalid", "disconnected", "idle", "pending", "active"}; |
| +const std::vector<std::string> kErrorCode = {"unsupported platform", |
| + "invalid adapter", |
| + "not registered", |
| + "not unregistered"}; |
|
armansito
2015/02/28 00:50:28
Define helper functions that do the string convers
Ben Chan
2015/02/28 01:09:22
Don't define global constants of non-POD types (ht
Miao
2015/02/28 02:19:32
Done.
|
| + |
| ObjectPath GenerateEndpointPath() { |
| static unsigned int sequence_number = 0; |
| ++sequence_number; |
| @@ -33,7 +42,8 @@ ObjectPath GenerateEndpointPath() { |
| // A dummy error callback for calling Unregister() in destructor. |
| void UnregisterErrorCallback( |
| device::BluetoothAudioSink::ErrorCode error_code) { |
| - VLOG(1) << "Bluetooth audio sink: Error code: " << error_code; |
| + VLOG(1) << "Bluetooth audio sink: Error code: " << kErrorCode[error_code] |
|
armansito
2015/02/28 00:50:28
Should this be "UnregisterErrorCallback - Error co
Miao
2015/02/28 02:19:32
Done.
|
| + << "(" << error_code << ")"; |
| } |
| } // namespace |
| @@ -48,6 +58,8 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
| write_mtu_(nullptr), |
| adapter_(adapter), |
| weak_ptr_factory_(this) { |
| + VLOG(1) << "Bluetooth audio sink created"; |
| + |
| DCHECK(adapter_.get()); |
| DCHECK(adapter_->IsPresent()); |
| @@ -67,6 +79,8 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
| } |
| BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
| + VLOG(1) << "Bluetooth audio sink destroyed"; |
| + |
| DCHECK(adapter_.get()); |
| if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { |
| @@ -90,6 +104,8 @@ BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
| void BluetoothAudioSinkChromeOS::Unregister( |
| const base::Closure& callback, |
| const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
| + VLOG(1) << "Bluetooth audio sink: Unregister called"; |
| + |
| if (!DBusThreadManager::IsInitialized()) |
| error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
| @@ -154,6 +170,8 @@ void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
| void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { |
| if (object_path == media_path_) { |
| + VLOG(1) << "Bluetooth audio sink: media removed: " |
| + << object_path.value(); |
| StateChanged(BluetoothAudioSink::STATE_INVALID); |
| } |
| } |
| @@ -164,6 +182,8 @@ void BluetoothAudioSinkChromeOS::MediaTransportRemoved( |
| // transport object should be removed accordingly, and the state should be |
| // changed to STATE_DISCONNECTED. |
| if (object_path == transport_path_) { |
| + VLOG(1) << "Bluetooth audio sink: media transport removed: " |
|
armansito
2015/02/28 00:50:28
"Bluetooth audio sink - media transport removed: "
Miao
2015/02/28 02:19:33
Done.
|
| + << object_path.value(); |
| StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
| } |
| } |
| @@ -208,7 +228,7 @@ void BluetoothAudioSinkChromeOS::SetConfiguration( |
| // The initial state for a connection should be "idle". |
| if (properties.state != BluetoothMediaTransportClient::kStateIdle) { |
| - VLOG(1) << "Bluetooth Audio Sink: unexpected state " << properties.state; |
| + VLOG(1) << "Bluetooth audio sink: unexpected state " << properties.state; |
| return; |
| } |
| @@ -244,6 +264,8 @@ void BluetoothAudioSinkChromeOS::Register( |
| const BluetoothAudioSink::Options& options, |
| const base::Closure& callback, |
| const BluetoothAudioSink::ErrorCallback& error_callback) { |
| + VLOG(1) << "Bluetooth audio sink: Register called"; |
| + |
| DCHECK(adapter_.get()); |
| DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); |
| @@ -291,7 +313,8 @@ void BluetoothAudioSinkChromeOS::StateChanged( |
| if (state == state_) |
| return; |
| - VLOG(1) << "Bluetooth audio sink state changed: " << state; |
| + VLOG(1) << "Bluetooth audio sink state changed: " << kState[state]; |
| + |
| switch (state) { |
| case BluetoothAudioSink::STATE_INVALID: |
| ResetMedia(); |
| @@ -327,8 +350,8 @@ void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { |
| return; |
| VLOG(1) << "Bluetooth audio sink volume changed: " << volume; |
| - volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); |
| + volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); |
| FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, |
| BluetoothAudioSinkVolumeChanged(this, volume_)); |
| } |
| @@ -346,7 +369,8 @@ void BluetoothAudioSinkChromeOS::OnRegisterFailed( |
| const BluetoothAudioSink::ErrorCallback& error_callback, |
| const std::string& error_name, |
| const std::string& error_message) { |
| - VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; |
| + VLOG(1) << "Bluetooth audio sink: error " << error_name << ": " |
| + << error_message; |
| ResetEndpoint(); |
| error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); |
| @@ -366,7 +390,9 @@ void BluetoothAudioSinkChromeOS::OnUnregisterFailed( |
| const device::BluetoothAudioSink::ErrorCallback& error_callback, |
| const std::string& error_name, |
| const std::string& error_message) { |
| - VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; |
| + VLOG(1) << "Bluetooth audio sink: error " << error_name << ": " |
|
armansito
2015/02/28 00:50:28
"UnregisterError - error_name: " << error_name <<
Miao
2015/02/28 02:19:33
Done.
|
| + << error_message; |
| + |
| error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
| } |
| @@ -379,10 +405,14 @@ void BluetoothAudioSinkChromeOS::ReadFromFD() { |
| } |
| void BluetoothAudioSinkChromeOS::ResetMedia() { |
| + VLOG(1) << "Bluetooth audio sink: ResetMedia"; |
| + |
| media_path_ = dbus::ObjectPath(""); |
| } |
| void BluetoothAudioSinkChromeOS::ResetTransport() { |
| + VLOG(1) << "Bluetooth audio sink: ResetTransport"; |
| + |
| if (transport_path_.value() == "") |
| return; |
| transport_path_ = dbus::ObjectPath(""); |
| @@ -393,6 +423,8 @@ void BluetoothAudioSinkChromeOS::ResetTransport() { |
| } |
| void BluetoothAudioSinkChromeOS::ResetEndpoint() { |
| + VLOG(1) << "Bluetooth audio sink: ResetEndpoint"; |
| + |
| endpoint_path_ = ObjectPath(""); |
| media_endpoint_ = nullptr; |
| } |