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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 273953002: Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang warnings, test flakiness, and bluetooth.connect should succeed even if monitor fails Created 6 years, 7 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
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/bluetooth_api.h ('k') | chromeos/dbus/bluetooth_device_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index 14bff9d6aad235e415c8207ab7a46f8a67534886..026c5edf507065ff6c57456f49fb1805fa9b25f5 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind_helpers.h"
#include "base/lazy_instance.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
@@ -457,13 +458,36 @@ bool BluetoothConnectFunction::DoWork(scoped_refptr<BluetoothAdapter> adapter) {
device->ConnectToProfile(
bluetooth_profile,
- base::Bind(&BluetoothConnectFunction::OnSuccessCallback, this),
+ base::Bind(&BluetoothConnectFunction::OnConnectedCallback,
+ this,
+ adapter,
+ device->GetAddress()),
base::Bind(&BluetoothConnectFunction::OnErrorCallback, this));
return true;
}
-void BluetoothConnectFunction::OnSuccessCallback() {
+void BluetoothConnectFunction::OnConnectedCallback(
+ scoped_refptr<device::BluetoothAdapter> adapter,
+ const std::string& device_address) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ // TODO(tengs): Remove this once we have an API for starting the connection
+ // monitor.
+ BluetoothDevice* device = adapter->GetDevice(device_address);
+ if (!device) {
+ SetError(kInvalidDevice);
+ SendResponse(false);
+ return;
+ }
+ // Start the connection monitor, and return success even if this fails,
+ // as the connection was still opened successfully.
+ device->StartConnectionMonitor(
+ base::Bind(&BluetoothConnectFunction::OnMonitorStartedCallback, this),
+ base::Bind(&BluetoothConnectFunction::OnMonitorStartedCallback, this));
+}
+
+void BluetoothConnectFunction::OnMonitorStartedCallback() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
SendResponse(true);
}
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/bluetooth_api.h ('k') | chromeos/dbus/bluetooth_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698