diff options
author | erikchen <erikchen@chromium.org> | 2015-07-28 16:25:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-28 23:26:31 +0000 |
commit | 484c0084e981f9bb1e43757ae2686dd4e8c6205d (patch) | |
tree | a4e69b7978aca54a3e62f0751179702c967eae1f /ipc/attachment_broker_privileged.cc | |
parent | 8acd84d5ea91a2f23e3124f0be69f4f3bf024767 (diff) | |
download | chromium_src-484c0084e981f9bb1e43757ae2686dd4e8c6205d.zip chromium_src-484c0084e981f9bb1e43757ae2686dd4e8c6205d.tar.gz chromium_src-484c0084e981f9bb1e43757ae2686dd4e8c6205d.tar.bz2 |
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}
Diffstat (limited to 'ipc/attachment_broker_privileged.cc')
-rw-r--r-- | ipc/attachment_broker_privileged.cc | 40 |
1 files changed, 40 insertions, 0 deletions
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 <algorithm> + +#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 |