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

Unified Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 933823003: bluetooth: Modify DCHECK to conditionals in several BluetoothAdapterChromeOS methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: 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_);

Powered by Google App Engine
This is Rietveld 408576698