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

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

Issue 2424353002: Use ChannelMojo between the remoting daemon and network processes. (Closed)
Patch Set: Created 4 years, 2 months 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
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 holds onto the task runner forever so ignore it when deciding when to
458 std::string channel_name = 463 // shut down.
joedow 2016/10/20 17:40:04 Copy/paste comment from the other class, is there
Sam McNally 2016/10/20 22:40:22 Done.
459 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName); 464 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>(
460 465 context_->network_task_runner()->underlying_task_runner());
461 int pipe_handle = 0; 466 mojo::edk::SetParentPipeHandle(
462 if (channel_name.empty() || 467 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess(
463 !base::StringToInt(channel_name, &pipe_handle)) { 468 *cmd_line));
464 LOG(ERROR) << "Invalid '" << kDaemonPipeSwitchName
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 469
477 // Connect to the daemon process. 470 // Connect to the daemon process.
478 daemon_channel_.reset( 471 daemon_channel_.reset(
479 new IPC::ChannelProxy(this, context_->network_task_runner())); 472 new IPC::ChannelProxy(this, context_->network_task_runner()));
480 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 473 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
481 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 474 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
482 if (broker && !broker->IsPrivilegedBroker()) 475 if (broker && !broker->IsPrivilegedBroker())
483 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); 476 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
484 daemon_channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, 477 daemon_channel_->Init(mojo::edk::CreateChildMessagePipe(
478 cmd_line->GetSwitchValueASCII(kMojoPipeToken))
479 .release(),
480 IPC::Channel::MODE_CLIENT,
485 /*create_pipe_now=*/true); 481 /*create_pipe_now=*/true);
486 482
487 #else // !defined(REMOTING_MULTI_PROCESS) 483 #else // !defined(REMOTING_MULTI_PROCESS)
488 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 484 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
489 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 485 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
490 486
491 // Read config from stdin if necessary. 487 // Read config from stdin if necessary.
492 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { 488 if (host_config_path_ == base::FilePath(kStdinConfigPath)) {
493 const size_t kBufferSize = 4096; 489 const size_t kBufferSize = 4096;
494 std::unique_ptr<char[]> buf(new char[kBufferSize]); 490 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)); 1658 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1663 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); 1659 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1664 1660
1665 // Run the main (also UI) message loop until the host no longer needs it. 1661 // Run the main (also UI) message loop until the host no longer needs it.
1666 base::RunLoop().Run(); 1662 base::RunLoop().Run();
1667 1663
1668 return exit_code; 1664 return exit_code;
1669 } 1665 }
1670 1666
1671 } // namespace remoting 1667 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698