Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ipc / attachment_broker_privileged.cc
blobda62ac0c06e87fd5f1d7d050c021cfe039f6408f
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ipc/attachment_broker_privileged.h"
7 #include <algorithm>
9 #include "ipc/ipc_endpoint.h"
11 namespace IPC {
13 AttachmentBrokerPrivileged::AttachmentBrokerPrivileged() {}
15 AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {}
17 void AttachmentBrokerPrivileged::RegisterCommunicationChannel(
18 Endpoint* endpoint) {
19 endpoint->SetAttachmentBrokerEndpoint(true);
20 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
21 DCHECK(endpoints_.end() == it);
22 endpoints_.push_back(endpoint);
25 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel(
26 Endpoint* endpoint) {
27 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
28 if (it != endpoints_.end())
29 endpoints_.erase(it);
32 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) {
33 auto it = std::find_if(endpoints_.begin(), endpoints_.end(),
34 [id](Endpoint* c) { return c->GetPeerPID() == id; });
35 if (it == endpoints_.end())
36 return nullptr;
37 return *it;
40 } // namespace IPC