1 // Copyright 2014 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_HID_HID_CONNECTION_H_
6 #define DEVICE_HID_HID_CONNECTION_H_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "device/hid/hid_device_info.h"
13 #include "net/base/io_buffer.h"
17 class HidConnection
: public base::RefCountedThreadSafe
<HidConnection
> {
19 typedef base::Callback
<void(bool success
, size_t size
)> IOCallback
;
21 virtual void Read(scoped_refptr
<net::IOBufferWithSize
> buffer
,
22 const IOCallback
& callback
) = 0;
23 virtual void Write(uint8_t report_id
,
24 scoped_refptr
<net::IOBufferWithSize
> buffer
,
25 const IOCallback
& callback
) = 0;
26 virtual void GetFeatureReport(uint8_t report_id
,
27 scoped_refptr
<net::IOBufferWithSize
> buffer
,
28 const IOCallback
& callback
) = 0;
29 virtual void SendFeatureReport(uint8_t report_id
,
30 scoped_refptr
<net::IOBufferWithSize
> buffer
,
31 const IOCallback
& callback
) = 0;
33 const HidDeviceInfo
& device_info() const { return device_info_
; }
36 friend class base::RefCountedThreadSafe
<HidConnection
>;
37 friend struct HidDeviceInfo
;
39 explicit HidConnection(const HidDeviceInfo
& device_info
);
40 virtual ~HidConnection();
43 const HidDeviceInfo device_info_
;
45 DISALLOW_COPY_AND_ASSIGN(HidConnection
);
48 struct PendingHidReport
{
52 scoped_refptr
<net::IOBufferWithSize
> buffer
;
55 struct PendingHidRead
{
59 scoped_refptr
<net::IOBufferWithSize
> buffer
;
60 HidConnection::IOCallback callback
;
65 #endif // DEVICE_HID_HID_CONNECTION_H_