Add git cl format presubmit warning for extension and apps.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_socket.h
blob6ae349e9ac92c2f1480f4360b6546287e73cef41
1 // Copyright (c) 2012 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_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
12 namespace net {
14 class DrainableIOBuffer;
15 class GrowableIOBuffer;
17 } // namespace net
19 namespace device {
21 // BluetoothSocket represents a socket to a specific service on a
22 // BluetoothDevice. BluetoothSocket objects are ref counted and may outlive
23 // both the BluetoothDevice and BluetoothAdapter that were involved in their
24 // creation.
25 class BluetoothSocket : public base::RefCounted<BluetoothSocket> {
26 public:
27 // Receives data from the socket and stores it in |buffer|. It returns whether
28 // the reception has been successful. If it fails, the caller can get the
29 // error message through |GetLastErrorMessage()|.
30 virtual bool Receive(net::GrowableIOBuffer* buffer) = 0;
32 // Sends |buffer| to the socket. It returns whether the sending has been
33 // successful. If it fails, the caller can get the error message through
34 // |GetLastErrorMessage()|.
35 virtual bool Send(net::DrainableIOBuffer* buffer) = 0;
37 virtual std::string GetLastErrorMessage() const = 0;
39 protected:
40 friend class base::RefCounted<BluetoothSocket>;
41 virtual ~BluetoothSocket() {}
44 } // namespace device
46 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_