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

Side by Side Diff: base/ios/crb_protocol_observers.mm

Issue 2234773002: base: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary formatting change Created 4 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 | « base/debug/activity_analyzer.cc ('k') | base/memory/scoped_vector.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "base/ios/crb_protocol_observers.h" 5 #import "base/ios/crb_protocol_observers.h"
6 6
7 #include <objc/runtime.h> 7 #include <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 - (Protocol*)protocol { 99 - (Protocol*)protocol {
100 return _protocol.get(); 100 return _protocol.get();
101 } 101 }
102 102
103 - (void)addObserver:(id)observer { 103 - (void)addObserver:(id)observer {
104 DCHECK(observer); 104 DCHECK(observer);
105 DCHECK([observer conformsToProtocol:self.protocol]); 105 DCHECK([observer conformsToProtocol:self.protocol]);
106 106
107 if (ContainsValue(_observers, observer)) 107 if (base::ContainsValue(_observers, observer))
108 return; 108 return;
109 109
110 _observers.push_back(observer); 110 _observers.push_back(observer);
111 } 111 }
112 112
113 - (void)removeObserver:(id)observer { 113 - (void)removeObserver:(id)observer {
114 DCHECK(observer); 114 DCHECK(observer);
115 auto it = std::find(_observers.begin(), _observers.end(), observer); 115 auto it = std::find(_observers.begin(), _observers.end(), observer);
116 if (it != _observers.end()) { 116 if (it != _observers.end()) {
117 if (_invocationDepth) 117 if (_invocationDepth)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 #pragma mark - Private 183 #pragma mark - Private
184 184
185 - (void)compact { 185 - (void)compact {
186 DCHECK(!_invocationDepth); 186 DCHECK(!_invocationDepth);
187 _observers.erase(std::remove(_observers.begin(), _observers.end(), nil), 187 _observers.erase(std::remove(_observers.begin(), _observers.end(), nil),
188 _observers.end()); 188 _observers.end());
189 } 189 }
190 190
191 @end 191 @end
OLDNEW
« no previous file with comments | « base/debug/activity_analyzer.cc ('k') | base/memory/scoped_vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698