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

Side by Side Diff: remoting/host/remoting_me2me_host.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/ipc_util_win.cc ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstdint> 9 #include <cstdint>
10 #include <memory> 10 #include <memory>
(...skipping 10 matching lines...) Expand all
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/run_loop.h" 23 #include "base/run_loop.h"
24 #include "base/single_thread_task_runner.h" 24 #include "base/single_thread_task_runner.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
27 #include "base/strings/stringize_macros.h" 27 #include "base/strings/stringize_macros.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "build/build_config.h" 29 #include "build/build_config.h"
30 #include "components/policy/policy_constants.h" 30 #include "components/policy/policy_constants.h"
31 #include "ipc/attachment_broker_unprivileged.h"
32 #include "ipc/ipc_channel.h" 31 #include "ipc/ipc_channel.h"
33 #include "ipc/ipc_channel_proxy.h" 32 #include "ipc/ipc_channel_proxy.h"
34 #include "ipc/ipc_listener.h" 33 #include "ipc/ipc_listener.h"
35 #include "jingle/glue/thread_wrapper.h" 34 #include "jingle/glue/thread_wrapper.h"
36 #include "mojo/edk/embedder/embedder.h" 35 #include "mojo/edk/embedder/embedder.h"
37 #include "mojo/edk/embedder/platform_channel_pair.h" 36 #include "mojo/edk/embedder/platform_channel_pair.h"
38 #include "mojo/edk/embedder/scoped_ipc_support.h" 37 #include "mojo/edk/embedder/scoped_ipc_support.h"
39 #include "net/base/network_change_notifier.h" 38 #include "net/base/network_change_notifier.h"
40 #include "net/base/url_util.h" 39 #include "net/base/url_util.h"
41 #include "net/socket/client_socket_factory.h" 40 #include "net/socket/client_socket_factory.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // Mojo keeps the task runner passed to it alive forever, so an 461 // Mojo keeps the task runner passed to it alive forever, so an
463 // AutoThreadTaskRunner should not be passed to it. Otherwise, the process may 462 // AutoThreadTaskRunner should not be passed to it. Otherwise, the process may
464 // never shut down cleanly. 463 // never shut down cleanly.
465 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>( 464 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>(
466 context_->network_task_runner()->task_runner()); 465 context_->network_task_runner()->task_runner());
467 mojo::edk::SetParentPipeHandle( 466 mojo::edk::SetParentPipeHandle(
468 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( 467 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess(
469 *cmd_line)); 468 *cmd_line));
470 469
471 // Connect to the daemon process. 470 // Connect to the daemon process.
472 daemon_channel_.reset( 471 daemon_channel_ = IPC::ChannelProxy::Create(
473 new IPC::ChannelProxy(this, context_->network_task_runner())); 472 mojo::edk::CreateChildMessagePipe(
474 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 473 cmd_line->GetSwitchValueASCII(kMojoPipeToken))
475 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 474 .release(),
476 if (broker && !broker->IsPrivilegedBroker()) 475 IPC::Channel::MODE_CLIENT, this, context_->network_task_runner());
477 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
478 daemon_channel_->Init(mojo::edk::CreateChildMessagePipe(
479 cmd_line->GetSwitchValueASCII(kMojoPipeToken))
480 .release(),
481 IPC::Channel::MODE_CLIENT,
482 /*create_pipe_now=*/true);
483 476
484 #else // !defined(REMOTING_MULTI_PROCESS) 477 #else // !defined(REMOTING_MULTI_PROCESS)
485 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 478 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
486 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 479 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
487 480
488 // Read config from stdin if necessary. 481 // Read config from stdin if necessary.
489 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { 482 if (host_config_path_ == base::FilePath(kStdinConfigPath)) {
490 const size_t kBufferSize = 4096; 483 const size_t kBufferSize = 4096;
491 std::unique_ptr<char[]> buf(new char[kBufferSize]); 484 std::unique_ptr<char[]> buf(new char[kBufferSize]);
492 size_t len; 485 size_t len;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 848 }
856 849
857 void HostProcess::ShutdownOnUiThread() { 850 void HostProcess::ShutdownOnUiThread() {
858 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 851 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
859 852
860 // Tear down resources that need to be torn down on the UI thread. 853 // Tear down resources that need to be torn down on the UI thread.
861 desktop_environment_factory_.reset(); 854 desktop_environment_factory_.reset();
862 policy_watcher_.reset(); 855 policy_watcher_.reset();
863 856
864 #if defined(REMOTING_MULTI_PROCESS) 857 #if defined(REMOTING_MULTI_PROCESS)
865 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
866 if (broker && !broker->IsPrivilegedBroker()) {
867 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get());
868 }
869 daemon_channel_.reset(); 858 daemon_channel_.reset();
870 #endif // defined(REMOTING_MULTI_PROCESS) 859 #endif // defined(REMOTING_MULTI_PROCESS)
871 860
872 // It is now safe for the HostProcess to be deleted. 861 // It is now safe for the HostProcess to be deleted.
873 self_ = nullptr; 862 self_ = nullptr;
874 863
875 #if defined(OS_LINUX) 864 #if defined(OS_LINUX)
876 // Cause the global AudioPipeReader to be freed, otherwise the audio 865 // Cause the global AudioPipeReader to be freed, otherwise the audio
877 // thread will remain in-use and prevent the process from exiting. 866 // thread will remain in-use and prevent the process from exiting.
878 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. 867 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader.
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1646 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1658 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); 1647 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1659 1648
1660 // Run the main (also UI) message loop until the host no longer needs it. 1649 // Run the main (also UI) message loop until the host no longer needs it.
1661 base::RunLoop().Run(); 1650 base::RunLoop().Run();
1662 1651
1663 return exit_code; 1652 return exit_code;
1664 } 1653 }
1665 1654
1666 } // namespace remoting 1655 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/ipc_util_win.cc ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698