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/memory/ptr_util.h" |
| 15 #include "base/sequence_checker.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/threading/non_thread_safe.h" | |
18 #include "base/win/message_window.h" | 18 #include "base/win/message_window.h" |
19 #include "remoting/host/client_session_control.h" | 19 #include "remoting/host/client_session_control.h" |
20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
21 | 21 |
22 namespace remoting { | 22 namespace remoting { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // From the HID Usage Tables specification. | 26 // From the HID Usage Tables specification. |
27 const USHORT kGenericDesktopPage = 1; | 27 const USHORT kGenericDesktopPage = 1; |
28 const USHORT kMouseUsage = 2; | 28 const USHORT kMouseUsage = 2; |
29 | 29 |
30 class LocalInputMonitorWin : public base::NonThreadSafe, | 30 class LocalInputMonitorWin : public LocalInputMonitor { |
31 public LocalInputMonitor { | |
32 public: | 31 public: |
33 LocalInputMonitorWin( | 32 LocalInputMonitorWin( |
34 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 33 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
35 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
36 base::WeakPtr<ClientSessionControl> client_session_control); | 35 base::WeakPtr<ClientSessionControl> client_session_control); |
37 ~LocalInputMonitorWin() override; | 36 ~LocalInputMonitorWin() override; |
38 | 37 |
39 private: | 38 private: |
40 // The actual implementation resides in LocalInputMonitorWin::Core class. | 39 // The actual implementation resides in LocalInputMonitorWin::Core class. |
41 class Core : public base::RefCountedThreadSafe<Core> { | 40 class Core : public base::RefCountedThreadSafe<Core> { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 std::unique_ptr<base::win::MessageWindow> window_; | 72 std::unique_ptr<base::win::MessageWindow> window_; |
74 | 73 |
75 // Points to the object receiving mouse event notifications. | 74 // Points to the object receiving mouse event notifications. |
76 base::WeakPtr<ClientSessionControl> client_session_control_; | 75 base::WeakPtr<ClientSessionControl> client_session_control_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(Core); | 77 DISALLOW_COPY_AND_ASSIGN(Core); |
79 }; | 78 }; |
80 | 79 |
81 scoped_refptr<Core> core_; | 80 scoped_refptr<Core> core_; |
82 | 81 |
| 82 SEQUENCE_CHECKER(sequence_checker_); |
| 83 |
83 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin); | 84 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin); |
84 }; | 85 }; |
85 | 86 |
86 LocalInputMonitorWin::LocalInputMonitorWin( | 87 LocalInputMonitorWin::LocalInputMonitorWin( |
87 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 88 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
88 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 89 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
89 base::WeakPtr<ClientSessionControl> client_session_control) | 90 base::WeakPtr<ClientSessionControl> client_session_control) |
90 : core_(new Core(caller_task_runner, | 91 : core_(new Core(caller_task_runner, |
91 ui_task_runner, | 92 ui_task_runner, |
92 client_session_control)) { | 93 client_session_control)) { |
93 core_->Start(); | 94 core_->Start(); |
94 } | 95 } |
95 | 96 |
96 LocalInputMonitorWin::~LocalInputMonitorWin() { | 97 LocalInputMonitorWin::~LocalInputMonitorWin() { |
| 98 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
97 core_->Stop(); | 99 core_->Stop(); |
98 } | 100 } |
99 | 101 |
100 LocalInputMonitorWin::Core::Core( | 102 LocalInputMonitorWin::Core::Core( |
101 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
102 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 104 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
103 base::WeakPtr<ClientSessionControl> client_session_control) | 105 base::WeakPtr<ClientSessionControl> client_session_control) |
104 : caller_task_runner_(caller_task_runner), | 106 : caller_task_runner_(caller_task_runner), |
105 ui_task_runner_(ui_task_runner), | 107 ui_task_runner_(ui_task_runner), |
106 client_session_control_(client_session_control) { | 108 client_session_control_(client_session_control) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( | 241 std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( |
240 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 242 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
241 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 243 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
242 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 244 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
243 base::WeakPtr<ClientSessionControl> client_session_control) { | 245 base::WeakPtr<ClientSessionControl> client_session_control) { |
244 return base::WrapUnique(new LocalInputMonitorWin( | 246 return base::WrapUnique(new LocalInputMonitorWin( |
245 caller_task_runner, ui_task_runner, client_session_control)); | 247 caller_task_runner, ui_task_runner, client_session_control)); |
246 } | 248 } |
247 | 249 |
248 } // namespace remoting | 250 } // namespace remoting |
OLD | NEW |