| 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_controls.h" | 21 #include "remoting/host/screen_controls.h" |
| 23 #include "remoting/host/screen_resolution.h" | 22 #include "remoting/host/screen_resolution.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(!desktop_environment_); | 71 DCHECK(!desktop_environment_); |
| 73 DCHECK(!disconnect_window_); | 72 DCHECK(!disconnect_window_); |
| 74 DCHECK(!local_input_monitor_); | |
| 75 DCHECK(!network_channel_); | 73 DCHECK(!network_channel_); |
| 76 DCHECK(!screen_controls_); | 74 DCHECK(!screen_controls_); |
| 77 DCHECK(!video_capturer_); | 75 DCHECK(!video_capturer_); |
| 78 | 76 |
| 79 CloseDesktopPipeHandle(); | 77 CloseDesktopPipeHandle(); |
| 80 } | 78 } |
| 81 | 79 |
| 82 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { | 80 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { |
| 83 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 81 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 84 | 82 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 176 |
| 179 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { | 177 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { |
| 180 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 178 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 181 | 179 |
| 182 remote_input_filter_->LocalMouseMoved(new_pos); | 180 remote_input_filter_->LocalMouseMoved(new_pos); |
| 183 } | 181 } |
| 184 | 182 |
| 185 void DesktopSessionAgent::SetDisableInputs(bool disable_inputs) { | 183 void DesktopSessionAgent::SetDisableInputs(bool disable_inputs) { |
| 186 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 184 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 187 | 185 |
| 188 // Do not expact this method to be called because it is only used by It2Me. | 186 // Do not expect this method to be called because it is only used by It2Me. |
| 189 NOTIMPLEMENTED(); | 187 NOTIMPLEMENTED(); |
| 190 } | 188 } |
| 191 | 189 |
| 192 void DesktopSessionAgent::OnStartSessionAgent( | 190 void DesktopSessionAgent::OnStartSessionAgent( |
| 193 const std::string& authenticated_jid, | 191 const std::string& authenticated_jid, |
| 194 const ScreenResolution& resolution) { | 192 const ScreenResolution& resolution) { |
| 195 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 193 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 196 DCHECK(!started_); | 194 DCHECK(!started_); |
| 197 DCHECK(!audio_capturer_); | 195 DCHECK(!audio_capturer_); |
| 198 DCHECK(!desktop_environment_); | 196 DCHECK(!desktop_environment_); |
| 199 DCHECK(!disconnect_window_); | 197 DCHECK(!disconnect_window_); |
| 200 DCHECK(!local_input_monitor_); | |
| 201 DCHECK(!screen_controls_); | 198 DCHECK(!screen_controls_); |
| 202 DCHECK(!video_capturer_); | 199 DCHECK(!video_capturer_); |
| 203 | 200 |
| 204 started_ = true; | 201 started_ = true; |
| 205 client_jid_ = authenticated_jid; | 202 client_jid_ = authenticated_jid; |
| 206 | 203 |
| 207 // Create a desktop environment for the new session. | 204 // Create a desktop environment for the new session. |
| 208 desktop_environment_ = delegate_->desktop_environment_factory().Create( | 205 desktop_environment_ = delegate_->desktop_environment_factory().Create( |
| 209 control_factory_.GetWeakPtr()); | 206 control_factory_.GetWeakPtr()); |
| 210 | 207 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 224 // reaches |remote_input_filter_|. | 221 // reaches |remote_input_filter_|. |
| 225 remote_input_filter_->SetExpectLocalEcho(false); | 222 remote_input_filter_->SetExpectLocalEcho(false); |
| 226 #endif // defined(OS_WIN) | 223 #endif // defined(OS_WIN) |
| 227 | 224 |
| 228 // Start the event executor. | 225 // Start the event executor. |
| 229 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 226 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
| 230 new DesktopSesssionClipboardStub(this)); | 227 new DesktopSesssionClipboardStub(this)); |
| 231 event_executor_->Start(clipboard_stub.Pass()); | 228 event_executor_->Start(clipboard_stub.Pass()); |
| 232 | 229 |
| 233 // Create the disconnect window. | 230 // Create the disconnect window. |
| 234 base::Closure disconnect_session = | |
| 235 base::Bind(&DesktopSessionAgent::DisconnectSession, this); | |
| 236 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); | 231 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); |
| 237 disconnect_window_->Show( | 232 disconnect_window_->Show( |
| 238 disconnect_session, | 233 base::Bind(&DesktopSessionAgent::DisconnectSession, this), |
| 239 authenticated_jid.substr(0, authenticated_jid.find('/'))); | 234 authenticated_jid.substr(0, authenticated_jid.find('/'))); |
| 240 | 235 |
| 241 // Start monitoring local input. | |
| 242 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, | |
| 243 input_task_runner_, | |
| 244 caller_task_runner_); | |
| 245 local_input_monitor_->Start(this, disconnect_session); | |
| 246 | |
| 247 // Start the audio capturer. | 236 // Start the audio capturer. |
| 248 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { | 237 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { |
| 249 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); | 238 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); |
| 250 audio_capture_task_runner()->PostTask( | 239 audio_capture_task_runner()->PostTask( |
| 251 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); | 240 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); |
| 252 } | 241 } |
| 253 | 242 |
| 254 // Start the video capturer. | 243 // Start the video capturer. |
| 255 video_capturer_ = desktop_environment_->CreateVideoCapturer(); | 244 video_capturer_ = desktop_environment_->CreateVideoCapturer(); |
| 256 video_capture_task_runner()->PostTask( | 245 video_capture_task_runner()->PostTask( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 started_ = false; | 328 started_ = false; |
| 340 | 329 |
| 341 // Close the disconnect window and stop listening to local input. | 330 // Close the disconnect window and stop listening to local input. |
| 342 disconnect_window_->Hide(); | 331 disconnect_window_->Hide(); |
| 343 disconnect_window_.reset(); | 332 disconnect_window_.reset(); |
| 344 | 333 |
| 345 // Ignore any further callbacks. | 334 // Ignore any further callbacks. |
| 346 control_factory_.InvalidateWeakPtrs(); | 335 control_factory_.InvalidateWeakPtrs(); |
| 347 client_jid_.clear(); | 336 client_jid_.clear(); |
| 348 | 337 |
| 349 // Stop monitoring to local input. | |
| 350 local_input_monitor_->Stop(); | |
| 351 local_input_monitor_.reset(); | |
| 352 | |
| 353 remote_input_filter_.reset(); | 338 remote_input_filter_.reset(); |
| 354 | 339 |
| 355 // Ensure that any pressed keys or buttons are released. | 340 // Ensure that any pressed keys or buttons are released. |
| 356 input_tracker_->ReleaseAll(); | 341 input_tracker_->ReleaseAll(); |
| 357 input_tracker_.reset(); | 342 input_tracker_.reset(); |
| 358 | 343 |
| 344 desktop_environment_.reset(); |
| 359 event_executor_.reset(); | 345 event_executor_.reset(); |
| 360 screen_controls_.reset(); | 346 screen_controls_.reset(); |
| 361 desktop_environment_.reset(); | |
| 362 | 347 |
| 363 // Stop the audio capturer. | 348 // Stop the audio capturer. |
| 364 audio_capture_task_runner()->PostTask( | 349 audio_capture_task_runner()->PostTask( |
| 365 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); | 350 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); |
| 366 | 351 |
| 367 // Stop the video capturer. | 352 // Stop the video capturer. |
| 368 video_capture_task_runner()->PostTask( | 353 video_capture_task_runner()->PostTask( |
| 369 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); | 354 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); |
| 370 } | 355 } |
| 371 } | 356 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 base::ClosePlatformFile(desktop_pipe_.fd); | 549 base::ClosePlatformFile(desktop_pipe_.fd); |
| 565 #else // !defined(OS_POSIX) | 550 #else // !defined(OS_POSIX) |
| 566 #error Unsupported platform. | 551 #error Unsupported platform. |
| 567 #endif // !defined(OS_POSIX) | 552 #endif // !defined(OS_POSIX) |
| 568 | 553 |
| 569 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 554 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); |
| 570 } | 555 } |
| 571 } | 556 } |
| 572 | 557 |
| 573 } // namespace remoting | 558 } // namespace remoting |
| OLD | NEW |