Index: device/bluetooth/bluetooth_profile_win.h |
diff --git a/device/bluetooth/bluetooth_profile_win.h b/device/bluetooth/bluetooth_profile_win.h |
index e235bd2ea6f0ed7b93b28cd906a572d18e66ec07..5ae66dad4f012b1b31208706b293437220f9e89c 100644 |
--- a/device/bluetooth/bluetooth_profile_win.h |
+++ b/device/bluetooth/bluetooth_profile_win.h |
@@ -7,23 +7,39 @@ |
#include <string> |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
#include "device/bluetooth/bluetooth_profile.h" |
#include "device/bluetooth/bluetooth_uuid.h" |
#include "net/base/net_log.h" |
+#include "net/socket/tcp_socket.h" |
+ |
+namespace net { |
+class IPEndPoint; |
+} |
namespace device { |
+class BluetoothAdapter; |
+class BluetoothAdapterWin; |
class BluetoothDeviceWin; |
class BluetoothSocketThreadWin; |
+class BluetoothSocketWin; |
class BluetoothProfileWin : public BluetoothProfile { |
public: |
+ typedef base::Callback<void(const std::string&)> ErrorCallback; |
+ |
// BluetoothProfile override. |
virtual void Unregister() OVERRIDE; |
virtual void SetConnectionCallback( |
const ConnectionCallback& callback) OVERRIDE; |
- typedef base::Callback<void(const std::string&)> ErrorCallback; |
+ // Called by BluetoothProfile::Register to initialize the profile object |
+ // asynchronously. |
+ void Init(const BluetoothUUID& uuid, |
+ const device::BluetoothProfile::Options& options, |
+ const ProfileCallback& callback); |
void Connect(const BluetoothDeviceWin* device, |
scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
@@ -36,13 +52,33 @@ class BluetoothProfileWin : public BluetoothProfile { |
private: |
friend BluetoothProfile; |
- BluetoothProfileWin(const BluetoothUUID& uuid, const std::string& name); |
+ BluetoothProfileWin(); |
virtual ~BluetoothProfileWin(); |
- const BluetoothUUID uuid_; |
- const std::string name_; |
+ // Internal method run to get the adapter object during initialization. |
+ void OnGetAdapter(const ProfileCallback& callback, |
+ scoped_refptr<BluetoothAdapter> adapter); |
+ |
+ // Callbacks for |profile_socket_|'s StartService call. |
+ void OnRegisterProfileSuccess(const ProfileCallback& callback); |
+ void OnRegisterProfileError(const ProfileCallback& callback, |
+ const std::string& error_message); |
+ |
+ // Callback when |profile_socket_| accepts a connection. |
+ void OnNewConnection(scoped_refptr<BluetoothSocketWin> connected, |
+ const net::IPEndPoint& peer_address); |
+ |
+ BluetoothAdapterWin* adapter() const; |
+ |
+ BluetoothUUID uuid_; |
+ std::string name_; |
+ int rfcomm_channel_; |
ConnectionCallback connection_callback_; |
+ scoped_refptr<BluetoothAdapter> adapter_; |
+ scoped_refptr<BluetoothSocketWin> profile_socket_; |
+ base::WeakPtrFactory<BluetoothProfileWin> weak_ptr_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(BluetoothProfileWin); |
}; |