| 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" | |
| 19 #include "remoting/host/input_injector.h" | 18 #include "remoting/host/input_injector.h" |
| 20 #include "remoting/host/remote_input_filter.h" | 19 #include "remoting/host/remote_input_filter.h" |
| 21 #include "remoting/host/screen_controls.h" | 20 #include "remoting/host/screen_controls.h" |
| 22 #include "remoting/host/screen_resolution.h" | 21 #include "remoting/host/screen_resolution.h" |
| 23 #include "remoting/proto/audio.pb.h" | 22 #include "remoting/proto/audio.pb.h" |
| 24 #include "remoting/proto/control.pb.h" | 23 #include "remoting/proto/control.pb.h" |
| 25 #include "remoting/proto/event.pb.h" | 24 #include "remoting/proto/event.pb.h" |
| 26 #include "remoting/protocol/clipboard_stub.h" | 25 #include "remoting/protocol/clipboard_stub.h" |
| 27 #include "remoting/protocol/input_event_tracker.h" | 26 #include "remoting/protocol/input_event_tracker.h" |
| 28 #include "third_party/skia/include/core/SkRegion.h" | 27 #include "third_party/skia/include/core/SkRegion.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace | 63 } // namespace |
| 65 | 64 |
| 66 DesktopSessionAgent::Delegate::~Delegate() { | 65 DesktopSessionAgent::Delegate::~Delegate() { |
| 67 } | 66 } |
| 68 | 67 |
| 69 DesktopSessionAgent::~DesktopSessionAgent() { | 68 DesktopSessionAgent::~DesktopSessionAgent() { |
| 70 DCHECK(!audio_capturer_); | 69 DCHECK(!audio_capturer_); |
| 71 DCHECK(!desktop_environment_); | 70 DCHECK(!desktop_environment_); |
| 72 DCHECK(!disconnect_window_); | |
| 73 DCHECK(!network_channel_); | 71 DCHECK(!network_channel_); |
| 74 DCHECK(!screen_controls_); | 72 DCHECK(!screen_controls_); |
| 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 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 NOTREACHED(); | 185 NOTREACHED(); |
| 188 } | 186 } |
| 189 | 187 |
| 190 void DesktopSessionAgent::OnStartSessionAgent( | 188 void DesktopSessionAgent::OnStartSessionAgent( |
| 191 const std::string& authenticated_jid, | 189 const std::string& authenticated_jid, |
| 192 const ScreenResolution& resolution) { | 190 const ScreenResolution& resolution) { |
| 193 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 191 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 194 DCHECK(!started_); | 192 DCHECK(!started_); |
| 195 DCHECK(!audio_capturer_); | 193 DCHECK(!audio_capturer_); |
| 196 DCHECK(!desktop_environment_); | 194 DCHECK(!desktop_environment_); |
| 197 DCHECK(!disconnect_window_); | |
| 198 DCHECK(!input_injector_); | 195 DCHECK(!input_injector_); |
| 199 DCHECK(!screen_controls_); | 196 DCHECK(!screen_controls_); |
| 200 DCHECK(!video_capturer_); | 197 DCHECK(!video_capturer_); |
| 201 | 198 |
| 202 started_ = true; | 199 started_ = true; |
| 203 client_jid_ = authenticated_jid; | 200 client_jid_ = authenticated_jid; |
| 204 | 201 |
| 205 // Create a desktop environment for the new session. | 202 // Create a desktop environment for the new session. |
| 206 desktop_environment_ = delegate_->desktop_environment_factory().Create( | 203 desktop_environment_ = delegate_->desktop_environment_factory().Create( |
| 207 control_factory_.GetWeakPtr()); | 204 control_factory_.GetWeakPtr()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 221 // LocalInputMonitorWin filters out an echo of the injected input before it | 218 // LocalInputMonitorWin filters out an echo of the injected input before it |
| 222 // reaches |remote_input_filter_|. | 219 // reaches |remote_input_filter_|. |
| 223 remote_input_filter_->SetExpectLocalEcho(false); | 220 remote_input_filter_->SetExpectLocalEcho(false); |
| 224 #endif // defined(OS_WIN) | 221 #endif // defined(OS_WIN) |
| 225 | 222 |
| 226 // Start the input injector. | 223 // Start the input injector. |
| 227 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 224 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
| 228 new DesktopSesssionClipboardStub(this)); | 225 new DesktopSesssionClipboardStub(this)); |
| 229 input_injector_->Start(clipboard_stub.Pass()); | 226 input_injector_->Start(clipboard_stub.Pass()); |
| 230 | 227 |
| 231 // Create the disconnect window. | |
| 232 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); | |
| 233 disconnect_window_->Show( | |
| 234 base::Bind(&DesktopSessionAgent::DisconnectSession, this), | |
| 235 authenticated_jid.substr(0, authenticated_jid.find('/'))); | |
| 236 | |
| 237 // Start the audio capturer. | 228 // Start the audio capturer. |
| 238 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { | 229 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { |
| 239 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); | 230 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); |
| 240 audio_capture_task_runner()->PostTask( | 231 audio_capture_task_runner()->PostTask( |
| 241 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); | 232 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); |
| 242 } | 233 } |
| 243 | 234 |
| 244 // Start the video capturer. | 235 // Start the video capturer. |
| 245 video_capturer_ = desktop_environment_->CreateVideoCapturer(); | 236 video_capturer_ = desktop_environment_->CreateVideoCapturer(); |
| 246 video_capture_task_runner()->PostTask( | 237 video_capture_task_runner()->PostTask( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 312 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 322 | 313 |
| 323 delegate_.reset(); | 314 delegate_.reset(); |
| 324 | 315 |
| 325 // Make sure the channel is closed. | 316 // Make sure the channel is closed. |
| 326 network_channel_.reset(); | 317 network_channel_.reset(); |
| 327 | 318 |
| 328 if (started_) { | 319 if (started_) { |
| 329 started_ = false; | 320 started_ = false; |
| 330 | 321 |
| 331 // Close the disconnect window and stop listening to local input. | |
| 332 disconnect_window_->Hide(); | |
| 333 disconnect_window_.reset(); | |
| 334 | |
| 335 // Ignore any further callbacks. | 322 // Ignore any further callbacks. |
| 336 control_factory_.InvalidateWeakPtrs(); | 323 control_factory_.InvalidateWeakPtrs(); |
| 337 client_jid_.clear(); | 324 client_jid_.clear(); |
| 338 | 325 |
| 339 remote_input_filter_.reset(); | 326 remote_input_filter_.reset(); |
| 340 | 327 |
| 341 // Ensure that any pressed keys or buttons are released. | 328 // Ensure that any pressed keys or buttons are released. |
| 342 input_tracker_->ReleaseAll(); | 329 input_tracker_->ReleaseAll(); |
| 343 input_tracker_.reset(); | 330 input_tracker_.reset(); |
| 344 | 331 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 base::ClosePlatformFile(desktop_pipe_.fd); | 537 base::ClosePlatformFile(desktop_pipe_.fd); |
| 551 #else // !defined(OS_POSIX) | 538 #else // !defined(OS_POSIX) |
| 552 #error Unsupported platform. | 539 #error Unsupported platform. |
| 553 #endif // !defined(OS_POSIX) | 540 #endif // !defined(OS_POSIX) |
| 554 | 541 |
| 555 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 542 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); |
| 556 } | 543 } |
| 557 } | 544 } |
| 558 | 545 |
| 559 } // namespace remoting | 546 } // namespace remoting |
| OLD | NEW |