From 484c0084e981f9bb1e43757ae2686dd4e8c6205d Mon Sep 17 00:00:00 2001 From: erikchen Date: Tue, 28 Jul 2015 16:25:44 -0700 Subject: ipc: Create AttachmentBrokerPrivileged and AttachmentBrokerUnprivileged. This CL is a refactor and contains no behavior changes. AttachmentBroker is an abstract base class. I made two new abstract subclasses, AttachmentBrokerPrivileged and AttachmentBrokerUnprivileged for use in privileged and unprivileged processes respectively. These in turn are inherited by AttachmentBrokerPrivilegedWin and AttachmentBrokerUnprivilegedWin. BUG=493414 TBR=avi@chromium.org Review URL: https://codereview.chromium.org/1256993003 Cr-Commit-Position: refs/heads/master@{#340803} --- ipc/attachment_broker_privileged.cc | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ipc/attachment_broker_privileged.cc (limited to 'ipc/attachment_broker_privileged.cc') diff --git a/ipc/attachment_broker_privileged.cc b/ipc/attachment_broker_privileged.cc new file mode 100644 index 0000000..d2b6832 --- /dev/null +++ b/ipc/attachment_broker_privileged.cc @@ -0,0 +1,40 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ipc/attachment_broker_privileged.h" + +#include + +#include "ipc/ipc_channel.h" + +namespace IPC { + +AttachmentBrokerPrivileged::AttachmentBrokerPrivileged() {} + +AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {} + +void AttachmentBrokerPrivileged::RegisterCommunicationChannel( + Channel* channel) { + auto it = std::find(channels_.begin(), channels_.end(), channel); + DCHECK(channels_.end() == it); + channels_.push_back(channel); +} + +void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( + Channel* channel) { + auto it = std::find(channels_.begin(), channels_.end(), channel); + if (it != channels_.end()) + channels_.erase(it); +} + +Channel* AttachmentBrokerPrivileged::GetChannelWithProcessId( + base::ProcessId id) { + auto it = std::find_if(channels_.begin(), channels_.end(), + [id](Channel* c) { return c->GetPeerPID() == id; }); + if (it == channels_.end()) + return nullptr; + return *it; +} + +} // namespace IPC -- cgit v1.1