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 e6c628322d349b629b507b17f753d8d541b35955..8b93a1a58f887cd0fd05b4b9c4249a99d21d46f2 100644 |
| --- a/device/bluetooth/bluetooth_adapter_chromeos.cc |
| +++ b/device/bluetooth/bluetooth_adapter_chromeos.cc |
| @@ -324,7 +324,6 @@ void BluetoothAdapterChromeOS::RegisterAudioSink( |
| void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( |
| BluetoothDevice::PairingDelegate* pairing_delegate) { |
| - DCHECK(IsPresent()); |
| // Before removing a pairing delegate make sure that there aren't any devices |
| // currently using it; if there are, clear the pairing context which will |
| // make any responses no-ops. |
| @@ -481,7 +480,8 @@ void BluetoothAdapterChromeOS::InputPropertyChanged( |
| } |
| void BluetoothAdapterChromeOS::Released() { |
| - DCHECK(IsPresent()); |
| + if (!IsPresent()) |
| + return; |
|
armansito
2015/02/19 01:44:47
Since we don't really do anything, here I would ju
scheib
2015/02/19 21:34:15
Logging moved above return. The conditional return
|
| DCHECK(agent_.get()); |
| VLOG(1) << "Release"; |
| @@ -624,7 +624,6 @@ void BluetoothAdapterChromeOS::Cancel() { |
| } |
| void BluetoothAdapterChromeOS::OnRegisterAgent() { |
| - DCHECK(IsPresent()); |
| VLOG(1) << "Pairing agent registered, requesting to be made default"; |
| DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> |
| @@ -639,7 +638,6 @@ void BluetoothAdapterChromeOS::OnRegisterAgent() { |
| void BluetoothAdapterChromeOS::OnRegisterAgentError( |
| const std::string& error_name, |
| const std::string& error_message) { |
| - DCHECK(IsPresent()); |
| // Our agent being already registered isn't an error. |
| if (error_name == bluetooth_agent_manager::kErrorAlreadyExists) |
| return; |
| @@ -649,14 +647,12 @@ void BluetoothAdapterChromeOS::OnRegisterAgentError( |
| } |
| void BluetoothAdapterChromeOS::OnRequestDefaultAgent() { |
| - DCHECK(IsPresent()); |
| VLOG(1) << "Pairing agent now default"; |
| } |
| void BluetoothAdapterChromeOS::OnRequestDefaultAgentError( |
| const std::string& error_name, |
| const std::string& error_message) { |
| - DCHECK(IsPresent()); |
| LOG(WARNING) << ": Failed to make pairing agent default: " |
| << error_name << ": " << error_message; |
| } |
| @@ -664,6 +660,8 @@ void BluetoothAdapterChromeOS::OnRequestDefaultAgentError( |
| void BluetoothAdapterChromeOS::OnRegisterAudioSink( |
| const device::BluetoothAdapter::AcquiredCallback& callback, |
| scoped_refptr<BluetoothAudioSink> audio_sink) { |
| + if (!IsPresent()) |
|
armansito
2015/02/19 01:44:47
This really shouldn't happen, since this method ge
scheib
2015/02/19 21:34:15
Done.
|
| + return; |
| DCHECK(audio_sink.get()); |
| callback.Run(audio_sink); |
| } |
| @@ -1019,7 +1017,10 @@ void BluetoothAdapterChromeOS::OnSetDiscoverable( |
| const base::Closure& callback, |
| const ErrorCallback& error_callback, |
| bool success) { |
| - DCHECK(IsPresent()); |
| + if (!IsPresent()) { |
| + error_callback.Run(); |
| + return; |
| + } |
|
armansito
2015/02/19 01:44:47
nit: newline after '}'.
scheib
2015/02/19 21:34:15
Done.
|
| // Set the discoverable_timeout property to zero so the adapter remains |
| // discoverable forever. |
| DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
| @@ -1035,8 +1036,7 @@ void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( |
| const base::Closure& callback, |
| const ErrorCallback& error_callback, |
| bool success) { |
| - DCHECK(IsPresent()); |
| - if (success) |
| + if (IsPresent() && success) |
| callback.Run(); |
| else |
| error_callback.Run(); |
| @@ -1089,7 +1089,11 @@ void BluetoothAdapterChromeOS::AddDiscoverySession( |
| void BluetoothAdapterChromeOS::RemoveDiscoverySession( |
| const base::Closure& callback, |
| const ErrorCallback& error_callback) { |
| - DCHECK(IsPresent()); |
| + if (!IsPresent()) { |
| + error_callback.Run(); |
| + return; |
| + } |
| + |
| VLOG(1) << __func__; |
| // There are active sessions other than the one currently being removed. |
| if (num_discovery_sessions_ > 1) { |
| @@ -1152,7 +1156,10 @@ void BluetoothAdapterChromeOS::OnStartDiscoveryError( |
| const ErrorCallback& error_callback, |
| const std::string& error_name, |
| const std::string& error_message) { |
| - DCHECK(IsPresent()); |
| + if (!IsPresent()) { |
| + error_callback.Run(); |
| + return; |
| + } |
| LOG(WARNING) << object_path_.value() << ": Failed to start discovery: " |
| << error_name << ": " << error_message; |
| @@ -1194,9 +1201,12 @@ void BluetoothAdapterChromeOS::OnStopDiscoveryError( |
| const ErrorCallback& error_callback, |
| const std::string& error_name, |
| const std::string& error_message) { |
| - DCHECK(IsPresent()); |
| LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " |
| << error_name << ": " << error_message; |
| + if (!IsPresent()) { |
| + error_callback.Run(); |
| + return; |
| + } |
|
armansito
2015/02/19 01:44:47
Wouldn't we want to clear the pending discovery re
scheib
2015/02/19 21:34:15
Done.
|
| // Failed to stop discovery. This can only happen if the count is at 1. |
| DCHECK(discovery_request_pending_); |