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

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

Issue 2424353002: Use ChannelMojo between the remoting daemon and network processes. (Closed)
Patch Set: sans test changes 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/host_main.cc ('k') | remoting/host/switches.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 // 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 15 matching lines...) Expand all
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" 31 #include "ipc/attachment_broker_unprivileged.h"
32 #include "ipc/ipc_channel.h" 32 #include "ipc/ipc_channel.h"
33 #include "ipc/ipc_channel_proxy.h" 33 #include "ipc/ipc_channel_proxy.h"
34 #include "ipc/ipc_listener.h" 34 #include "ipc/ipc_listener.h"
35 #include "jingle/glue/thread_wrapper.h" 35 #include "jingle/glue/thread_wrapper.h"
36 #include "mojo/edk/embedder/embedder.h"
37 #include "mojo/edk/embedder/platform_channel_pair.h"
38 #include "mojo/edk/embedder/scoped_ipc_support.h"
36 #include "net/base/network_change_notifier.h" 39 #include "net/base/network_change_notifier.h"
37 #include "net/base/url_util.h" 40 #include "net/base/url_util.h"
38 #include "net/socket/client_socket_factory.h" 41 #include "net/socket/client_socket_factory.h"
39 #include "net/url_request/url_fetcher.h" 42 #include "net/url_request/url_fetcher.h"
40 #include "remoting/base/auto_thread_task_runner.h" 43 #include "remoting/base/auto_thread_task_runner.h"
41 #include "remoting/base/breakpad.h" 44 #include "remoting/base/breakpad.h"
42 #include "remoting/base/chromium_url_request.h" 45 #include "remoting/base/chromium_url_request.h"
43 #include "remoting/base/constants.h" 46 #include "remoting/base/constants.h"
44 #include "remoting/base/logging.h" 47 #include "remoting/base/logging.h"
45 #include "remoting/base/rsa_key_pair.h" 48 #include "remoting/base/rsa_key_pair.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 std::unique_ptr<HostStatusLogger> host_status_logger_; 406 std::unique_ptr<HostStatusLogger> host_status_logger_;
404 std::unique_ptr<HostEventLogger> host_event_logger_; 407 std::unique_ptr<HostEventLogger> host_event_logger_;
405 std::unique_ptr<HostPowerSaveBlocker> power_save_blocker_; 408 std::unique_ptr<HostPowerSaveBlocker> power_save_blocker_;
406 409
407 std::unique_ptr<ChromotingHost> host_; 410 std::unique_ptr<ChromotingHost> host_;
408 411
409 // Used to keep this HostProcess alive until it is shutdown. 412 // Used to keep this HostProcess alive until it is shutdown.
410 scoped_refptr<HostProcess> self_; 413 scoped_refptr<HostProcess> self_;
411 414
412 #if defined(REMOTING_MULTI_PROCESS) 415 #if defined(REMOTING_MULTI_PROCESS)
416 std::unique_ptr<mojo::edk::ScopedIPCSupport> ipc_support_;
417
413 // Accessed on the UI thread. 418 // Accessed on the UI thread.
414 std::unique_ptr<IPC::ChannelProxy> daemon_channel_; 419 std::unique_ptr<IPC::ChannelProxy> daemon_channel_;
415 420
416 // Owned as |desktop_environment_factory_|. 421 // Owned as |desktop_environment_factory_|.
417 DesktopSessionConnector* desktop_session_connector_ = nullptr; 422 DesktopSessionConnector* desktop_session_connector_ = nullptr;
418 #endif // defined(REMOTING_MULTI_PROCESS) 423 #endif // defined(REMOTING_MULTI_PROCESS)
419 424
420 int* exit_code_out_; 425 int* exit_code_out_;
421 bool signal_parent_ = false; 426 bool signal_parent_ = false;
422 427
(...skipping 24 matching lines...) Expand all
447 // threads it contains. This will go away when we move to AutoThread. 452 // threads it contains. This will go away when we move to AutoThread.
448 // |context_release()| will null |context_| before the method is invoked, so 453 // |context_release()| will null |context_| before the method is invoked, so
449 // we need to pull out the task-runner on which to call DeleteSoon first. 454 // we need to pull out the task-runner on which to call DeleteSoon first.
450 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 455 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
451 context_->ui_task_runner(); 456 context_->ui_task_runner();
452 task_runner->DeleteSoon(FROM_HERE, context_.release()); 457 task_runner->DeleteSoon(FROM_HERE, context_.release());
453 } 458 }
454 459
455 bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) { 460 bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
456 #if defined(REMOTING_MULTI_PROCESS) 461 #if defined(REMOTING_MULTI_PROCESS)
457 // Parse the handle value and convert it to a handle/file descriptor. 462 // Mojo keeps the task runner passed to it alive forever, so an
458 std::string channel_name = 463 // AutoThreadTaskRunner should not be passed to it. Otherwise, the process may
459 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName); 464 // never shut down cleanly.
460 465 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>(
461 int pipe_handle = 0; 466 context_->network_task_runner()->task_runner());
462 if (channel_name.empty() || 467 mojo::edk::SetParentPipeHandle(
463 !base::StringToInt(channel_name, &pipe_handle)) { 468 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess(
464 LOG(ERROR) << "Invalid '" << kDaemonPipeSwitchName 469 *cmd_line));
465 << "' value: " << channel_name;
466 return false;
467 }
468
469 #if defined(OS_WIN)
470 base::win::ScopedHandle pipe(reinterpret_cast<HANDLE>(pipe_handle));
471 IPC::ChannelHandle channel_handle(pipe.Get());
472 #elif defined(OS_POSIX)
473 base::FileDescriptor pipe(pipe_handle, true);
474 IPC::ChannelHandle channel_handle(channel_name, pipe);
475 #endif // defined(OS_POSIX)
476 470
477 // Connect to the daemon process. 471 // Connect to the daemon process.
478 daemon_channel_.reset( 472 daemon_channel_.reset(
479 new IPC::ChannelProxy(this, context_->network_task_runner())); 473 new IPC::ChannelProxy(this, context_->network_task_runner()));
480 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 474 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
481 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 475 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
482 if (broker && !broker->IsPrivilegedBroker()) 476 if (broker && !broker->IsPrivilegedBroker())
483 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); 477 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
484 daemon_channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, 478 daemon_channel_->Init(mojo::edk::CreateChildMessagePipe(
479 cmd_line->GetSwitchValueASCII(kMojoPipeToken))
480 .release(),
481 IPC::Channel::MODE_CLIENT,
485 /*create_pipe_now=*/true); 482 /*create_pipe_now=*/true);
486 483
487 #else // !defined(REMOTING_MULTI_PROCESS) 484 #else // !defined(REMOTING_MULTI_PROCESS)
488 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 485 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
489 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 486 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
490 487
491 // Read config from stdin if necessary. 488 // Read config from stdin if necessary.
492 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { 489 if (host_config_path_ == base::FilePath(kStdinConfigPath)) {
493 const size_t kBufferSize = 4096; 490 const size_t kBufferSize = 4096;
494 std::unique_ptr<char[]> buf(new char[kBufferSize]); 491 std::unique_ptr<char[]> buf(new char[kBufferSize]);
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1659 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1663 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); 1660 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1664 1661
1665 // Run the main (also UI) message loop until the host no longer needs it. 1662 // Run the main (also UI) message loop until the host no longer needs it.
1666 base::RunLoop().Run(); 1663 base::RunLoop().Run();
1667 1664
1668 return exit_code; 1665 return exit_code;
1669 } 1666 }
1670 1667
1671 } // namespace remoting 1668 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_main.cc ('k') | remoting/host/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698