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 <sys/select.h> | 7 #include <sys/select.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/sequence_checker.h" |
11 #define XK_MISCELLANY | 12 #define XK_MISCELLANY |
12 #include <X11/keysymdef.h> | 13 #include <X11/keysymdef.h> |
13 | 14 |
14 #include "base/bind.h" | 15 #include "base/bind.h" |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
17 #include "base/files/file_descriptor_watcher_posix.h" | 18 #include "base/files/file_descriptor_watcher_posix.h" |
18 #include "base/location.h" | 19 #include "base/location.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "base/macros.h" | 21 #include "base/macros.h" |
21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
22 #include "base/threading/non_thread_safe.h" | |
23 #include "remoting/host/client_session_control.h" | 23 #include "remoting/host/client_session_control.h" |
24 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 24 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
25 | 25 |
26 // These includes need to be later than dictated by the style guide due to | 26 // These includes need to be later than dictated by the style guide due to |
27 // Xlib header pollution, specifically the min, max, and Status macros. | 27 // Xlib header pollution, specifically the min, max, and Status macros. |
28 #include <X11/XKBlib.h> | 28 #include <X11/XKBlib.h> |
29 #include <X11/Xlibint.h> | 29 #include <X11/Xlibint.h> |
30 #include <X11/extensions/record.h> | 30 #include <X11/extensions/record.h> |
31 | 31 |
32 namespace remoting { | 32 namespace remoting { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 class LocalInputMonitorX11 : public base::NonThreadSafe, | 36 class LocalInputMonitorX11 : public LocalInputMonitor { |
37 public LocalInputMonitor { | |
38 public: | 37 public: |
39 LocalInputMonitorX11( | 38 LocalInputMonitorX11( |
40 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
41 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 40 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
42 base::WeakPtr<ClientSessionControl> client_session_control); | 41 base::WeakPtr<ClientSessionControl> client_session_control); |
43 ~LocalInputMonitorX11() override; | 42 ~LocalInputMonitorX11() override; |
44 | 43 |
45 private: | 44 private: |
46 // The actual implementation resides in LocalInputMonitorX11::Core class. | 45 // The actual implementation resides in LocalInputMonitorX11::Core class. |
47 class Core : public base::RefCountedThreadSafe<Core> { | 46 class Core : public base::RefCountedThreadSafe<Core> { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 Display* display_; | 89 Display* display_; |
91 Display* x_record_display_; | 90 Display* x_record_display_; |
92 XRecordRange* x_record_range_[2]; | 91 XRecordRange* x_record_range_[2]; |
93 XRecordContext x_record_context_; | 92 XRecordContext x_record_context_; |
94 | 93 |
95 DISALLOW_COPY_AND_ASSIGN(Core); | 94 DISALLOW_COPY_AND_ASSIGN(Core); |
96 }; | 95 }; |
97 | 96 |
98 scoped_refptr<Core> core_; | 97 scoped_refptr<Core> core_; |
99 | 98 |
| 99 SEQUENCE_CHECKER(sequence_checker_); |
| 100 |
100 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorX11); | 101 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorX11); |
101 }; | 102 }; |
102 | 103 |
103 LocalInputMonitorX11::LocalInputMonitorX11( | 104 LocalInputMonitorX11::LocalInputMonitorX11( |
104 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 105 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
105 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 106 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
106 base::WeakPtr<ClientSessionControl> client_session_control) | 107 base::WeakPtr<ClientSessionControl> client_session_control) |
107 : core_(new Core(caller_task_runner, | 108 : core_(new Core(caller_task_runner, |
108 input_task_runner, | 109 input_task_runner, |
109 client_session_control)) { | 110 client_session_control)) { |
110 core_->Start(); | 111 core_->Start(); |
111 } | 112 } |
112 | 113 |
113 LocalInputMonitorX11::~LocalInputMonitorX11() { | 114 LocalInputMonitorX11::~LocalInputMonitorX11() { |
| 115 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
114 core_->Stop(); | 116 core_->Stop(); |
115 } | 117 } |
116 | 118 |
117 LocalInputMonitorX11::Core::Core( | 119 LocalInputMonitorX11::Core::Core( |
118 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 120 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
119 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 121 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
120 base::WeakPtr<ClientSessionControl> client_session_control) | 122 base::WeakPtr<ClientSessionControl> client_session_control) |
121 : caller_task_runner_(caller_task_runner), | 123 : caller_task_runner_(caller_task_runner), |
122 input_task_runner_(input_task_runner), | 124 input_task_runner_(input_task_runner), |
123 client_session_control_(client_session_control), | 125 client_session_control_(client_session_control), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( | 308 std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( |
307 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 309 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
308 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 310 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
309 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 311 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
310 base::WeakPtr<ClientSessionControl> client_session_control) { | 312 base::WeakPtr<ClientSessionControl> client_session_control) { |
311 return base::WrapUnique(new LocalInputMonitorX11( | 313 return base::WrapUnique(new LocalInputMonitorX11( |
312 caller_task_runner, input_task_runner, client_session_control)); | 314 caller_task_runner, input_task_runner, client_session_control)); |
313 } | 315 } |
314 | 316 |
315 } // namespace remoting | 317 } // namespace remoting |
OLD | NEW |