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