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