Add DriveAppRegistryObserver.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_socket_chromeos.h
blob5cfefbad41bc86ad13a2289379183fa6c1666a4d
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 {
16 class FileDescriptor;
17 } // namespace dbus
19 namespace net {
20 class IOBuffer;
21 } // namespace net
23 namespace chromeos {
25 // The BluetoothSocketChromeOS class implements BluetoothSocket for the
26 // Chrome OS platform.
27 class CHROMEOS_EXPORT BluetoothSocketChromeOS
28 : public device::BluetoothSocket {
29 public:
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)
36 OVERRIDE;
37 virtual void Send(scoped_refptr<net::IOBuffer> buffer,
38 int buffer_size,
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);
48 protected:
49 virtual ~BluetoothSocketChromeOS();
51 private:
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
56 // sockets do not.
57 enum SocketType {
58 L2CAP,
59 RFCOMM
62 // File descriptor and socket type of the socket.
63 const int fd_;
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_