OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "media/base/user_input_monitor.h" | 5 #include "media/base/user_input_monitor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 LRESULT* result); | 58 LRESULT* result); |
59 RAWINPUTDEVICE* GetRawInputDevices(EventBitMask event, DWORD flags); | 59 RAWINPUTDEVICE* GetRawInputDevices(EventBitMask event, DWORD flags); |
60 | 60 |
61 // Task runner on which |window_| is created. | 61 // Task runner on which |window_| is created. |
62 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 62 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
63 scoped_refptr<base::ObserverListThreadSafe< | 63 scoped_refptr<base::ObserverListThreadSafe< |
64 UserInputMonitor::MouseEventListener>> mouse_listeners_; | 64 UserInputMonitor::MouseEventListener>> mouse_listeners_; |
65 | 65 |
66 // These members are only accessed on the UI thread. | 66 // These members are only accessed on the UI thread. |
67 scoped_ptr<base::win::MessageWindow> window_; | 67 scoped_ptr<base::win::MessageWindow> window_; |
68 uint8 events_monitored_; | 68 uint8_t events_monitored_; |
69 KeyboardEventCounter counter_; | 69 KeyboardEventCounter counter_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorWinCore); | 71 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorWinCore); |
72 }; | 72 }; |
73 | 73 |
74 class UserInputMonitorWin : public UserInputMonitor { | 74 class UserInputMonitorWin : public UserInputMonitor { |
75 public: | 75 public: |
76 explicit UserInputMonitorWin( | 76 explicit UserInputMonitorWin( |
77 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); | 77 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); |
78 ~UserInputMonitorWin() override; | 78 ~UserInputMonitorWin() override; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 UINT size = 0; | 180 UINT size = 0; |
181 UINT result = GetRawInputData( | 181 UINT result = GetRawInputData( |
182 input_handle, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); | 182 input_handle, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); |
183 if (result == static_cast<UINT>(-1)) { | 183 if (result == static_cast<UINT>(-1)) { |
184 PLOG(ERROR) << "GetRawInputData() failed"; | 184 PLOG(ERROR) << "GetRawInputData() failed"; |
185 return 0; | 185 return 0; |
186 } | 186 } |
187 DCHECK_EQ(0u, result); | 187 DCHECK_EQ(0u, result); |
188 | 188 |
189 // Retrieve the input record itself. | 189 // Retrieve the input record itself. |
190 scoped_ptr<uint8[]> buffer(new uint8[size]); | 190 scoped_ptr<uint8_t[]> buffer(new uint8_t[size]); |
191 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); | 191 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); |
192 result = GetRawInputData( | 192 result = GetRawInputData( |
193 input_handle, RID_INPUT, buffer.get(), &size, sizeof(RAWINPUTHEADER)); | 193 input_handle, RID_INPUT, buffer.get(), &size, sizeof(RAWINPUTHEADER)); |
194 if (result == static_cast<UINT>(-1)) { | 194 if (result == static_cast<UINT>(-1)) { |
195 PLOG(ERROR) << "GetRawInputData() failed"; | 195 PLOG(ERROR) << "GetRawInputData() failed"; |
196 return 0; | 196 return 0; |
197 } | 197 } |
198 DCHECK_EQ(size, result); | 198 DCHECK_EQ(size, result); |
199 | 199 |
200 // Notify the observer about events generated locally. | 200 // Notify the observer about events generated locally. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 } // namespace | 309 } // namespace |
310 | 310 |
311 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( | 311 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( |
312 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 312 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
313 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 313 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
314 return scoped_ptr<UserInputMonitor>(new UserInputMonitorWin(ui_task_runner)); | 314 return scoped_ptr<UserInputMonitor>(new UserInputMonitorWin(ui_task_runner)); |
315 } | 315 } |
316 | 316 |
317 } // namespace media | 317 } // namespace media |
OLD | NEW |