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_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "chromeos/chromeos_export.h"
13 #include "device/bluetooth/bluetooth_socket.h"
23 class DrainableIOBuffer
;
24 class GrowableIOBuffer
;
30 // The BluetoothSocketChromeOS class implements BluetoothSocket for the
31 // Chrome OS platform.
32 class CHROMEOS_EXPORT BluetoothSocketChromeOS
33 : public device::BluetoothSocket
{
35 // BluetoothSocket override.
36 virtual bool Receive(net::GrowableIOBuffer
* buffer
) OVERRIDE
;
37 virtual bool Send(net::DrainableIOBuffer
* buffer
) OVERRIDE
;
38 virtual std::string
GetLastErrorMessage() const OVERRIDE
;
40 // Create an instance of a BluetoothSocket from the passed file descriptor
41 // received over D-Bus in |fd|, the descriptor will be taken from that object
42 // and ownership passed to the returned object.
43 static scoped_refptr
<device::BluetoothSocket
> Create(
44 dbus::FileDescriptor
* fd
);
47 virtual ~BluetoothSocketChromeOS();
50 BluetoothSocketChromeOS(int fd
);
52 // The different socket types have different reading patterns; l2cap sockets
53 // have to be read with boundaries between datagrams preserved while rfcomm
60 // File descriptor and socket type of the socket.
62 SocketType socket_type_
;
64 // Last error message, set during Receive() and Send() and retrieved using
65 // GetLastErrorMessage().
66 std::string error_message_
;
68 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketChromeOS
);
71 } // namespace chromeos
73 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_