OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/local_input_monitor.h" | 5 #include "remoting/host/local_input_monitor.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
17 #include "base/win/message_window.h" | 18 #include "base/win/message_window.h" |
18 #include "remoting/host/client_session_control.h" | 19 #include "remoting/host/client_session_control.h" |
19 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
20 | 21 |
21 namespace remoting { | 22 namespace remoting { |
22 | 23 |
23 namespace { | 24 namespace { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 LPARAM lparam, | 63 LPARAM lparam, |
63 LRESULT* result); | 64 LRESULT* result); |
64 | 65 |
65 // Task runner on which public methods of this class must be called. | 66 // Task runner on which public methods of this class must be called. |
66 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 67 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
67 | 68 |
68 // Task runner on which |window_| is created. | 69 // Task runner on which |window_| is created. |
69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 70 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
70 | 71 |
71 // Used to receive raw input. | 72 // Used to receive raw input. |
72 scoped_ptr<base::win::MessageWindow> window_; | 73 std::unique_ptr<base::win::MessageWindow> window_; |
73 | 74 |
74 // Points to the object receiving mouse event notifications. | 75 // Points to the object receiving mouse event notifications. |
75 base::WeakPtr<ClientSessionControl> client_session_control_; | 76 base::WeakPtr<ClientSessionControl> client_session_control_; |
76 | 77 |
77 DISALLOW_COPY_AND_ASSIGN(Core); | 78 DISALLOW_COPY_AND_ASSIGN(Core); |
78 }; | 79 }; |
79 | 80 |
80 scoped_refptr<Core> core_; | 81 scoped_refptr<Core> core_; |
81 | 82 |
82 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin); | 83 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 RID_INPUT, | 168 RID_INPUT, |
168 nullptr, | 169 nullptr, |
169 &size, | 170 &size, |
170 sizeof(RAWINPUTHEADER)); | 171 sizeof(RAWINPUTHEADER)); |
171 if (result == static_cast<UINT>(-1)) { | 172 if (result == static_cast<UINT>(-1)) { |
172 PLOG(ERROR) << "GetRawInputData() failed"; | 173 PLOG(ERROR) << "GetRawInputData() failed"; |
173 return 0; | 174 return 0; |
174 } | 175 } |
175 | 176 |
176 // Retrieve the input record itself. | 177 // Retrieve the input record itself. |
177 scoped_ptr<uint8_t[]> buffer(new uint8_t[size]); | 178 std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); |
178 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); | 179 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); |
179 result = GetRawInputData(input_handle, | 180 result = GetRawInputData(input_handle, |
180 RID_INPUT, | 181 RID_INPUT, |
181 buffer.get(), | 182 buffer.get(), |
182 &size, | 183 &size, |
183 sizeof(RAWINPUTHEADER)); | 184 sizeof(RAWINPUTHEADER)); |
184 if (result == static_cast<UINT>(-1)) { | 185 if (result == static_cast<UINT>(-1)) { |
185 PLOG(ERROR) << "GetRawInputData() failed"; | 186 PLOG(ERROR) << "GetRawInputData() failed"; |
186 return 0; | 187 return 0; |
187 } | 188 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 *result = OnInput(reinterpret_cast<HRAWINPUT>(lparam)); | 229 *result = OnInput(reinterpret_cast<HRAWINPUT>(lparam)); |
229 return true; | 230 return true; |
230 | 231 |
231 default: | 232 default: |
232 return false; | 233 return false; |
233 } | 234 } |
234 } | 235 } |
235 | 236 |
236 } // namespace | 237 } // namespace |
237 | 238 |
238 scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create( | 239 std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( |
239 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 240 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
240 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 241 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
241 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 242 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
242 base::WeakPtr<ClientSessionControl> client_session_control) { | 243 base::WeakPtr<ClientSessionControl> client_session_control) { |
243 return make_scoped_ptr(new LocalInputMonitorWin( | 244 return base::WrapUnique(new LocalInputMonitorWin( |
244 caller_task_runner, ui_task_runner, client_session_control)); | 245 caller_task_runner, ui_task_runner, client_session_control)); |
245 } | 246 } |
246 | 247 |
247 } // namespace remoting | 248 } // namespace remoting |
OLD | NEW |