Index: device/bluetooth/bluetooth_socket_win.h |
diff --git a/device/bluetooth/bluetooth_socket_win.h b/device/bluetooth/bluetooth_socket_win.h |
index 666b6a57957e804006a8cdd2ef5f60ac6365e9d7..22ec412a1f4499af5670ac61b54f335a92813ae7 100644 |
--- a/device/bluetooth/bluetooth_socket_win.h |
+++ b/device/bluetooth/bluetooth_socket_win.h |
@@ -13,45 +13,43 @@ |
#include "device/bluetooth/bluetooth_service_record_win.h" |
#include "device/bluetooth/bluetooth_socket.h" |
#include "device/bluetooth/bluetooth_socket_net.h" |
+#include "device/bluetooth/bluetooth_uuid.h" |
#include "net/base/ip_endpoint.h" |
#include "net/socket/tcp_socket.h" |
namespace device { |
-class BluetoothServiceRecord; |
+class BluetoothAdapter; |
+class BluetoothDeviceWin; |
// The BluetoothSocketWin class implements BluetoothSocket for the Microsoft |
// Windows platform. |
class BluetoothSocketWin : public BluetoothSocketNet { |
public: |
- typedef base::Callback<void(scoped_refptr<BluetoothSocketWin>, |
- const net::IPEndPoint&)> OnNewConnectionCallback; |
- |
static scoped_refptr<BluetoothSocketWin> CreateBluetoothSocket( |
scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
scoped_refptr<BluetoothSocketThread> socket_thread, |
net::NetLog* net_log, |
const net::NetLog::Source& source); |
- // Starts a service with the given uuid, name and rfcomm_channel. |
- // |success_callback| is invoked when the underlying socket is created |
- // and the service is published successfully. Otherwise, |error_callback| is |
- // called with an error message. |new_connection_callback| is invoked when |
- // an incoming connection is accepted by the underlying socket. |
- void StartService( |
- const BluetoothUUID& uuid, |
- const std::string& name, |
- int rfcomm_channel, |
- const base::Closure& success_callback, |
- const ErrorCompletionCallback& error_callback, |
- const OnNewConnectionCallback& new_connection_callback); |
- |
+ // Connect to the peer device and calls |success_callback| when the |
// connection has been established successfully. If an error occurs, calls |
// |error_callback| with a system error message. |
- void Connect(const BluetoothServiceRecord& service_record, |
+ void Connect(const BluetoothDeviceWin* device, |
+ const BluetoothUUID& uuid, |
const base::Closure& success_callback, |
const ErrorCompletionCallback& error_callback); |
+ // Listens using this socket using an RFCOMM service published as UUID |uuid| |
+ // with Channel |channel|. |success_callback| will be called if the service |
+ // is successfully registered, |error_callback| on failure with a message |
+ // explaining the cause. |
+ void Listen(scoped_refptr<BluetoothAdapter> adapter, |
+ const BluetoothUUID& uuid, |
+ int rfcomm_channel, |
+ const base::Closure& success_callback, |
+ const ErrorCompletionCallback& error_callback); |
+ |
// BluetoothSocketNet: |
void ResetData(); |
@@ -59,7 +57,6 @@ class BluetoothSocketWin : public BluetoothSocketNet { |
virtual void Accept(const AcceptCompletionCallback& success_callback, |
const ErrorCompletionCallback& error_callback) OVERRIDE; |
- |
protected: |
virtual ~BluetoothSocketWin(); |
@@ -74,26 +71,30 @@ class BluetoothSocketWin : public BluetoothSocketNet { |
void DoConnect(const base::Closure& success_callback, |
const ErrorCompletionCallback& error_callback); |
- void DoStartService(const BluetoothUUID& uuid, |
- const std::string& name, |
+ void DoListen(const BluetoothUUID& uuid, |
int rfcomm_channel, |
const base::Closure& success_callback, |
- const ErrorCompletionCallback& error_callback, |
- const OnNewConnectionCallback& new_connection_callback); |
- void DoAccept(); |
- void OnAcceptOnSocketThread(int accept_result); |
+ const ErrorCompletionCallback& error_callback); |
+ void DoAccept(const AcceptCompletionCallback& success_callback, |
+ const ErrorCompletionCallback& error_callback); |
+ void OnAcceptOnSocketThread(const AcceptCompletionCallback& success_callback, |
+ const ErrorCompletionCallback& error_callback, |
+ int accept_result); |
void OnAcceptOnUI(scoped_ptr<net::TCPSocket> accept_socket, |
- const net::IPEndPoint& peer_address); |
+ const net::IPEndPoint& peer_address, |
+ const AcceptCompletionCallback& success_callback, |
+ const ErrorCompletionCallback& error_callback); |
std::string device_address_; |
bool supports_rfcomm_; |
uint8 rfcomm_channel_; |
BTH_ADDR bth_addr_; |
+ // Data members below are only used when listening. |
+ scoped_refptr<device::BluetoothAdapter> adapter_; |
scoped_ptr<ServiceRegData> service_reg_data_; |
scoped_ptr<net::TCPSocket> accept_socket_; |
net::IPEndPoint accept_address_; |
- OnNewConnectionCallback on_new_connection_callback_; |
DISALLOW_COPY_AND_ASSIGN(BluetoothSocketWin); |
}; |