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

Unified Diff: chrome/browser/chromeos/bluetooth/bluetooth_device.h

Issue 10007008: Add support for creating bluetooth RFCOMM sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extensions code Created 8 years, 8 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: chrome/browser/chromeos/bluetooth/bluetooth_device.h
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.h b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
index 7c27ba2f68287ece0c9168fa9762c9ae3a040b3b..77e5e3520ea5cfe654db5e00552814f26b0af8fb 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.h
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "chromeos/dbus/bluetooth_agent_service_provider.h"
#include "chromeos/dbus/bluetooth_device_client.h"
@@ -20,6 +21,7 @@
namespace chromeos {
class BluetoothAdapter;
+class BluetoothSocket;
// The BluetoothDevice class represents a remote Bluetooth device, both
// its properties and capabilities as discovered by a local adapter and
@@ -249,6 +251,20 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
// have been deleted. If the request fails, |error_callback| will be called.
void Forget(ErrorCallback error_callback);
+ // SocketCallback is used by ConnectToService to return a BluetoothSocket
+ // to the caller, or NULL if there was an error. The socket will remain open
+ // until the last reference to the returned BluetoothSocket is released.
+ typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> SocketCallback;
+
+ // Attempts to open a socket to a service matching |uuid| on this device. If
+ // the connection is successful, |callback| is called with a BluetoothSocket.
+ // Otherwise |callback| is called with NULL. The socket is closed as soon as
+ // all references to the BluetoothSocket are released. Note that the
+ // BluetoothSocket object can outlive both this BluetoothDevice and the
+ // BluetoothAdapter for this device.
+ void ConnectToService(const std::string& service_uuid,
+ SocketCallback callback);
+
private:
friend class BluetoothAdapter;
@@ -327,6 +343,21 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
const BluetoothDeviceClient::ServiceMap& service_map,
bool success);
+ // Opens a socket to this device on the provided |channel|.
+ scoped_refptr<BluetoothSocket> OpenSocket(const std::string& service_uuid,
+ uint8_t channel);
keybuk 2012/04/19 23:30:11 OpenSocket is gone now, right?
bryeung 2012/04/20 00:17:56 Oops! Good catch.
+
+ // Called by BluetoothDeviceClient when a call to DiscoverServices() that was
+ // initated from ConnectToService completes. The |callback| is called with
+ // true iff a connection was successfully established. The rest of the
+ // parameters are as documented for a BluetoothDeviceClient::ServicesCallback.
+ void ConnectToMatchingService(
+ const std::string& service_uuid,
+ SocketCallback callback,
+ const dbus::ObjectPath& object_path,
+ const BluetoothDeviceClient::ServiceMap& service_map,
+ bool success);
+
// BluetoothDeviceClient::Observer override.
//
// Called when the device with object path |object_path| is about

Powered by Google App Engine
This is Rietveld 408576698