| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( | 97 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( |
| 98 Endpoint* endpoint) { | 98 Endpoint* endpoint) { |
| 99 base::AutoLock auto_lock(*get_lock()); | 99 base::AutoLock auto_lock(*get_lock()); |
| 100 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint); | 100 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint); |
| 101 if (it != endpoints_.end()) | 101 if (it != endpoints_.end()) |
| 102 endpoints_.erase(it); | 102 endpoints_.erase(it); |
| 103 } | 103 } |
| 104 | 104 |
| 105 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) { | 105 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) { |
| 106 base::AutoLock auto_lock(*get_lock()); | 106 get_lock()->AssertAcquired(); |
| 107 auto it = std::find_if(endpoints_.begin(), endpoints_.end(), | 107 auto it = std::find_if(endpoints_.begin(), endpoints_.end(), |
| 108 [id](Endpoint* c) { return c->GetPeerPID() == id; }); | 108 [id](Endpoint* c) { return c->GetPeerPID() == id; }); |
| 109 if (it == endpoints_.end()) | 109 if (it == endpoints_.end()) |
| 110 return nullptr; | 110 return nullptr; |
| 111 return *it; | 111 return *it; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void AttachmentBrokerPrivileged::LogError(UMAError error) { | 114 void AttachmentBrokerPrivileged::LogError(UMAError error) { |
| 115 UMA_HISTOGRAM_ENUMERATION( | 115 UMA_HISTOGRAM_ENUMERATION( |
| 116 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); | 116 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace IPC | 119 } // namespace IPC |
| OLD | NEW |