Revert 269361 "Fix WebURLLoaderImpl::Context leak if a pending r..."
[chromium-blink-merge.git] / device / hid / hid_connection.h
blob5c08fbc5bbdf5733e1e3a3c63149bed7044d768b
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_
8 #include <stdint.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"
15 namespace device {
17 class HidConnection : public base::RefCountedThreadSafe<HidConnection> {
18 public:
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_; }
35 protected:
36 friend class base::RefCountedThreadSafe<HidConnection>;
37 friend struct HidDeviceInfo;
39 explicit HidConnection(const HidDeviceInfo& device_info);
40 virtual ~HidConnection();
42 private:
43 const HidDeviceInfo device_info_;
45 DISALLOW_COPY_AND_ASSIGN(HidConnection);
48 struct PendingHidReport {
49 PendingHidReport();
50 ~PendingHidReport();
52 scoped_refptr<net::IOBufferWithSize> buffer;
55 struct PendingHidRead {
56 PendingHidRead();
57 ~PendingHidRead();
59 scoped_refptr<net::IOBufferWithSize> buffer;
60 HidConnection::IOCallback callback;
63 } // namespace device
65 #endif // DEVICE_HID_HID_CONNECTION_H_