Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: remoting/host/desktop_session_agent.cc

Issue 2451953002: Use ChannelMojo between the remoting network and desktop processes. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/desktop_session_agent.h ('k') | remoting/host/desktop_session_connector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "ipc/attachment_broker.h"
17 #include "ipc/ipc_channel_proxy.h" 16 #include "ipc/ipc_channel_proxy.h"
18 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
19 #include "ipc/ipc_message_macros.h" 18 #include "ipc/ipc_message_macros.h"
20 #include "remoting/base/auto_thread_task_runner.h" 19 #include "remoting/base/auto_thread_task_runner.h"
21 #include "remoting/base/constants.h" 20 #include "remoting/base/constants.h"
22 #include "remoting/host/audio_capturer.h" 21 #include "remoting/host/audio_capturer.h"
23 #include "remoting/host/chromoting_messages.h" 22 #include "remoting/host/chromoting_messages.h"
24 #include "remoting/host/desktop_environment.h" 23 #include "remoting/host/desktop_environment.h"
25 #include "remoting/host/input_injector.h" 24 #include "remoting/host/input_injector.h"
26 #include "remoting/host/ipc_util.h" 25 #include "remoting/host/ipc_util.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 199 }
201 200
202 CHECK(handled) << "Received unexpected IPC type: " << message.type(); 201 CHECK(handled) << "Received unexpected IPC type: " << message.type();
203 return handled; 202 return handled;
204 } 203 }
205 204
206 void DesktopSessionAgent::OnChannelConnected(int32_t peer_pid) { 205 void DesktopSessionAgent::OnChannelConnected(int32_t peer_pid) {
207 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 206 DCHECK(caller_task_runner_->BelongsToCurrentThread());
208 207
209 VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")"; 208 VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")";
210
211 desktop_pipe_.Close();
212 } 209 }
213 210
214 void DesktopSessionAgent::OnChannelError() { 211 void DesktopSessionAgent::OnChannelError() {
215 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 212 DCHECK(caller_task_runner_->BelongsToCurrentThread());
216 213
217 // Make sure the channel is closed. 214 // Make sure the channel is closed.
218 if (IPC::AttachmentBroker::GetGlobal()) {
219 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
220 network_channel_.get());
221 }
222 network_channel_.reset(); 215 network_channel_.reset();
223 desktop_pipe_.Close();
224 216
225 // Notify the caller that the channel has been disconnected. 217 // Notify the caller that the channel has been disconnected.
226 if (delegate_.get()) 218 if (delegate_.get())
227 delegate_->OnNetworkProcessDisconnected(); 219 delegate_->OnNetworkProcessDisconnected();
228 } 220 }
229 221
230 DesktopSessionAgent::~DesktopSessionAgent() { 222 DesktopSessionAgent::~DesktopSessionAgent() {
231 DCHECK(!audio_capturer_); 223 DCHECK(!audio_capturer_);
232 DCHECK(!desktop_environment_); 224 DCHECK(!desktop_environment_);
233 DCHECK(!network_channel_); 225 DCHECK(!network_channel_);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 std::string serialized_packet; 375 std::string serialized_packet;
384 if (!packet->SerializeToString(&serialized_packet)) { 376 if (!packet->SerializeToString(&serialized_packet)) {
385 LOG(ERROR) << "Failed to serialize AudioPacket."; 377 LOG(ERROR) << "Failed to serialize AudioPacket.";
386 return; 378 return;
387 } 379 }
388 380
389 SendToNetwork(base::MakeUnique<ChromotingDesktopNetworkMsg_AudioPacket>( 381 SendToNetwork(base::MakeUnique<ChromotingDesktopNetworkMsg_AudioPacket>(
390 serialized_packet)); 382 serialized_packet));
391 } 383 }
392 384
393 bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate, 385 mojo::ScopedMessagePipeHandle DesktopSessionAgent::Start(
394 IPC::PlatformFileForTransit* desktop_pipe_out) { 386 const base::WeakPtr<Delegate>& delegate) {
395 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 387 DCHECK(caller_task_runner_->BelongsToCurrentThread());
396 DCHECK(delegate_.get() == nullptr); 388 DCHECK(delegate_.get() == nullptr);
397 389
398 delegate_ = delegate; 390 delegate_ = delegate;
399 391
400 // Create an IPC channel to communicate with the network process. 392 mojo::MessagePipe pipe;
401 bool result = CreateConnectedIpcChannel(io_task_runner_, 393 network_channel_ = IPC::ChannelProxy::Create(
402 this, 394 pipe.handle0.release(), IPC::Channel::MODE_SERVER, this, io_task_runner_);
403 &desktop_pipe_, 395 return std::move(pipe.handle1);
404 &network_channel_);
405 base::PlatformFile raw_desktop_pipe = desktop_pipe_.GetPlatformFile();
406 #if defined(OS_WIN)
407 *desktop_pipe_out =
408 IPC::PlatformFileForTransit(raw_desktop_pipe, base::GetCurrentProcId());
409 #elif defined(OS_POSIX)
410 *desktop_pipe_out = IPC::PlatformFileForTransit(raw_desktop_pipe, false);
411 #else
412 #error Unsupported platform.
413 #endif
414 return result;
415 } 396 }
416 397
417 void DesktopSessionAgent::Stop() { 398 void DesktopSessionAgent::Stop() {
418 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 399 DCHECK(caller_task_runner_->BelongsToCurrentThread());
419 400
420 delegate_.reset(); 401 delegate_.reset();
421 402
422 // Make sure the channel is closed. 403 // Make sure the channel is closed.
423 if (IPC::AttachmentBroker::GetGlobal()) {
424 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
425 network_channel_.get());
426 }
427 network_channel_.reset(); 404 network_channel_.reset();
428 405
429 if (started_) { 406 if (started_) {
430 started_ = false; 407 started_ = false;
431 408
432 // Ignore any further callbacks. 409 // Ignore any further callbacks.
433 weak_factory_.InvalidateWeakPtrs(); 410 weak_factory_.InvalidateWeakPtrs();
434 client_jid_.clear(); 411 client_jid_.clear();
435 412
436 remote_input_filter_.reset(); 413 remote_input_filter_.reset();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 557 }
581 } 558 }
582 559
583 void DesktopSessionAgent::StopAudioCapturer() { 560 void DesktopSessionAgent::StopAudioCapturer() {
584 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread()); 561 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread());
585 562
586 audio_capturer_.reset(); 563 audio_capturer_.reset();
587 } 564 }
588 565
589 } // namespace remoting 566 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_session_agent.h ('k') | remoting/host/desktop_session_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698