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

Side by Side Diff: ipc/attachment_broker_privileged.cc

Issue 1405253010: ipc: Add a lock to guard modifications of state of the AttachmentBroker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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.cc ('k') | ipc/attachment_broker_privileged_mac.h » ('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 "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 #else 81 #else
82 // static 82 // static
83 void AttachmentBrokerPrivileged::CreateBrokerIfNeeded() { 83 void AttachmentBrokerPrivileged::CreateBrokerIfNeeded() {
84 g_attachment_broker_make_once.Get(); 84 g_attachment_broker_make_once.Get();
85 } 85 }
86 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 86 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
87 87
88 void AttachmentBrokerPrivileged::RegisterCommunicationChannel( 88 void AttachmentBrokerPrivileged::RegisterCommunicationChannel(
89 Endpoint* endpoint) { 89 Endpoint* endpoint) {
90 base::AutoLock auto_lock(*get_lock());
90 endpoint->SetAttachmentBrokerEndpoint(true); 91 endpoint->SetAttachmentBrokerEndpoint(true);
91 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint); 92 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
92 DCHECK(endpoints_.end() == it); 93 DCHECK(endpoints_.end() == it);
93 endpoints_.push_back(endpoint); 94 endpoints_.push_back(endpoint);
94 } 95 }
95 96
96 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( 97 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel(
97 Endpoint* endpoint) { 98 Endpoint* endpoint) {
99 base::AutoLock auto_lock(*get_lock());
98 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint); 100 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
99 if (it != endpoints_.end()) 101 if (it != endpoints_.end())
100 endpoints_.erase(it); 102 endpoints_.erase(it);
101 } 103 }
102 104
103 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) { 105 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) {
106 base::AutoLock auto_lock(*get_lock());
104 auto it = std::find_if(endpoints_.begin(), endpoints_.end(), 107 auto it = std::find_if(endpoints_.begin(), endpoints_.end(),
105 [id](Endpoint* c) { return c->GetPeerPID() == id; }); 108 [id](Endpoint* c) { return c->GetPeerPID() == id; });
106 if (it == endpoints_.end()) 109 if (it == endpoints_.end())
107 return nullptr; 110 return nullptr;
108 return *it; 111 return *it;
109 } 112 }
110 113
111 void AttachmentBrokerPrivileged::LogError(UMAError error) { 114 void AttachmentBrokerPrivileged::LogError(UMAError error) {
112 UMA_HISTOGRAM_ENUMERATION( 115 UMA_HISTOGRAM_ENUMERATION(
113 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); 116 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX);
114 } 117 }
115 118
116 } // namespace IPC 119 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker.cc ('k') | ipc/attachment_broker_privileged_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698