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

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

Issue 143883005: HID backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base
Patch Set: Created 6 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_
6 #define DEVICE_HID_HID_CONNECTION_WIN_H_
7
8 #include <windows.h>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/win/object_watcher.h"
13 #include "device/hid/hid_connection.h"
14 #include "device/hid/hid_device_info.h"
15
16 namespace device {
17
18 class AsyncTransfer : public base::RefCountedThreadSafe<AsyncTransfer>,
19 public base::win::ObjectWatcher::Delegate {
20 public:
Ken Rockot(use gerrit already) 2014/01/21 23:03:39 base::MessageLoopForIO::IOHandler essentially prov
Bei Zhang 2014/01/24 12:48:47 As I tested, it only works on IO thread, were IO i
21 AsyncTransfer(HANDLE file,
22 scoped_refptr<net::IOBuffer> buffer,
23 const HidIOCallback& callback,
24 bool is_read);
25
26 OVERLAPPED* GetOverlappedPtr();
27 DWORD* GetActualSizePtr();
28
29 void StartWatching(BOOL result_from_winapi);
30
31 private:
32 friend class base::RefCountedThreadSafe<AsyncTransfer>;
33
34 virtual ~AsyncTransfer();
35
36 // base::win::ObjectWatcher::Delegate:
37 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
38
39 HANDLE file_;
40 OVERLAPPED overlapped_;
41 scoped_refptr<net::IOBuffer> buffer_;
42 base::win::ScopedHandle event_;
43 HidIOCallback callback_;
44 base::win::ObjectWatcher watcher_;
45 DWORD actual_size_;
46
47 // For input transfer, if the first byte is zero, we need to remove it.
48 bool is_read_;
49
50 DISALLOW_COPY_AND_ASSIGN(AsyncTransfer);
51 };
52
53 class HidConnectionWin : public HidConnection {
54 public:
55 HidConnectionWin(HidDeviceInfo device_info);
56
57 virtual void Read(const HidIOCallback& callback) OVERRIDE;
58 virtual void Write(scoped_refptr<net::IOBuffer> buffer,
59 size_t size,
60 const HidIOCallback& callback) OVERRIDE;
61 virtual void GetFeatureReport(const HidIOCallback& callback) OVERRIDE;
62 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
63 size_t size,
64 const HidIOCallback& callback) OVERRIDE;
65
66 bool available() const { return available_; }
67
68 private:
69 ~HidConnectionWin();
70
71 base::win::ScopedHandle file_;
72
73 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin);
74
75 bool available_;
76 };
77
78 } // namespace device
79
80 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698