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

Side by Side Diff: ipc/attachment_broker_privileged.cc

Issue 1270683002: ipc: Make a common subclass for Channel and ProxyChannel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase errors. Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « ipc/attachment_broker_privileged.h ('k') | ipc/attachment_broker_privileged_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/attachment_broker_privileged.h" 5 #include "ipc/attachment_broker_privileged.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ipc/ipc_channel.h" 9 #include "ipc/ipc_endpoint.h"
10 10
11 namespace IPC { 11 namespace IPC {
12 12
13 AttachmentBrokerPrivileged::AttachmentBrokerPrivileged() {} 13 AttachmentBrokerPrivileged::AttachmentBrokerPrivileged() {}
14 14
15 AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {} 15 AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {}
16 16
17 void AttachmentBrokerPrivileged::RegisterCommunicationChannel( 17 void AttachmentBrokerPrivileged::RegisterCommunicationChannel(
18 Channel* channel) { 18 Endpoint* endpoint) {
19 channel->set_attachment_broker_endpoint(true); 19 endpoint->SetAttachmentBrokerEndpoint(true);
20 auto it = std::find(channels_.begin(), channels_.end(), channel); 20 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
21 DCHECK(channels_.end() == it); 21 DCHECK(endpoints_.end() == it);
22 channels_.push_back(channel); 22 endpoints_.push_back(endpoint);
23 } 23 }
24 24
25 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( 25 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel(
26 Channel* channel) { 26 Endpoint* endpoint) {
27 auto it = std::find(channels_.begin(), channels_.end(), channel); 27 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
28 if (it != channels_.end()) 28 if (it != endpoints_.end())
29 channels_.erase(it); 29 endpoints_.erase(it);
30 } 30 }
31 31
32 Channel* AttachmentBrokerPrivileged::GetChannelWithProcessId( 32 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) {
33 base::ProcessId id) { 33 auto it = std::find_if(endpoints_.begin(), endpoints_.end(),
34 auto it = std::find_if(channels_.begin(), channels_.end(), 34 [id](Endpoint* c) { return c->GetPeerPID() == id; });
35 [id](Channel* c) { return c->GetPeerPID() == id; }); 35 if (it == endpoints_.end())
36 if (it == channels_.end())
37 return nullptr; 36 return nullptr;
38 return *it; 37 return *it;
39 } 38 }
40 39
41 } // namespace IPC 40 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker_privileged.h ('k') | ipc/attachment_broker_privileged_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698