OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "ipc/attachment_broker_privileged.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "ipc/ipc_channel.h" |
| 10 |
| 11 namespace IPC { |
| 12 |
| 13 AttachmentBrokerPrivileged::AttachmentBrokerPrivileged() {} |
| 14 |
| 15 AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {} |
| 16 |
| 17 void AttachmentBrokerPrivileged::RegisterCommunicationChannel( |
| 18 Channel* channel) { |
| 19 auto it = std::find(channels_.begin(), channels_.end(), channel); |
| 20 DCHECK(channels_.end() == it); |
| 21 channels_.push_back(channel); |
| 22 } |
| 23 |
| 24 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( |
| 25 Channel* channel) { |
| 26 auto it = std::find(channels_.begin(), channels_.end(), channel); |
| 27 if (it != channels_.end()) |
| 28 channels_.erase(it); |
| 29 } |
| 30 |
| 31 Channel* AttachmentBrokerPrivileged::GetChannelWithProcessId( |
| 32 base::ProcessId id) { |
| 33 auto it = std::find_if(channels_.begin(), channels_.end(), |
| 34 [id](Channel* c) { return c->GetPeerPID() == id; }); |
| 35 if (it == channels_.end()) |
| 36 return nullptr; |
| 37 return *it; |
| 38 } |
| 39 |
| 40 } // namespace IPC |
OLD | NEW |