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/desktop_session_agent.h" | 5 #include "remoting/host/desktop_session_agent.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
11 #include "ipc/ipc_message_macros.h" | 11 #include "ipc/ipc_message_macros.h" |
12 #include "media/video/capture/screen/screen_capture_data.h" | 12 #include "media/video/capture/screen/screen_capture_data.h" |
13 #include "remoting/base/auto_thread_task_runner.h" | 13 #include "remoting/base/auto_thread_task_runner.h" |
14 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" |
15 #include "remoting/host/audio_capturer.h" | 15 #include "remoting/host/audio_capturer.h" |
16 #include "remoting/host/chromoting_messages.h" | 16 #include "remoting/host/chromoting_messages.h" |
17 #include "remoting/host/desktop_environment.h" | 17 #include "remoting/host/desktop_environment.h" |
18 #include "remoting/host/disconnect_window.h" | 18 #include "remoting/host/disconnect_window.h" |
19 #include "remoting/host/event_executor.h" | 19 #include "remoting/host/input_injector.h" |
20 #include "remoting/host/local_input_monitor.h" | 20 #include "remoting/host/local_input_monitor.h" |
21 #include "remoting/host/remote_input_filter.h" | 21 #include "remoting/host/remote_input_filter.h" |
22 #include "remoting/host/screen_resolution.h" | 22 #include "remoting/host/screen_resolution.h" |
23 #include "remoting/host/session_controller.h" | 23 #include "remoting/host/session_controller.h" |
24 #include "remoting/proto/audio.pb.h" | 24 #include "remoting/proto/audio.pb.h" |
25 #include "remoting/proto/control.pb.h" | 25 #include "remoting/proto/control.pb.h" |
26 #include "remoting/proto/event.pb.h" | 26 #include "remoting/proto/event.pb.h" |
27 #include "remoting/protocol/clipboard_stub.h" | 27 #include "remoting/protocol/clipboard_stub.h" |
28 #include "remoting/protocol/input_event_tracker.h" | 28 #include "remoting/protocol/input_event_tracker.h" |
29 #include "third_party/skia/include/core/SkRegion.h" | 29 #include "third_party/skia/include/core/SkRegion.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 SendToNetwork( | 171 SendToNetwork( |
172 new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(buffer->id())); | 172 new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(buffer->id())); |
173 } | 173 } |
174 | 174 |
175 void DesktopSessionAgent::OnStartSessionAgent( | 175 void DesktopSessionAgent::OnStartSessionAgent( |
176 const std::string& authenticated_jid, | 176 const std::string& authenticated_jid, |
177 const ScreenResolution& resolution) { | 177 const ScreenResolution& resolution) { |
178 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 178 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
179 DCHECK(!started_); | 179 DCHECK(!started_); |
180 DCHECK(!audio_capturer_); | 180 DCHECK(!audio_capturer_); |
181 DCHECK(!event_executor_); | 181 DCHECK(!input_injector_); |
182 DCHECK(!video_capturer_); | 182 DCHECK(!video_capturer_); |
183 | 183 |
184 started_ = true; | 184 started_ = true; |
185 | 185 |
186 // Create a desktop environment for the new session. | 186 // Create a desktop environment for the new session. |
187 base::Closure disconnect_session = | 187 base::Closure disconnect_session = |
188 base::Bind(&DesktopSessionAgent::DisconnectSession, this); | 188 base::Bind(&DesktopSessionAgent::DisconnectSession, this); |
189 scoped_ptr<DesktopEnvironment> desktop_environment = | 189 scoped_ptr<DesktopEnvironment> desktop_environment = |
190 delegate_->desktop_environment_factory().Create(authenticated_jid, | 190 delegate_->desktop_environment_factory().Create(authenticated_jid, |
191 disconnect_session); | 191 disconnect_session); |
192 | 192 |
193 // Create the session controller and set the initial screen resolution. | 193 // Create the session controller and set the initial screen resolution. |
194 session_controller_ = desktop_environment->CreateSessionController(); | 194 session_controller_ = desktop_environment->CreateSessionController(); |
195 SetScreenResolution(resolution); | 195 SetScreenResolution(resolution); |
196 | 196 |
197 // Create the event executor. | 197 // Create the input injector. |
198 event_executor_ = | 198 input_injector_ = |
199 desktop_environment->CreateEventExecutor(input_task_runner(), | 199 desktop_environment->CreateInputInjector(input_task_runner(), |
200 caller_task_runner()); | 200 caller_task_runner()); |
201 | 201 |
202 // Hook up the input filter | 202 // Hook up the input filter. |
203 input_tracker_.reset(new protocol::InputEventTracker(event_executor_.get())); | 203 input_tracker_.reset(new protocol::InputEventTracker(input_injector_.get())); |
204 remote_input_filter_.reset(new RemoteInputFilter(input_tracker_.get())); | 204 remote_input_filter_.reset(new RemoteInputFilter(input_tracker_.get())); |
205 | 205 |
206 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
207 // LocalInputMonitorWin filters out an echo of the injected input before it | 207 // LocalInputMonitorWin filters out an echo of the injected input before it |
208 // reaches |remote_input_filter_|. | 208 // reaches |remote_input_filter_|. |
209 remote_input_filter_->SetExpectLocalEcho(false); | 209 remote_input_filter_->SetExpectLocalEcho(false); |
210 #endif // defined(OS_WIN) | 210 #endif // defined(OS_WIN) |
211 | 211 |
212 // Start the event executor. | 212 // Start the input injector. |
213 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 213 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
214 new DesktopSesssionClipboardStub(this)); | 214 new DesktopSesssionClipboardStub(this)); |
215 event_executor_->Start(clipboard_stub.Pass()); | 215 input_injector_->Start(clipboard_stub.Pass()); |
216 | 216 |
217 // Create the disconnect window. | 217 // Create the disconnect window. |
218 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); | 218 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); |
219 disconnect_window_->Show( | 219 disconnect_window_->Show( |
220 disconnect_session, | 220 disconnect_session, |
221 authenticated_jid.substr(0, authenticated_jid.find('/'))); | 221 authenticated_jid.substr(0, authenticated_jid.find('/'))); |
222 | 222 |
223 // Start monitoring local input. | 223 // Start monitoring local input. |
224 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, | 224 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, |
225 input_task_runner_, | 225 input_task_runner_, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // Stop monitoring to local input. | 329 // Stop monitoring to local input. |
330 local_input_monitor_->Stop(); | 330 local_input_monitor_->Stop(); |
331 local_input_monitor_.reset(); | 331 local_input_monitor_.reset(); |
332 | 332 |
333 remote_input_filter_.reset(); | 333 remote_input_filter_.reset(); |
334 | 334 |
335 // Ensure that any pressed keys or buttons are released. | 335 // Ensure that any pressed keys or buttons are released. |
336 input_tracker_->ReleaseAll(); | 336 input_tracker_->ReleaseAll(); |
337 input_tracker_.reset(); | 337 input_tracker_.reset(); |
338 | 338 |
339 event_executor_.reset(); | 339 input_injector_.reset(); |
340 session_controller_.reset(); | 340 session_controller_.reset(); |
341 | 341 |
342 // Stop the audio capturer. | 342 // Stop the audio capturer. |
343 audio_capture_task_runner()->PostTask( | 343 audio_capture_task_runner()->PostTask( |
344 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); | 344 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); |
345 | 345 |
346 // Stop the video capturer. | 346 // Stop the video capturer. |
347 video_capture_task_runner()->PostTask( | 347 video_capture_task_runner()->PostTask( |
348 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); | 348 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); |
349 } | 349 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 414 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
415 | 415 |
416 protocol::ClipboardEvent event; | 416 protocol::ClipboardEvent event; |
417 if (!event.ParseFromString(serialized_event)) { | 417 if (!event.ParseFromString(serialized_event)) { |
418 LOG(ERROR) << "Failed to parse protocol::ClipboardEvent."; | 418 LOG(ERROR) << "Failed to parse protocol::ClipboardEvent."; |
419 return; | 419 return; |
420 } | 420 } |
421 | 421 |
422 // InputStub implementations must verify events themselves, so we don't need | 422 // InputStub implementations must verify events themselves, so we don't need |
423 // verification here. This matches HostEventDispatcher. | 423 // verification here. This matches HostEventDispatcher. |
424 event_executor_->InjectClipboardEvent(event); | 424 input_injector_->InjectClipboardEvent(event); |
425 } | 425 } |
426 | 426 |
427 void DesktopSessionAgent::OnInjectKeyEvent( | 427 void DesktopSessionAgent::OnInjectKeyEvent( |
428 const std::string& serialized_event) { | 428 const std::string& serialized_event) { |
429 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 429 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
430 | 430 |
431 protocol::KeyEvent event; | 431 protocol::KeyEvent event; |
432 if (!event.ParseFromString(serialized_event)) { | 432 if (!event.ParseFromString(serialized_event)) { |
433 LOG(ERROR) << "Failed to parse protocol::KeyEvent."; | 433 LOG(ERROR) << "Failed to parse protocol::KeyEvent."; |
434 return; | 434 return; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 base::ClosePlatformFile(desktop_pipe_.fd); | 546 base::ClosePlatformFile(desktop_pipe_.fd); |
547 #else // !defined(OS_POSIX) | 547 #else // !defined(OS_POSIX) |
548 #error Unsupported platform. | 548 #error Unsupported platform. |
549 #endif // !defined(OS_POSIX) | 549 #endif // !defined(OS_POSIX) |
550 | 550 |
551 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 551 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 } // namespace remoting | 555 } // namespace remoting |
OLD | NEW |