summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2016-02-16 14:00:54 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-16 22:02:46 +0000
commit11fea2242b3a197993dbd5a1f977f9a31c6b98e4 (patch)
treea01c485ee5e08742566c48221cf9855940e72738 /remoting/host
parent11afb324fa322a3d651124f3ca244c9595f84768 (diff)
downloadchromium_src-11fea2242b3a197993dbd5a1f977f9a31c6b98e4.zip
chromium_src-11fea2242b3a197993dbd5a1f977f9a31c6b98e4.tar.gz
chromium_src-11fea2242b3a197993dbd5a1f977f9a31c6b98e4.tar.bz2
Clean up public interface of AttachmentBrokerUnprivileged.
In the old interface, a static factory method returns a scoped_ptr, and the caller had to manage the lifetime. Since this is a global object with minimal memory footprint, and is required to outlive every IPC::Channel, it's much easier for the global to never be destroyed. This also matches the interface for AttachmentBrokerPrivileged. BUG=584297 Review URL: https://codereview.chromium.org/1679763002 Cr-Commit-Position: refs/heads/master@{#375674}
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/desktop_process.cc15
-rw-r--r--remoting/host/desktop_process.h4
-rw-r--r--remoting/host/remoting_me2me_host.cc16
3 files changed, 14 insertions, 21 deletions
diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc
index b0afa8e..e59b8a5 100644
--- a/remoting/host/desktop_process.cc
+++ b/remoting/host/desktop_process.cc
@@ -82,6 +82,9 @@ void DesktopProcess::OnChannelConnected(int32_t peer_pid) {
void DesktopProcess::OnChannelError() {
// Shutdown the desktop process.
+ IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
+ if (broker && !broker->IsPrivilegedBroker())
+ broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get());
daemon_channel_.reset();
if (desktop_agent_.get()) {
desktop_agent_->Stop();
@@ -141,14 +144,10 @@ bool DesktopProcess::Start(
IPC::ChannelProxy::Create(daemon_channel_name_, IPC::Channel::MODE_CLIENT,
this, io_task_runner.get());
- // Attachment broker may be already created in tests.
- if (!IPC::AttachmentBroker::GetGlobal())
- attachment_broker_ = IPC::AttachmentBrokerUnprivileged::CreateBroker();
-
- if (attachment_broker_) {
- attachment_broker_->DesignateBrokerCommunicationChannel(
- daemon_channel_.get());
- }
+ IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
+ IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
+ if (broker && !broker->IsPrivilegedBroker())
+ broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
// Pass |desktop_pipe| to the daemon.
daemon_channel_->Send(
diff --git a/remoting/host/desktop_process.h b/remoting/host/desktop_process.h
index e085c6a..4246724 100644
--- a/remoting/host/desktop_process.h
+++ b/remoting/host/desktop_process.h
@@ -19,7 +19,6 @@
#include "remoting/host/desktop_session_agent.h"
namespace IPC {
-class AttachmentBrokerUnprivileged;
class ChannelProxy;
} // namespace IPC
@@ -77,9 +76,6 @@ class DesktopProcess : public DesktopSessionAgent::Delegate,
// process.
std::string daemon_channel_name_;
- // Attachment broker for |daemon_channel_|.
- scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
-
// IPC channel connecting the desktop process with the daemon process.
scoped_ptr<IPC::ChannelProxy> daemon_channel_;
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index a80ef55..9004846 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -461,9 +461,6 @@ class HostProcess : public ConfigWatcher::Delegate,
// Accessed on the UI thread.
scoped_ptr<IPC::ChannelProxy> daemon_channel_;
- // AttachmentBroker for |daemon_channel_|.
- scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
-
// Owned as |desktop_environment_factory_|.
DesktopSessionConnector* desktop_session_connector_ = nullptr;
#endif // defined(REMOTING_MULTI_PROCESS)
@@ -545,11 +542,10 @@ bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
this,
context_->network_task_runner());
- attachment_broker_ = IPC::AttachmentBrokerUnprivileged::CreateBroker();
- if (attachment_broker_) {
- attachment_broker_->DesignateBrokerCommunicationChannel(
- daemon_channel_.get());
- }
+ IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
+ IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
+ if (broker && !broker->IsPrivilegedBroker())
+ broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
#else // !defined(REMOTING_MULTI_PROCESS)
if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
@@ -931,7 +927,9 @@ void HostProcess::ShutdownOnUiThread() {
policy_watcher_.reset();
#if defined(REMOTING_MULTI_PROCESS)
- attachment_broker_.reset();
+ IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
+ if (broker && !broker->IsPrivilegedBroker())
+ broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get());
daemon_channel_.reset();
#endif // defined(REMOTING_MULTI_PROCESS)