| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 @class BluetoothRfcommConnectionListener; | 22 @class BluetoothRfcommConnectionListener; |
| 23 @class BluetoothL2capConnectionListener; | 23 @class BluetoothL2capConnectionListener; |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 class IOBuffer; | 26 class IOBuffer; |
| 27 class IOBufferWithSize; | 27 class IOBufferWithSize; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace device { | 30 namespace device { |
| 31 | 31 |
| 32 class BluetoothAdapter; | 32 class BluetoothAdapterMac; |
| 33 class BluetoothChannelMac; | 33 class BluetoothChannelMac; |
| 34 | 34 |
| 35 // Implements the BluetoothSocket class for the Mac OS X platform. | 35 // Implements the BluetoothSocket class for the Mac OS X platform. |
| 36 class BluetoothSocketMac : public BluetoothSocket { | 36 class BluetoothSocketMac : public BluetoothSocket { |
| 37 public: | 37 public: |
| 38 static scoped_refptr<BluetoothSocketMac> CreateSocket(); | 38 static scoped_refptr<BluetoothSocketMac> CreateSocket(); |
| 39 | 39 |
| 40 // Connects this socket to the service on |device| published as UUID |uuid|. | 40 // Connects this socket to the service on |device| published as UUID |uuid|. |
| 41 // The underlying protocol and PSM or Channel is obtained through service | 41 // The underlying protocol and PSM or Channel is obtained through service |
| 42 // discovery. On a successful connection, the socket properties will be | 42 // discovery. On a successful connection, the socket properties will be |
| 43 // updated and |success_callback| called. On failure, |error_callback| will be | 43 // updated and |success_callback| called. On failure, |error_callback| will be |
| 44 // called with a message explaining the cause of failure. | 44 // called with a message explaining the cause of failure. |
| 45 void Connect(IOBluetoothDevice* device, | 45 void Connect(IOBluetoothDevice* device, |
| 46 const BluetoothUUID& uuid, | 46 const BluetoothUUID& uuid, |
| 47 const base::Closure& success_callback, | 47 const base::Closure& success_callback, |
| 48 const ErrorCompletionCallback& error_callback); | 48 const ErrorCompletionCallback& error_callback); |
| 49 | 49 |
| 50 // Listens for incoming RFCOMM connections using this socket: Publishes an | 50 // Listens for incoming RFCOMM connections using this socket: Publishes an |
| 51 // RFCOMM service on the |adapter| as UUID |uuid| with Channel |channel_id|. | 51 // RFCOMM service on the |adapter| as UUID |uuid| with Channel |channel_id|. |
| 52 // |success_callback| will be called if the service is successfully | 52 // |success_callback| will be called if the service is successfully |
| 53 // registered, |error_callback| on failure with a message explaining the | 53 // registered, |error_callback| on failure with a message explaining the |
| 54 // cause. | 54 // cause. |
| 55 void ListenUsingRfcomm(scoped_refptr<BluetoothAdapter> adapter, | 55 void ListenUsingRfcomm(scoped_refptr<BluetoothAdapterMac> adapter, |
| 56 const BluetoothUUID& uuid, | 56 const BluetoothUUID& uuid, |
| 57 int channel_id, | 57 int channel_id, |
| 58 const base::Closure& success_callback, | 58 const base::Closure& success_callback, |
| 59 const ErrorCompletionCallback& error_callback); | 59 const ErrorCompletionCallback& error_callback); |
| 60 | 60 |
| 61 // Listens for incoming L2CAP connections using this socket: Publishes an | 61 // Listens for incoming L2CAP connections using this socket: Publishes an |
| 62 // L2CAP service on the |adapter| as UUID |uuid| with PSM |psm|. | 62 // L2CAP service on the |adapter| as UUID |uuid| with PSM |psm|. |
| 63 // |success_callback| will be called if the service is successfully | 63 // |success_callback| will be called if the service is successfully |
| 64 // registered, |error_callback| on failure with a message explaining the | 64 // registered, |error_callback| on failure with a message explaining the |
| 65 // cause. | 65 // cause. |
| 66 void ListenUsingL2cap(scoped_refptr<BluetoothAdapter> adapter, | 66 void ListenUsingL2cap(scoped_refptr<BluetoothAdapterMac> adapter, |
| 67 const BluetoothUUID& uuid, | 67 const BluetoothUUID& uuid, |
| 68 int psm, | 68 int psm, |
| 69 const base::Closure& success_callback, | 69 const base::Closure& success_callback, |
| 70 const ErrorCompletionCallback& error_callback); | 70 const ErrorCompletionCallback& error_callback); |
| 71 | 71 |
| 72 // BluetoothSocket: | 72 // BluetoothSocket: |
| 73 virtual void Close() OVERRIDE; | 73 virtual void Close() OVERRIDE; |
| 74 virtual void Disconnect(const base::Closure& callback) OVERRIDE; | 74 virtual void Disconnect(const base::Closure& callback) OVERRIDE; |
| 75 virtual void Receive( | 75 virtual void Receive( |
| 76 int /* buffer_size */, | 76 int /* buffer_size */, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void ReleaseChannel(); | 148 void ReleaseChannel(); |
| 149 void ReleaseListener(); | 149 void ReleaseListener(); |
| 150 | 150 |
| 151 bool is_connecting() const { return connect_callbacks_; } | 151 bool is_connecting() const { return connect_callbacks_; } |
| 152 | 152 |
| 153 // Used to verify that all methods are called on the same thread. | 153 // Used to verify that all methods are called on the same thread. |
| 154 base::ThreadChecker thread_checker_; | 154 base::ThreadChecker thread_checker_; |
| 155 | 155 |
| 156 // Adapter the socket is registered against. This is only present when the | 156 // Adapter the socket is registered against. This is only present when the |
| 157 // socket is listening. | 157 // socket is listening. |
| 158 scoped_refptr<BluetoothAdapter> adapter_; | 158 scoped_refptr<BluetoothAdapterMac> adapter_; |
| 159 | 159 |
| 160 // UUID of the profile being connected to, or that the socket is listening on. | 160 // UUID of the profile being connected to, or that the socket is listening on. |
| 161 device::BluetoothUUID uuid_; | 161 device::BluetoothUUID uuid_; |
| 162 | 162 |
| 163 // Simple helpers that register for OS notifications and forward them to | 163 // Simple helpers that register for OS notifications and forward them to |
| 164 // |this| profile. | 164 // |this| profile. |
| 165 base::scoped_nsobject<BluetoothRfcommConnectionListener> | 165 base::scoped_nsobject<BluetoothRfcommConnectionListener> |
| 166 rfcomm_connection_listener_; | 166 rfcomm_connection_listener_; |
| 167 base::scoped_nsobject<BluetoothL2capConnectionListener> | 167 base::scoped_nsobject<BluetoothL2capConnectionListener> |
| 168 l2cap_connection_listener_; | 168 l2cap_connection_listener_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 192 | 192 |
| 193 // Queue of incoming connections. | 193 // Queue of incoming connections. |
| 194 std::queue<linked_ptr<BluetoothChannelMac>> accept_queue_; | 194 std::queue<linked_ptr<BluetoothChannelMac>> accept_queue_; |
| 195 | 195 |
| 196 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac); | 196 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 } // namespace device | 199 } // namespace device |
| 200 | 200 |
| 201 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ | 201 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ |
| OLD | NEW |