| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void DesktopSessionAgent::DisconnectSession() { | 167 void DesktopSessionAgent::DisconnectSession() { |
| 170 SendToNetwork(new ChromotingDesktopNetworkMsg_DisconnectSession()); | 168 SendToNetwork(new ChromotingDesktopNetworkMsg_DisconnectSession()); |
| 171 } | 169 } |
| 172 | 170 |
| 173 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { | 171 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { |
| 174 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 172 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 175 | 173 |
| 176 remote_input_filter_->LocalMouseMoved(new_pos); | 174 remote_input_filter_->LocalMouseMoved(new_pos); |
| 177 } | 175 } |
| 178 | 176 |
| 177 void DesktopSessionAgent::PauseSession(bool pause) { |
| 178 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 179 |
| 180 // SessionController::Delegate::PauseSession() is only used by the continue |
| 181 // window, so it should not be called. |
| 182 NOTIMPLEMENTED(); |
| 183 } |
| 184 |
| 179 void DesktopSessionAgent::OnStartSessionAgent( | 185 void DesktopSessionAgent::OnStartSessionAgent( |
| 180 const std::string& authenticated_jid, | 186 const std::string& authenticated_jid, |
| 181 const ScreenResolution& resolution) { | 187 const ScreenResolution& resolution) { |
| 182 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 188 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 183 DCHECK(!started_); | 189 DCHECK(!started_); |
| 184 DCHECK(!audio_capturer_); | 190 DCHECK(!audio_capturer_); |
| 185 DCHECK(!event_executor_); | 191 DCHECK(!event_executor_); |
| 186 DCHECK(!video_capturer_); | 192 DCHECK(!video_capturer_); |
| 187 | 193 |
| 188 started_ = true; | 194 started_ = true; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 208 // reaches |remote_input_filter_|. | 214 // reaches |remote_input_filter_|. |
| 209 remote_input_filter_->SetExpectLocalEcho(false); | 215 remote_input_filter_->SetExpectLocalEcho(false); |
| 210 #endif // defined(OS_WIN) | 216 #endif // defined(OS_WIN) |
| 211 | 217 |
| 212 // Start the event executor. | 218 // Start the event executor. |
| 213 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 219 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
| 214 new DesktopSesssionClipboardStub(this)); | 220 new DesktopSesssionClipboardStub(this)); |
| 215 event_executor_->Start(clipboard_stub.Pass()); | 221 event_executor_->Start(clipboard_stub.Pass()); |
| 216 | 222 |
| 217 // Create the disconnect window. | 223 // Create the disconnect window. |
| 218 base::Closure disconnect_session = | |
| 219 base::Bind(&DesktopSessionAgent::DisconnectSession, this); | |
| 220 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); | 224 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); |
| 221 disconnect_window_->Show( | 225 disconnect_window_->Show( |
| 222 disconnect_session, | 226 base::Bind(&DesktopSessionAgent::DisconnectSession, this), |
| 223 authenticated_jid.substr(0, authenticated_jid.find('/'))); | 227 authenticated_jid.substr(0, authenticated_jid.find('/'))); |
| 224 | 228 |
| 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. | 229 // Start the audio capturer. |
| 232 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { | 230 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { |
| 233 audio_capturer_ = desktop_environment->CreateAudioCapturer(); | 231 audio_capturer_ = desktop_environment->CreateAudioCapturer(); |
| 234 audio_capture_task_runner()->PostTask( | 232 audio_capture_task_runner()->PostTask( |
| 235 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); | 233 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); |
| 236 } | 234 } |
| 237 | 235 |
| 238 // Start the video capturer. | 236 // Start the video capturer. |
| 239 video_capturer_ = desktop_environment->CreateVideoCapturer(); | 237 video_capturer_ = desktop_environment->CreateVideoCapturer(); |
| 240 video_capture_task_runner()->PostTask( | 238 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. | 317 // Make sure the channel is closed. |
| 320 network_channel_.reset(); | 318 network_channel_.reset(); |
| 321 | 319 |
| 322 if (started_) { | 320 if (started_) { |
| 323 started_ = false; | 321 started_ = false; |
| 324 | 322 |
| 325 // Close the disconnect window and stop listening to local input. | 323 // Close the disconnect window and stop listening to local input. |
| 326 disconnect_window_->Hide(); | 324 disconnect_window_->Hide(); |
| 327 disconnect_window_.reset(); | 325 disconnect_window_.reset(); |
| 328 | 326 |
| 329 // Stop monitoring to local input. | 327 session_controller_.reset(); |
| 330 local_input_monitor_->Stop(); | |
| 331 local_input_monitor_.reset(); | |
| 332 | |
| 333 remote_input_filter_.reset(); | 328 remote_input_filter_.reset(); |
| 334 | 329 |
| 335 // Ensure that any pressed keys or buttons are released. | 330 // Ensure that any pressed keys or buttons are released. |
| 336 input_tracker_->ReleaseAll(); | 331 input_tracker_->ReleaseAll(); |
| 337 input_tracker_.reset(); | 332 input_tracker_.reset(); |
| 338 | 333 |
| 339 event_executor_.reset(); | 334 event_executor_.reset(); |
| 340 session_controller_.reset(); | |
| 341 | 335 |
| 342 // Stop the audio capturer. | 336 // Stop the audio capturer. |
| 343 audio_capture_task_runner()->PostTask( | 337 audio_capture_task_runner()->PostTask( |
| 344 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); | 338 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); |
| 345 | 339 |
| 346 // Stop the video capturer. | 340 // Stop the video capturer. |
| 347 video_capture_task_runner()->PostTask( | 341 video_capture_task_runner()->PostTask( |
| 348 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); | 342 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); |
| 349 } | 343 } |
| 350 } | 344 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 base::ClosePlatformFile(desktop_pipe_.fd); | 536 base::ClosePlatformFile(desktop_pipe_.fd); |
| 543 #else // !defined(OS_POSIX) | 537 #else // !defined(OS_POSIX) |
| 544 #error Unsupported platform. | 538 #error Unsupported platform. |
| 545 #endif // !defined(OS_POSIX) | 539 #endif // !defined(OS_POSIX) |
| 546 | 540 |
| 547 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 541 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); |
| 548 } | 542 } |
| 549 } | 543 } |
| 550 | 544 |
| 551 } // namespace remoting | 545 } // namespace remoting |
| OLD | NEW |