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_
10 #include "base/memory/ref_counted.h"
14 class DrainableIOBuffer
;
15 class GrowableIOBuffer
;
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
25 class BluetoothSocket
: public base::RefCounted
<BluetoothSocket
> {
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;
40 friend class base::RefCounted
<BluetoothSocket
>;
41 virtual ~BluetoothSocket() {}
46 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_