Add JSON check in tools/perf presubmit script.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_socket_chromeos.h
blob1c52c679f0e76b2a343e5e2477cfa0eff56cde18
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_
8 #include <string>
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"
15 namespace dbus {
17 class FileDescriptor;
19 } // namespace dbus
21 namespace net {
23 class DrainableIOBuffer;
24 class GrowableIOBuffer;
26 } // namespace net
28 namespace chromeos {
30 // The BluetoothSocketChromeOS class implements BluetoothSocket for the
31 // Chrome OS platform.
32 class CHROMEOS_EXPORT BluetoothSocketChromeOS
33 : public device::BluetoothSocket {
34 public:
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);
46 protected:
47 virtual ~BluetoothSocketChromeOS();
49 private:
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
54 // sockets do not.
55 enum SocketType {
56 L2CAP,
57 RFCOMM
60 // File descriptor and socket type of the socket.
61 const int fd_;
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_