| 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 <memory> | 10 #include <memory> |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 IPC::ChannelHandle channel_handle(channel_name, pipe); | 472 IPC::ChannelHandle channel_handle(channel_name, pipe); |
| 473 #endif // defined(OS_POSIX) | 473 #endif // defined(OS_POSIX) |
| 474 | 474 |
| 475 // Connect to the daemon process. | 475 // Connect to the daemon process. |
| 476 daemon_channel_.reset( | 476 daemon_channel_.reset( |
| 477 new IPC::ChannelProxy(this, context_->network_task_runner())); | 477 new IPC::ChannelProxy(this, context_->network_task_runner())); |
| 478 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); | 478 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); |
| 479 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); | 479 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); |
| 480 if (broker && !broker->IsPrivilegedBroker()) | 480 if (broker && !broker->IsPrivilegedBroker()) |
| 481 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); | 481 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); |
| 482 daemon_channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, true); | 482 daemon_channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, |
| 483 /*create_pipe_now=*/true); |
| 483 | 484 |
| 484 #else // !defined(REMOTING_MULTI_PROCESS) | 485 #else // !defined(REMOTING_MULTI_PROCESS) |
| 485 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { | 486 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { |
| 486 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); | 487 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); |
| 487 | 488 |
| 488 // Read config from stdin if necessary. | 489 // Read config from stdin if necessary. |
| 489 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { | 490 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { |
| 490 const size_t kBufferSize = 4096; | 491 const size_t kBufferSize = 4096; |
| 491 std::unique_ptr<char[]> buf(new char[kBufferSize]); | 492 std::unique_ptr<char[]> buf(new char[kBufferSize]); |
| 492 size_t len; | 493 size_t len; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 854 |
| 854 void HostProcess::ShutdownOnUiThread() { | 855 void HostProcess::ShutdownOnUiThread() { |
| 855 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 856 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 856 | 857 |
| 857 // Tear down resources that need to be torn down on the UI thread. | 858 // Tear down resources that need to be torn down on the UI thread. |
| 858 desktop_environment_factory_.reset(); | 859 desktop_environment_factory_.reset(); |
| 859 policy_watcher_.reset(); | 860 policy_watcher_.reset(); |
| 860 | 861 |
| 861 #if defined(REMOTING_MULTI_PROCESS) | 862 #if defined(REMOTING_MULTI_PROCESS) |
| 862 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); | 863 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); |
| 863 if (broker && !broker->IsPrivilegedBroker()) | 864 if (broker && !broker->IsPrivilegedBroker()) { |
| 864 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get()); | 865 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get()); |
| 866 } |
| 865 daemon_channel_.reset(); | 867 daemon_channel_.reset(); |
| 866 #endif // defined(REMOTING_MULTI_PROCESS) | 868 #endif // defined(REMOTING_MULTI_PROCESS) |
| 867 | 869 |
| 868 // It is now safe for the HostProcess to be deleted. | 870 // It is now safe for the HostProcess to be deleted. |
| 869 self_ = nullptr; | 871 self_ = nullptr; |
| 870 | 872 |
| 871 #if defined(OS_LINUX) | 873 #if defined(OS_LINUX) |
| 872 // Cause the global AudioPipeReader to be freed, otherwise the audio | 874 // Cause the global AudioPipeReader to be freed, otherwise the audio |
| 873 // thread will remain in-use and prevent the process from exiting. | 875 // thread will remain in-use and prevent the process from exiting. |
| 874 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. | 876 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1652 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
| 1651 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); | 1653 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); |
| 1652 | 1654 |
| 1653 // Run the main (also UI) message loop until the host no longer needs it. | 1655 // Run the main (also UI) message loop until the host no longer needs it. |
| 1654 message_loop.Run(); | 1656 message_loop.Run(); |
| 1655 | 1657 |
| 1656 return exit_code; | 1658 return exit_code; |
| 1657 } | 1659 } |
| 1658 | 1660 |
| 1659 } // namespace remoting | 1661 } // namespace remoting |
| OLD | NEW |