| 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 // 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 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 454 |
| 455 scoped_ptr<ChromotingHost> host_; | 455 scoped_ptr<ChromotingHost> host_; |
| 456 | 456 |
| 457 // Used to keep this HostProcess alive until it is shutdown. | 457 // Used to keep this HostProcess alive until it is shutdown. |
| 458 scoped_refptr<HostProcess> self_; | 458 scoped_refptr<HostProcess> self_; |
| 459 | 459 |
| 460 #if defined(REMOTING_MULTI_PROCESS) | 460 #if defined(REMOTING_MULTI_PROCESS) |
| 461 // Accessed on the UI thread. | 461 // Accessed on the UI thread. |
| 462 scoped_ptr<IPC::ChannelProxy> daemon_channel_; | 462 scoped_ptr<IPC::ChannelProxy> daemon_channel_; |
| 463 | 463 |
| 464 // AttachmentBroker for |daemon_channel_|. | |
| 465 scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_; | |
| 466 | |
| 467 // Owned as |desktop_environment_factory_|. | 464 // Owned as |desktop_environment_factory_|. |
| 468 DesktopSessionConnector* desktop_session_connector_ = nullptr; | 465 DesktopSessionConnector* desktop_session_connector_ = nullptr; |
| 469 #endif // defined(REMOTING_MULTI_PROCESS) | 466 #endif // defined(REMOTING_MULTI_PROCESS) |
| 470 | 467 |
| 471 int* exit_code_out_; | 468 int* exit_code_out_; |
| 472 bool signal_parent_; | 469 bool signal_parent_; |
| 473 | 470 |
| 474 scoped_refptr<PairingRegistry> pairing_registry_; | 471 scoped_refptr<PairingRegistry> pairing_registry_; |
| 475 | 472 |
| 476 ShutdownWatchdog* shutdown_watchdog_; | 473 ShutdownWatchdog* shutdown_watchdog_; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 base::FileDescriptor pipe(pipe_handle, true); | 535 base::FileDescriptor pipe(pipe_handle, true); |
| 539 IPC::ChannelHandle channel_handle(channel_name, pipe); | 536 IPC::ChannelHandle channel_handle(channel_name, pipe); |
| 540 #endif // defined(OS_POSIX) | 537 #endif // defined(OS_POSIX) |
| 541 | 538 |
| 542 // Connect to the daemon process. | 539 // Connect to the daemon process. |
| 543 daemon_channel_ = IPC::ChannelProxy::Create(channel_handle, | 540 daemon_channel_ = IPC::ChannelProxy::Create(channel_handle, |
| 544 IPC::Channel::MODE_CLIENT, | 541 IPC::Channel::MODE_CLIENT, |
| 545 this, | 542 this, |
| 546 context_->network_task_runner()); | 543 context_->network_task_runner()); |
| 547 | 544 |
| 548 attachment_broker_ = IPC::AttachmentBrokerUnprivileged::CreateBroker(); | 545 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); |
| 549 if (attachment_broker_) { | 546 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); |
| 550 attachment_broker_->DesignateBrokerCommunicationChannel( | 547 if (broker && !broker->IsPrivilegedBroker()) |
| 551 daemon_channel_.get()); | 548 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); |
| 552 } | |
| 553 | 549 |
| 554 #else // !defined(REMOTING_MULTI_PROCESS) | 550 #else // !defined(REMOTING_MULTI_PROCESS) |
| 555 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { | 551 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { |
| 556 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); | 552 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); |
| 557 | 553 |
| 558 // Read config from stdin if necessary. | 554 // Read config from stdin if necessary. |
| 559 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { | 555 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { |
| 560 const size_t kBufferSize = 4096; | 556 const size_t kBufferSize = 4096; |
| 561 scoped_ptr<char[]> buf(new char[kBufferSize]); | 557 scoped_ptr<char[]> buf(new char[kBufferSize]); |
| 562 size_t len; | 558 size_t len; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 } | 920 } |
| 925 | 921 |
| 926 void HostProcess::ShutdownOnUiThread() { | 922 void HostProcess::ShutdownOnUiThread() { |
| 927 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 923 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 928 | 924 |
| 929 // Tear down resources that need to be torn down on the UI thread. | 925 // Tear down resources that need to be torn down on the UI thread. |
| 930 desktop_environment_factory_.reset(); | 926 desktop_environment_factory_.reset(); |
| 931 policy_watcher_.reset(); | 927 policy_watcher_.reset(); |
| 932 | 928 |
| 933 #if defined(REMOTING_MULTI_PROCESS) | 929 #if defined(REMOTING_MULTI_PROCESS) |
| 934 attachment_broker_.reset(); | 930 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); |
| 931 if (broker && !broker->IsPrivilegedBroker()) |
| 932 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get()); |
| 935 daemon_channel_.reset(); | 933 daemon_channel_.reset(); |
| 936 #endif // defined(REMOTING_MULTI_PROCESS) | 934 #endif // defined(REMOTING_MULTI_PROCESS) |
| 937 | 935 |
| 938 // It is now safe for the HostProcess to be deleted. | 936 // It is now safe for the HostProcess to be deleted. |
| 939 self_ = nullptr; | 937 self_ = nullptr; |
| 940 | 938 |
| 941 #if defined(OS_LINUX) | 939 #if defined(OS_LINUX) |
| 942 // Cause the global AudioPipeReader to be freed, otherwise the audio | 940 // Cause the global AudioPipeReader to be freed, otherwise the audio |
| 943 // thread will remain in-use and prevent the process from exiting. | 941 // thread will remain in-use and prevent the process from exiting. |
| 944 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. | 942 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1739 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
| 1742 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); | 1740 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); |
| 1743 | 1741 |
| 1744 // Run the main (also UI) message loop until the host no longer needs it. | 1742 // Run the main (also UI) message loop until the host no longer needs it. |
| 1745 message_loop.Run(); | 1743 message_loop.Run(); |
| 1746 | 1744 |
| 1747 return exit_code; | 1745 return exit_code; |
| 1748 } | 1746 } |
| 1749 | 1747 |
| 1750 } // namespace remoting | 1748 } // namespace remoting |
| OLD | NEW |