| 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/logging.h" | 8 #include "base/logging.h" | 
| 8 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" | 
| 9 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" | 
| 10 #include "ipc/ipc_message_macros.h" | 11 #include "ipc/ipc_message_macros.h" | 
| 11 #include "media/video/capture/screen/screen_capture_data.h" | 12 #include "media/video/capture/screen/screen_capture_data.h" | 
| 12 #include "remoting/base/auto_thread_task_runner.h" | 13 #include "remoting/base/auto_thread_task_runner.h" | 
| 13 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" | 
| 14 #include "remoting/base/util.h" | 15 #include "remoting/base/util.h" | 
| 15 #include "remoting/host/audio_capturer.h" | 16 #include "remoting/host/audio_capturer.h" | 
| 16 #include "remoting/host/chromoting_messages.h" | 17 #include "remoting/host/chromoting_messages.h" | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 69 | 70 | 
| 70 DesktopSessionAgent::Delegate::~Delegate() { | 71 DesktopSessionAgent::Delegate::~Delegate() { | 
| 71 } | 72 } | 
| 72 | 73 | 
| 73 DesktopSessionAgent::~DesktopSessionAgent() { | 74 DesktopSessionAgent::~DesktopSessionAgent() { | 
| 74   DCHECK(!audio_capturer_); | 75   DCHECK(!audio_capturer_); | 
| 75   DCHECK(!disconnect_window_); | 76   DCHECK(!disconnect_window_); | 
| 76   DCHECK(!local_input_monitor_); | 77   DCHECK(!local_input_monitor_); | 
| 77   DCHECK(!network_channel_); | 78   DCHECK(!network_channel_); | 
| 78   DCHECK(!video_capturer_); | 79   DCHECK(!video_capturer_); | 
|  | 80 | 
|  | 81   CloseDesktopPipeHandle(); | 
| 79 } | 82 } | 
| 80 | 83 | 
| 81 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { | 84 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { | 
| 82   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 85   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 83 | 86 | 
| 84   bool handled = true; | 87   bool handled = true; | 
| 85   if (started_) { | 88   if (started_) { | 
| 86     IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message) | 89     IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message) | 
| 87       IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame, | 90       IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame, | 
| 88                           OnCaptureFrame) | 91                           OnCaptureFrame) | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 112     OnChannelError(); | 115     OnChannelError(); | 
| 113   } | 116   } | 
| 114 | 117 | 
| 115   return handled; | 118   return handled; | 
| 116 } | 119 } | 
| 117 | 120 | 
| 118 void DesktopSessionAgent::OnChannelConnected(int32 peer_pid) { | 121 void DesktopSessionAgent::OnChannelConnected(int32 peer_pid) { | 
| 119   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 122   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 120 | 123 | 
| 121   VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")"; | 124   VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")"; | 
|  | 125 | 
|  | 126   CloseDesktopPipeHandle(); | 
| 122 } | 127 } | 
| 123 | 128 | 
| 124 void DesktopSessionAgent::OnChannelError() { | 129 void DesktopSessionAgent::OnChannelError() { | 
| 125   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 130   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 126 | 131 | 
| 127   // Make sure the channel is closed. | 132   // Make sure the channel is closed. | 
| 128   network_channel_.reset(); | 133   network_channel_.reset(); | 
|  | 134   CloseDesktopPipeHandle(); | 
| 129 | 135 | 
| 130   // Notify the caller that the channel has been disconnected. | 136   // Notify the caller that the channel has been disconnected. | 
| 131   if (delegate_.get()) | 137   if (delegate_.get()) | 
| 132     delegate_->OnNetworkProcessDisconnected(); | 138     delegate_->OnNetworkProcessDisconnected(); | 
| 133 } | 139 } | 
| 134 | 140 | 
| 135 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { | 141 void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { | 
| 136   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 142   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 137 | 143 | 
| 138   remote_input_filter_->LocalMouseMoved(new_pos); | 144   remote_input_filter_->LocalMouseMoved(new_pos); | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 286 } | 292 } | 
| 287 | 293 | 
| 288 bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate, | 294 bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate, | 
| 289                                 IPC::PlatformFileForTransit* desktop_pipe_out) { | 295                                 IPC::PlatformFileForTransit* desktop_pipe_out) { | 
| 290   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 296   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 291   DCHECK(delegate_.get() == NULL); | 297   DCHECK(delegate_.get() == NULL); | 
| 292 | 298 | 
| 293   delegate_ = delegate; | 299   delegate_ = delegate; | 
| 294 | 300 | 
| 295   // Create an IPC channel to communicate with the network process. | 301   // Create an IPC channel to communicate with the network process. | 
| 296   return CreateChannelForNetworkProcess(desktop_pipe_out, &network_channel_); | 302   bool result = CreateChannelForNetworkProcess(&desktop_pipe_, | 
|  | 303                                                &network_channel_); | 
|  | 304   *desktop_pipe_out = desktop_pipe_; | 
|  | 305   return result; | 
| 297 } | 306 } | 
| 298 | 307 | 
| 299 void DesktopSessionAgent::Stop() { | 308 void DesktopSessionAgent::Stop() { | 
| 300   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 309   DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 
| 301 | 310 | 
| 302   delegate_.reset(); | 311   delegate_.reset(); | 
| 303 | 312 | 
| 304   // Make sure the channel is closed. | 313   // Make sure the channel is closed. | 
| 305   network_channel_.reset(); | 314   network_channel_.reset(); | 
| 306 | 315 | 
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 521     scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, | 530     scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, | 
| 522     scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 531     scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 
| 523     scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 532     scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 
| 524     scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 533     scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 
| 525     scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) | 534     scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) | 
| 526     : audio_capture_task_runner_(audio_capture_task_runner), | 535     : audio_capture_task_runner_(audio_capture_task_runner), | 
| 527       caller_task_runner_(caller_task_runner), | 536       caller_task_runner_(caller_task_runner), | 
| 528       input_task_runner_(input_task_runner), | 537       input_task_runner_(input_task_runner), | 
| 529       io_task_runner_(io_task_runner), | 538       io_task_runner_(io_task_runner), | 
| 530       video_capture_task_runner_(video_capture_task_runner), | 539       video_capture_task_runner_(video_capture_task_runner), | 
|  | 540       desktop_pipe_(IPC::InvalidPlatformFileForTransit()), | 
| 531       current_size_(SkISize::Make(0, 0)), | 541       current_size_(SkISize::Make(0, 0)), | 
| 532       next_shared_buffer_id_(1), | 542       next_shared_buffer_id_(1), | 
| 533       started_(false) { | 543       started_(false) { | 
| 534   DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 544   DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 
| 535 } | 545 } | 
| 536 | 546 | 
|  | 547 void DesktopSessionAgent::CloseDesktopPipeHandle() { | 
|  | 548   if (!(desktop_pipe_ == IPC::InvalidPlatformFileForTransit())) { | 
|  | 549 #if defined(OS_WIN) | 
|  | 550     base::ClosePlatformFile(desktop_pipe_); | 
|  | 551 #elif defined(OS_POSIX) | 
|  | 552     base::ClosePlatformFile(desktop_pipe_.fd); | 
|  | 553 #else  // !defined(OS_POSIX) | 
|  | 554 #error Unsupported platform. | 
|  | 555 #endif  // !defined(OS_POSIX) | 
|  | 556 | 
|  | 557     desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); | 
|  | 558   } | 
|  | 559 } | 
|  | 560 | 
| 537 }  // namespace remoting | 561 }  // namespace remoting | 
| OLD | NEW | 
|---|