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