summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorkeybuk@google.com <keybuk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 18:39:44 +0000
committerkeybuk@google.com <keybuk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 18:39:44 +0000
commit95e9859ccccc4a131d1d68767fa6cd6d9a18658a (patch)
tree3a75d9acf6a9122d2a40a5383c9d73dbfc26da81 /chrome/browser
parent9c02fa0e4d7a8126f4901c8d28b0d2468a3e2fa5 (diff)
downloadchromium_src-95e9859ccccc4a131d1d68767fa6cd6d9a18658a.zip
chromium_src-95e9859ccccc4a131d1d68767fa6cd6d9a18658a.tar.gz
chromium_src-95e9859ccccc4a131d1d68767fa6cd6d9a18658a.tar.bz2
bluetooth: obtain D-Bus error for select methods
For the CreateDevice, CreatePairedDevice and Connect methods use CallMethodWithErrorCallback rather than CallMethod so that we obtain richer error information from the BlueZ service. BUG=chromium-os:27902 TEST=make chrome Change-Id: If801d834604e4c2142c20169603bc527bde09403 Review URL: https://chromiumcodereview.appspot.com/10409062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_device.cc94
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_device.h40
2 files changed, 82 insertions, 52 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
index 7eaebf8..4bf458f 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
@@ -255,6 +255,9 @@ void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
address_,
base::Bind(&BluetoothDevice::ConnectCallback,
weak_ptr_factory_.GetWeakPtr(),
+ error_callback),
+ base::Bind(&BluetoothDevice::ConnectErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(),
error_callback));
} else {
// Initiate high-security connection with pairing.
@@ -284,42 +287,47 @@ void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
bluetooth_agent::kDisplayYesNoCapability,
base::Bind(&BluetoothDevice::ConnectCallback,
weak_ptr_factory_.GetWeakPtr(),
+ error_callback),
+ base::Bind(&BluetoothDevice::ConnectErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(),
error_callback));
}
}
void BluetoothDevice::ConnectCallback(ErrorCallback error_callback,
- const dbus::ObjectPath& device_path,
- bool success) {
- if (success) {
- DVLOG(1) << "Connection successful: " << device_path.value();
- if (object_path_.value().empty()) {
- object_path_ = device_path;
- } else {
- LOG_IF(WARNING, object_path_ != device_path)
- << "Conflicting device paths for objects, result gave: "
- << device_path.value() << " but signal gave: "
- << object_path_.value();
- }
-
- // Mark the device trusted so it can connect to us automatically, and
- // we can connect after rebooting. This information is part of the
- // pairing information of the device, and is unique to the combination
- // of our bluetooth address and the device's bluetooth address. A
- // different host needs a new pairing, so it's not useful to sync.
- DBusThreadManager::Get()->GetBluetoothDeviceClient()->
- GetProperties(object_path_)->trusted.Set(
- true,
- base::Bind(&BluetoothDevice::OnSetTrusted,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
-
- // Connect application-layer protocols.
- ConnectApplications(error_callback);
+ const dbus::ObjectPath& device_path) {
+ DVLOG(1) << "Connection successful: " << device_path.value();
+ if (object_path_.value().empty()) {
+ object_path_ = device_path;
} else {
- LOG(WARNING) << "Connection failed: " << address_;
- error_callback.Run();
+ LOG_IF(WARNING, object_path_ != device_path)
+ << "Conflicting device paths for objects, result gave: "
+ << device_path.value() << " but signal gave: "
+ << object_path_.value();
}
+
+ // Mark the device trusted so it can connect to us automatically, and
+ // we can connect after rebooting. This information is part of the
+ // pairing information of the device, and is unique to the combination
+ // of our bluetooth address and the device's bluetooth address. A
+ // different host needs a new pairing, so it's not useful to sync.
+ DBusThreadManager::Get()->GetBluetoothDeviceClient()->
+ GetProperties(object_path_)->trusted.Set(
+ true,
+ base::Bind(&BluetoothDevice::OnSetTrusted,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+
+ // Connect application-layer protocols.
+ ConnectApplications(error_callback);
+}
+
+void BluetoothDevice::ConnectErrorCallback(ErrorCallback error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ LOG(WARNING) << "Connection failed: " << address_
+ << ": " << error_name << ": " << error_message;
+ error_callback.Run();
}
void BluetoothDevice::OnSetTrusted(ErrorCallback error_callback, bool success) {
@@ -365,22 +373,28 @@ void BluetoothDevice::OnIntrospect(ErrorCallback error_callback,
Connect(object_path_,
base::Bind(&BluetoothDevice::OnConnect,
weak_ptr_factory_.GetWeakPtr(),
+ *iter),
+ base::Bind(&BluetoothDevice::OnConnectError,
+ weak_ptr_factory_.GetWeakPtr(),
error_callback, *iter));
}
}
}
-void BluetoothDevice::OnConnect(ErrorCallback error_callback,
- const std::string& interface_name,
- const dbus::ObjectPath& device_path,
- bool success) {
- if (success) {
- DVLOG(1) << "Application connection successful: " << device_path.value()
- << ": " << interface_name;
- } else {
- LOG(WARNING) << "Connection failed: " << address_ << ": " << interface_name;
- error_callback.Run();
- }
+void BluetoothDevice::OnConnect(const std::string& interface_name,
+ const dbus::ObjectPath& device_path) {
+ DVLOG(1) << "Application connection successful: " << device_path.value()
+ << ": " << interface_name;
+}
+
+void BluetoothDevice::OnConnectError(ErrorCallback error_callback,
+ const std::string& interface_name,
+ const dbus::ObjectPath& device_path,
+ const std::string& error_name,
+ const std::string& error_message) {
+ LOG(WARNING) << "Connection failed: " << address_ << ": " << interface_name
+ << ": " << error_name << ": " << error_message;
+ error_callback.Run();
}
void BluetoothDevice::SetPinCode(const std::string& pincode) {
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.h b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
index 8892bce..cd46b7f 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.h
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
@@ -284,12 +284,19 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
bool update_state);
// Called by BluetoothAdapterClient when a call to CreateDevice() or
- // CreatePairedDevice() to provide the new object path for the remote
- // device in |device_path| and |success| which indicates whether or not
- // the request succeeded. |error_callback| is the callback provided to
+ // CreatePairedDevice() succeeds, provides the new object path for the remote
+ // device in |device_path|. |error_callback| is the callback provided to
// Connect().
void ConnectCallback(ErrorCallback error_callback,
- const dbus::ObjectPath& device_path, bool success);
+ const dbus::ObjectPath& device_path);
+
+ // Called by BluetoothAdapterClient when a call to CreateDevice() or
+ // CreatePairedDevice() fails with the error named |error_name| and
+ // optional message |error_message|, |error_callback| is the callback
+ // provided to Connect().
+ void ConnectErrorCallback(ErrorCallback error_callback,
+ const std::string& error_name,
+ const std::string& error_message);
// Called by BluetoothProperty when the call to Set() for the Trusted
// property completes. |success| indicates whether or not the request
@@ -311,14 +318,23 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
const dbus::ObjectPath& device_path,
const std::string& xml_data, bool success);
- // Called by BluetoothInputClient when the call to Connect() completes.
- // |success| indicates whether or not the request succeed, |error_callback|
- // is the callback provided to ConnectApplications(), |interface_name|
- // specifies the interface being connect and |device_path| the remote
- // object path.
- void OnConnect(ErrorCallback error_callback,
- const std::string& interface_name,
- const dbus::ObjectPath& device_path, bool success);
+ // Called by BluetoothInputClient when the call to Connect() succeeds.
+ // |error_callback| is the callback provided to ConnectApplications(),
+ // |interface_name| specifies the interface being connected and
+ // |device_path| the remote object path.
+ void OnConnect(const std::string& interface_name,
+ const dbus::ObjectPath& device_path);
+
+ // Called by BluetoothInputClient when the call to Connect() fails.
+ // |error_callback| is the callback provided to ConnectApplications(),
+ // |interface_name| specifies the interface being connected,
+ // |device_path| the remote object path,
+ // |error_name| the error name and |error_message| the optional message.
+ void OnConnectError(ErrorCallback error_callback,
+ const std::string& interface_name,
+ const dbus::ObjectPath& device_path,
+ const std::string& error_name,
+ const std::string& error_message);
// Called by BluetoothDeviceClient when a call to Disconnect() completes,
// |success| indicates whether or not the request succeeded, |error_callback|