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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "device/bluetooth/bluetooth_socket.h" | 11 #include "device/bluetooth/bluetooth_socket.h" |
12 | 12 |
13 #ifdef __OBJC__ | 13 #ifdef __OBJC__ |
14 @class BluetoothRFCOMMChannelDelegate; | 14 @class BluetoothRFCOMMChannelDelegate; |
15 @class IOBluetoothRFCOMMChannel; | 15 @class IOBluetoothRFCOMMChannel; |
16 @class IOBluetoothSDPServiceRecord; | 16 @class IOBluetoothSDPServiceRecord; |
17 #else | 17 #else |
18 class BluetoothRFCOMMChannelDelegate; | 18 class BluetoothRFCOMMChannelDelegate; |
19 class IOBluetoothRFCOMMChannel; | 19 class IOBluetoothRFCOMMChannel; |
20 class IOBluetoothSDPServiceRecord; | 20 class IOBluetoothSDPServiceRecord; |
21 #endif | 21 #endif |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | |
25 class DrainableIOBuffer; | |
26 class GrowableIOBuffer; | 24 class GrowableIOBuffer; |
27 | 25 class IOBuffer; |
28 } // namespace net | 26 } // namespace net |
29 | 27 |
30 namespace device { | 28 namespace device { |
31 | 29 |
32 class BluetoothServiceRecord; | 30 class BluetoothServiceRecord; |
33 | 31 |
34 // This class is an implementation of BluetoothSocket class for OSX platform. | 32 // This class is an implementation of BluetoothSocket class for OSX platform. |
35 class BluetoothSocketMac : public BluetoothSocket { | 33 class BluetoothSocketMac : public BluetoothSocket { |
36 public: | 34 public: |
37 // TODO(youngki): This method is deprecated; remove this method when | 35 // TODO(youngki): This method is deprecated; remove this method when |
38 // BluetoothServiceRecord is removed. | 36 // BluetoothServiceRecord is removed. |
39 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( | 37 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( |
40 const BluetoothServiceRecord& service_record); | 38 const BluetoothServiceRecord& service_record); |
41 | 39 |
42 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( | 40 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( |
43 IOBluetoothSDPServiceRecord* record); | 41 IOBluetoothSDPServiceRecord* record); |
44 | 42 |
45 // BluetoothSocket override | 43 // Overriden from BluetoothSocket: |
46 virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE; | 44 virtual void Close() OVERRIDE; |
47 virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE; | 45 virtual void Disconnect(const base::Closure& callback) OVERRIDE; |
48 virtual std::string GetLastErrorMessage() const OVERRIDE; | 46 virtual void Receive(int count, |
| 47 const ReceiveCompletionCallback& success_callback, |
| 48 const ReceiveErrorCompletionCallback& error_callback) |
| 49 OVERRIDE; |
| 50 virtual void Send(scoped_refptr<net::IOBuffer> buffer, |
| 51 int buffer_size, |
| 52 const SendCompletionCallback& success_callback, |
| 53 const ErrorCompletionCallback& error_callback) OVERRIDE; |
49 | 54 |
50 // called by BluetoothRFCOMMChannelDelegate. | 55 // called by BluetoothRFCOMMChannelDelegate. |
51 void OnDataReceived(IOBluetoothRFCOMMChannel* rfcomm_channel, | 56 void OnDataReceived(IOBluetoothRFCOMMChannel* rfcomm_channel, |
52 void* data, | 57 void* data, |
53 size_t length); | 58 size_t length); |
54 | 59 |
55 protected: | 60 protected: |
56 virtual ~BluetoothSocketMac(); | 61 virtual ~BluetoothSocketMac(); |
57 | 62 |
58 private: | 63 private: |
59 explicit BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel); | 64 explicit BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel); |
60 | 65 |
61 void ResetIncomingDataBuffer(); | 66 void ResetIncomingDataBuffer(); |
62 | 67 |
63 IOBluetoothRFCOMMChannel* rfcomm_channel_; | 68 IOBluetoothRFCOMMChannel* rfcomm_channel_; |
64 BluetoothRFCOMMChannelDelegate* delegate_; | 69 BluetoothRFCOMMChannelDelegate* delegate_; |
65 scoped_refptr<net::GrowableIOBuffer> incoming_data_buffer_; | 70 scoped_refptr<net::GrowableIOBuffer> incoming_data_buffer_; |
66 std::string error_message_; | 71 std::string error_message_; |
67 | 72 |
68 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac); | 73 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac); |
69 }; | 74 }; |
70 | 75 |
71 } // namespace device | 76 } // namespace device |
72 | 77 |
73 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ | 78 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ |
OLD | NEW |