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"
25 // The BluetoothSocketChromeOS class implements BluetoothSocket for the
26 // Chrome OS platform.
27 class CHROMEOS_EXPORT BluetoothSocketChromeOS
28 : public device::BluetoothSocket
{
30 // Overriden from BluetoothSocket:
31 virtual void Close() OVERRIDE
;
32 virtual void Disconnect(const base::Closure
& callback
) OVERRIDE
;
33 virtual void Receive(int count
,
34 const ReceiveCompletionCallback
& success_callback
,
35 const ReceiveErrorCompletionCallback
& error_callback
)
37 virtual void Send(scoped_refptr
<net::IOBuffer
> buffer
,
39 const SendCompletionCallback
& success_callback
,
40 const ErrorCompletionCallback
& error_callback
) OVERRIDE
;
42 // Create an instance of a BluetoothSocket from the passed file descriptor
43 // received over D-Bus in |fd|, the descriptor will be taken from that object
44 // and ownership passed to the returned object.
45 static scoped_refptr
<device::BluetoothSocket
> Create(
46 dbus::FileDescriptor
* fd
);
49 virtual ~BluetoothSocketChromeOS();
52 BluetoothSocketChromeOS(int fd
);
54 // The different socket types have different reading patterns; l2cap sockets
55 // have to be read with boundaries between datagrams preserved while rfcomm
62 // File descriptor and socket type of the socket.
64 SocketType socket_type_
;
66 // Last error message, set during Receive() and Send() and retrieved using
67 // GetLastErrorMessage().
68 std::string error_message_
;
70 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketChromeOS
);
73 } // namespace chromeos
75 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_