| 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/event_executor.h" |
| 20 #include "remoting/host/local_input_monitor.h" | |
| 21 #include "remoting/host/remote_input_filter.h" | 20 #include "remoting/host/remote_input_filter.h" |
| 22 #include "remoting/host/screen_resolution.h" | 21 #include "remoting/host/screen_resolution.h" |
| 23 #include "remoting/host/session_controller.h" | 22 #include "remoting/host/session_controller.h" |
| 24 #include "remoting/proto/audio.pb.h" | 23 #include "remoting/proto/audio.pb.h" |
| 25 #include "remoting/proto/control.pb.h" | 24 #include "remoting/proto/control.pb.h" |
| 26 #include "remoting/proto/event.pb.h" | 25 #include "remoting/proto/event.pb.h" |
| 27 #include "remoting/protocol/clipboard_stub.h" | 26 #include "remoting/protocol/clipboard_stub.h" |
| 28 #include "remoting/protocol/input_event_tracker.h" | 27 #include "remoting/protocol/input_event_tracker.h" |
| 29 #include "third_party/skia/include/core/SkRegion.h" | 28 #include "third_party/skia/include/core/SkRegion.h" |
| 30 | 29 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 62 } |
| 64 | 63 |
| 65 } // namespace | 64 } // namespace |
| 66 | 65 |
| 67 DesktopSessionAgent::Delegate::~Delegate() { | 66 DesktopSessionAgent::Delegate::~Delegate() { |
| 68 } | 67 } |
| 69 | 68 |
| 70 DesktopSessionAgent::~DesktopSessionAgent() { | 69 DesktopSessionAgent::~DesktopSessionAgent() { |
| 71 DCHECK(!audio_capturer_); | 70 DCHECK(!audio_capturer_); |
| 72 DCHECK(!disconnect_window_); | 71 DCHECK(!disconnect_window_); |
| 73 DCHECK(!local_input_monitor_); | |
| 74 DCHECK(!network_channel_); | 72 DCHECK(!network_channel_); |
| 75 DCHECK(!video_capturer_); | 73 DCHECK(!video_capturer_); |
| 76 | 74 |
| 77 CloseDesktopPipeHandle(); | 75 CloseDesktopPipeHandle(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { | 78 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { |
| 81 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 79 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 82 | 80 |
| 83 bool handled = true; | 81 bool handled = true; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // reaches |remote_input_filter_|. | 206 // reaches |remote_input_filter_|. |
| 209 remote_input_filter_->SetExpectLocalEcho(false); | 207 remote_input_filter_->SetExpectLocalEcho(false); |
| 210 #endif // defined(OS_WIN) | 208 #endif // defined(OS_WIN) |
| 211 | 209 |
| 212 // Start the event executor. | 210 // Start the event executor. |
| 213 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 211 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
| 214 new DesktopSesssionClipboardStub(this)); | 212 new DesktopSesssionClipboardStub(this)); |
| 215 event_executor_->Start(clipboard_stub.Pass()); | 213 event_executor_->Start(clipboard_stub.Pass()); |
| 216 | 214 |
| 217 // Create the disconnect window. | 215 // Create the disconnect window. |
| 218 base::Closure disconnect_session = | |
| 219 base::Bind(&DesktopSessionAgent::DisconnectSession, this); | |
| 220 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); | 216 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); |
| 221 disconnect_window_->Show( | 217 disconnect_window_->Show( |
| 222 disconnect_session, | 218 base::Bind(&DesktopSessionAgent::DisconnectSession, this), |
| 223 authenticated_jid.substr(0, authenticated_jid.find('/'))); | 219 authenticated_jid.substr(0, authenticated_jid.find('/'))); |
| 224 | 220 |
| 225 // Start monitoring local input. | |
| 226 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, | |
| 227 input_task_runner_, | |
| 228 caller_task_runner_); | |
| 229 local_input_monitor_->Start(this, disconnect_session); | |
| 230 | |
| 231 // Start the audio capturer. | 221 // Start the audio capturer. |
| 232 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { | 222 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { |
| 233 audio_capturer_ = desktop_environment->CreateAudioCapturer(); | 223 audio_capturer_ = desktop_environment->CreateAudioCapturer(); |
| 234 audio_capture_task_runner()->PostTask( | 224 audio_capture_task_runner()->PostTask( |
| 235 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); | 225 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); |
| 236 } | 226 } |
| 237 | 227 |
| 238 // Start the video capturer. | 228 // Start the video capturer. |
| 239 video_capturer_ = desktop_environment->CreateVideoCapturer(); | 229 video_capturer_ = desktop_environment->CreateVideoCapturer(); |
| 240 video_capture_task_runner()->PostTask( | 230 video_capture_task_runner()->PostTask( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // Make sure the channel is closed. | 309 // Make sure the channel is closed. |
| 320 network_channel_.reset(); | 310 network_channel_.reset(); |
| 321 | 311 |
| 322 if (started_) { | 312 if (started_) { |
| 323 started_ = false; | 313 started_ = false; |
| 324 | 314 |
| 325 // Close the disconnect window and stop listening to local input. | 315 // Close the disconnect window and stop listening to local input. |
| 326 disconnect_window_->Hide(); | 316 disconnect_window_->Hide(); |
| 327 disconnect_window_.reset(); | 317 disconnect_window_.reset(); |
| 328 | 318 |
| 329 // Stop monitoring to local input. | 319 session_controller_.reset(); |
| 330 local_input_monitor_->Stop(); | |
| 331 local_input_monitor_.reset(); | |
| 332 | |
| 333 remote_input_filter_.reset(); | 320 remote_input_filter_.reset(); |
| 334 | 321 |
| 335 // Ensure that any pressed keys or buttons are released. | 322 // Ensure that any pressed keys or buttons are released. |
| 336 input_tracker_->ReleaseAll(); | 323 input_tracker_->ReleaseAll(); |
| 337 input_tracker_.reset(); | 324 input_tracker_.reset(); |
| 338 | 325 |
| 339 event_executor_.reset(); | 326 event_executor_.reset(); |
| 340 session_controller_.reset(); | |
| 341 | 327 |
| 342 // Stop the audio capturer. | 328 // Stop the audio capturer. |
| 343 audio_capture_task_runner()->PostTask( | 329 audio_capture_task_runner()->PostTask( |
| 344 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); | 330 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); |
| 345 | 331 |
| 346 // Stop the video capturer. | 332 // Stop the video capturer. |
| 347 video_capture_task_runner()->PostTask( | 333 video_capture_task_runner()->PostTask( |
| 348 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); | 334 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); |
| 349 } | 335 } |
| 350 } | 336 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 base::ClosePlatformFile(desktop_pipe_.fd); | 528 base::ClosePlatformFile(desktop_pipe_.fd); |
| 543 #else // !defined(OS_POSIX) | 529 #else // !defined(OS_POSIX) |
| 544 #error Unsupported platform. | 530 #error Unsupported platform. |
| 545 #endif // !defined(OS_POSIX) | 531 #endif // !defined(OS_POSIX) |
| 546 | 532 |
| 547 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 533 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); |
| 548 } | 534 } |
| 549 } | 535 } |
| 550 | 536 |
| 551 } // namespace remoting | 537 } // namespace remoting |
| OLD | NEW |