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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_
10 #include "base/memory/ref_counted.h"
11 #include "device/bluetooth/bluetooth_socket.h"
14 @class BluetoothRFCOMMChannelDelegate;
15 @class IOBluetoothRFCOMMChannel;
16 @class IOBluetoothSDPServiceRecord;
18 class BluetoothRFCOMMChannelDelegate;
19 class IOBluetoothRFCOMMChannel;
20 class IOBluetoothSDPServiceRecord;
25 class DrainableIOBuffer;
26 class GrowableIOBuffer;
32 class BluetoothServiceRecord;
34 // This class is an implementation of BluetoothSocket class for OSX platform.
35 class BluetoothSocketMac : public BluetoothSocket {
37 // TODO(youngki): This method is deprecated; remove this method when
38 // BluetoothServiceRecord is removed.
39 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
40 const BluetoothServiceRecord& service_record);
42 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
43 IOBluetoothSDPServiceRecord* record);
45 // BluetoothSocket override
46 virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE;
47 virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE;
48 virtual std::string GetLastErrorMessage() const OVERRIDE;
50 // called by BluetoothRFCOMMChannelDelegate.
51 void OnDataReceived(IOBluetoothRFCOMMChannel* rfcomm_channel,
56 virtual ~BluetoothSocketMac();
59 explicit BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel);
61 void ResetIncomingDataBuffer();
63 IOBluetoothRFCOMMChannel* rfcomm_channel_;
64 BluetoothRFCOMMChannelDelegate* delegate_;
65 scoped_refptr<net::GrowableIOBuffer> incoming_data_buffer_;
66 std::string error_message_;
68 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac);
73 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_