Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1095)

Unified Diff: ipc/attachment_broker_privileged.cc

Issue 1256993003: ipc: Create AttachmentBrokerPrivileged and AttachmentBrokerUnprivileged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_ipc_message_feature
Patch Set: Rebase. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ipc/attachment_broker_privileged.cc
diff --git a/ipc/attachment_broker_privileged.cc b/ipc/attachment_broker_privileged.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d2b68320ba0adc9b609e927ada5dd152e1c2e67d
--- /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

Powered by Google App Engine
This is Rietveld 408576698