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

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: Many cleanup, such device ID, woww. Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "device/hid/hid_device_info.h" 11 #include "device/hid/hid_device_info.h"
12 12 #include "net/base/io_buffer.h"
13 namespace net {
14 class IOBuffer;
15 }
16 13
17 namespace device { 14 namespace device {
18 15
19 class HidConnection : public base::RefCountedThreadSafe<HidConnection> { 16 class HidConnection : public base::RefCountedThreadSafe<HidConnection> {
20 public: 17 public:
21 typedef base::Callback<void(bool success, size_t size)> IOCallback; 18 typedef base::Callback<void(bool success, size_t size)> IOCallback;
22 19
23 virtual void Read(scoped_refptr<net::IOBuffer> buffer, 20 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
24 size_t size,
25 const IOCallback& callback) = 0; 21 const IOCallback& callback) = 0;
26 virtual void Write(scoped_refptr<net::IOBuffer> buffer, 22 virtual void Write(scoped_refptr<net::IOBufferWithSize> buffer,
27 size_t size,
28 const IOCallback& callback) = 0; 23 const IOCallback& callback) = 0;
29 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, 24 virtual void GetFeatureReport(scoped_refptr<net::IOBufferWithSize> buffer,
30 size_t size,
31 const IOCallback& callback) = 0; 25 const IOCallback& callback) = 0;
32 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 26 virtual void SendFeatureReport(scoped_refptr<net::IOBufferWithSize> buffer,
33 size_t size,
34 const IOCallback& callback) = 0; 27 const IOCallback& callback) = 0;
35 28
36 const HidDeviceInfo& device_info() const; 29 const HidDeviceInfo& device_info() const;
37 30
38 protected: 31 protected:
39 friend class base::RefCountedThreadSafe<HidConnection>; 32 friend class base::RefCountedThreadSafe<HidConnection>;
40 friend struct HidDeviceInfo; 33 friend struct HidDeviceInfo;
41 34
42 HidConnection(HidDeviceInfo device_info); 35 explicit HidConnection(const HidDeviceInfo& device_info);
43 virtual ~HidConnection(); 36 virtual ~HidConnection();
44 37
45 const HidDeviceInfo device_info_;
46
47 base::ThreadChecker thread_checker_; 38 base::ThreadChecker thread_checker_;
Mark Mentovai 2014/02/21 17:48:18 It feels a little bit dirty that this is protected
Ken Rockot(use gerrit already) 2014/02/22 01:17:04 Done. One per subclass now.
48 39
40 private:
41 const HidDeviceInfo device_info_;
42
49 DISALLOW_COPY_AND_ASSIGN(HidConnection); 43 DISALLOW_COPY_AND_ASSIGN(HidConnection);
50 }; 44 };
51 45
46 struct PendingHidReport {
47 PendingHidReport();
48 ~PendingHidReport();
49
50 scoped_refptr<net::IOBufferWithSize> buffer;
51 };
52
53 struct PendingHidRead {
54 PendingHidRead();
55 ~PendingHidRead();
56
57 scoped_refptr<net::IOBufferWithSize> buffer;
58 HidConnection::IOCallback callback;
59 };
60
52 } // namespace device 61 } // namespace device
53 62
54 #endif // DEVICE_HID_HID_CONNECTION_H_ 63 #endif // DEVICE_HID_HID_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698