Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: device/hid/hid_connection.h

Issue 161823002: Clean up HID backend and API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/api/hid.idl ('k') | device/hid/hid_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_HID_HID_CONNECTION_H_ 5 #ifndef DEVICE_HID_HID_CONNECTION_H_
6 #define DEVICE_HID_HID_CONNECTION_H_ 6 #define DEVICE_HID_HID_CONNECTION_H_
7 7
8 #include <stdint.h>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread_checker.h"
11 #include "device/hid/hid_device_info.h" 12 #include "device/hid/hid_device_info.h"
12 13 #include "net/base/io_buffer.h"
13 namespace net {
14 class IOBuffer;
15 }
16 14
17 namespace device { 15 namespace device {
18 16
19 class HidConnection : public base::RefCountedThreadSafe<HidConnection> { 17 class HidConnection : public base::RefCountedThreadSafe<HidConnection> {
20 public: 18 public:
21 typedef base::Callback<void(bool success, size_t size)> IOCallback; 19 typedef base::Callback<void(bool success, size_t size)> IOCallback;
22 20
23 virtual void Read(scoped_refptr<net::IOBuffer> buffer, 21 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
24 size_t size,
25 const IOCallback& callback) = 0; 22 const IOCallback& callback) = 0;
26 virtual void Write(scoped_refptr<net::IOBuffer> buffer, 23 virtual void Write(uint8_t report_id,
27 size_t size, 24 scoped_refptr<net::IOBufferWithSize> buffer,
28 const IOCallback& callback) = 0; 25 const IOCallback& callback) = 0;
29 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, 26 virtual void GetFeatureReport(uint8_t report_id,
30 size_t size, 27 scoped_refptr<net::IOBufferWithSize> buffer,
31 const IOCallback& callback) = 0; 28 const IOCallback& callback) = 0;
32 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 29 virtual void SendFeatureReport(uint8_t report_id,
33 size_t size, 30 scoped_refptr<net::IOBufferWithSize> buffer,
34 const IOCallback& callback) = 0; 31 const IOCallback& callback) = 0;
35 32
36 const HidDeviceInfo& device_info() const; 33 const HidDeviceInfo& device_info() const { return device_info_; }
37 34
38 protected: 35 protected:
39 friend class base::RefCountedThreadSafe<HidConnection>; 36 friend class base::RefCountedThreadSafe<HidConnection>;
40 friend struct HidDeviceInfo; 37 friend struct HidDeviceInfo;
41 38
42 HidConnection(HidDeviceInfo device_info); 39 explicit HidConnection(const HidDeviceInfo& device_info);
43 virtual ~HidConnection(); 40 virtual ~HidConnection();
44 41
42 private:
45 const HidDeviceInfo device_info_; 43 const HidDeviceInfo device_info_;
46 44
47 base::ThreadChecker thread_checker_; 45 DISALLOW_COPY_AND_ASSIGN(HidConnection);
46 };
48 47
49 DISALLOW_COPY_AND_ASSIGN(HidConnection); 48 struct PendingHidReport {
49 PendingHidReport();
50 ~PendingHidReport();
51
52 scoped_refptr<net::IOBufferWithSize> buffer;
53 };
54
55 struct PendingHidRead {
56 PendingHidRead();
57 ~PendingHidRead();
58
59 scoped_refptr<net::IOBufferWithSize> buffer;
60 HidConnection::IOCallback callback;
50 }; 61 };
51 62
52 } // namespace device 63 } // namespace device
53 64
54 #endif // DEVICE_HID_HID_CONNECTION_H_ 65 #endif // DEVICE_HID_HID_CONNECTION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/hid.idl ('k') | device/hid/hid_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698