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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 LRESULT UserInputMonitorWinCore::OnInput(HRAWINPUT input_handle) { | 176 LRESULT UserInputMonitorWinCore::OnInput(HRAWINPUT input_handle) { |
177 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 177 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
178 | 178 |
179 // Get the size of the input record. | 179 // Get the size of the input record. |
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 == -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[]> buffer(new uint8[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 == -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. |
201 if (input->header.dwType == RIM_TYPEMOUSE && input->header.hDevice != NULL) { | 201 if (input->header.dwType == RIM_TYPEMOUSE && input->header.hDevice != NULL) { |
202 POINT position; | 202 POINT position; |
203 if (!GetCursorPos(&position)) { | 203 if (!GetCursorPos(&position)) { |
204 position.x = 0; | 204 position.x = 0; |
(...skipping 103 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 |