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

Side by Side Diff: ipc/attachment_broker_privileged.cc

Issue 1679763002: Clean up public interface of AttachmentBrokerUnprivileged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CHECK. Created 4 years, 10 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_unittest.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 "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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #else 60 #else
61 return nullptr; 61 return nullptr;
62 #endif 62 #endif
63 } 63 }
64 64
65 // This class is wrapped in a LazyInstance to ensure that its constructor is 65 // This class is wrapped in a LazyInstance to ensure that its constructor is
66 // only called once. The constructor creates an attachment broker and sets it as 66 // only called once. The constructor creates an attachment broker and sets it as
67 // the global broker. 67 // the global broker.
68 class AttachmentBrokerMakeOnce { 68 class AttachmentBrokerMakeOnce {
69 public: 69 public:
70 AttachmentBrokerMakeOnce() { 70 AttachmentBrokerMakeOnce() : attachment_broker_(CreateBroker()) {}
71 attachment_broker_.reset(CreateBroker().release());
72 }
73 71
74 private: 72 private:
75 scoped_ptr<IPC::AttachmentBrokerPrivileged> attachment_broker_; 73 scoped_ptr<IPC::AttachmentBrokerPrivileged> attachment_broker_;
76 }; 74 };
77 75
78 base::LazyInstance<AttachmentBrokerMakeOnce>::Leaky 76 base::LazyInstance<AttachmentBrokerMakeOnce>::Leaky
79 g_attachment_broker_make_once = LAZY_INSTANCE_INITIALIZER; 77 g_attachment_broker_make_once = LAZY_INSTANCE_INITIALIZER;
80 78
81 } // namespace 79 } // namespace
82 80
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 119 }
122 120
123 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel( 121 void AttachmentBrokerPrivileged::DeregisterCommunicationChannel(
124 Endpoint* endpoint) { 122 Endpoint* endpoint) {
125 base::AutoLock auto_lock(*get_lock()); 123 base::AutoLock auto_lock(*get_lock());
126 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint); 124 auto it = std::find(endpoints_.begin(), endpoints_.end(), endpoint);
127 if (it != endpoints_.end()) 125 if (it != endpoints_.end())
128 endpoints_.erase(it); 126 endpoints_.erase(it);
129 } 127 }
130 128
129 bool AttachmentBrokerPrivileged::IsPrivilegedBroker() {
130 return true;
131 }
132
131 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) { 133 Sender* AttachmentBrokerPrivileged::GetSenderWithProcessId(base::ProcessId id) {
132 get_lock()->AssertAcquired(); 134 get_lock()->AssertAcquired();
133 auto it = std::find_if(endpoints_.begin(), endpoints_.end(), 135 auto it = std::find_if(endpoints_.begin(), endpoints_.end(),
134 [id](Endpoint* c) { return c->GetPeerPID() == id; }); 136 [id](Endpoint* c) { return c->GetPeerPID() == id; });
135 if (it == endpoints_.end()) 137 if (it == endpoints_.end())
136 return nullptr; 138 return nullptr;
137 return *it; 139 return *it;
138 } 140 }
139 141
140 void AttachmentBrokerPrivileged::LogError(UMAError error) { 142 void AttachmentBrokerPrivileged::LogError(UMAError error) {
141 UMA_HISTOGRAM_ENUMERATION( 143 UMA_HISTOGRAM_ENUMERATION(
142 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); 144 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX);
143 } 145 }
144 146
145 } // namespace IPC 147 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker_privileged.h ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698