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

Side by Side Diff: base/observer_list_threadsafe.h

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/sync_internals/chrome_sync.js » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef BASE_OBSERVER_LIST_THREADSAFE_H_ 5 #ifndef BASE_OBSERVER_LIST_THREADSAFE_H_
6 #define BASE_OBSERVER_LIST_THREADSAFE_H_ 6 #define BASE_OBSERVER_LIST_THREADSAFE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Note, these calls are effectively asynchronous. You cannot assume 141 // Note, these calls are effectively asynchronous. You cannot assume
142 // that at the completion of the Notify call that all Observers have 142 // that at the completion of the Notify call that all Observers have
143 // been Notified. The notification may still be pending delivery. 143 // been Notified. The notification may still be pending delivery.
144 template <class Method> 144 template <class Method>
145 void Notify(Method m) { 145 void Notify(Method m) {
146 UnboundMethod<ObserverType, Method, Tuple0> method(m, MakeTuple()); 146 UnboundMethod<ObserverType, Method, Tuple0> method(m, MakeTuple());
147 Notify<Method, Tuple0>(method); 147 Notify<Method, Tuple0>(method);
148 } 148 }
149 149
150 template <class Method, class A> 150 template <class Method, class A>
151 void Notify(Method m, const A &a) { 151 void Notify(Method m, const A& a) {
152 UnboundMethod<ObserverType, Method, Tuple1<A> > method(m, MakeTuple(a)); 152 UnboundMethod<ObserverType, Method, Tuple1<A> > method(m, MakeTuple(a));
153 Notify<Method, Tuple1<A> >(method); 153 Notify<Method, Tuple1<A> >(method);
154 } 154 }
155 155
156 template <class Method, class A, class B>
157 void Notify(Method m, const A& a, const B& b) {
158 UnboundMethod<ObserverType, Method, Tuple2<A, B> > method(
159 m, MakeTuple(a, b));
160 Notify<Method, Tuple2<A, B> >(method);
161 }
162
163 template <class Method, class A, class B, class C>
164 void Notify(Method m, const A& a, const B& b, const C& c) {
165 UnboundMethod<ObserverType, Method, Tuple3<A, B, C> > method(
166 m, MakeTuple(a, b, c));
167 Notify<Method, Tuple3<A, B, C> >(method);
168 }
169
170 template <class Method, class A, class B, class C, class D>
171 void Notify(Method m, const A& a, const B& b, const C& c, const D& d) {
172 UnboundMethod<ObserverType, Method, Tuple4<A, B, C, D> > method(
173 m, MakeTuple(a, b, c, d));
174 Notify<Method, Tuple4<A, B, C, D> >(method);
175 }
176
156 // TODO(mbelshe): Add more wrappers for Notify() with more arguments. 177 // TODO(mbelshe): Add more wrappers for Notify() with more arguments.
157 178
158 private: 179 private:
159 // See comment above ObserverListThreadSafeTraits' definition. 180 // See comment above ObserverListThreadSafeTraits' definition.
160 friend struct ObserverListThreadSafeTraits<ObserverType>; 181 friend struct ObserverListThreadSafeTraits<ObserverType>;
161 182
162 ~ObserverListThreadSafe() { 183 ~ObserverListThreadSafe() {
163 typename ObserversListMap::const_iterator it; 184 typename ObserversListMap::const_iterator it;
164 for (it = observer_lists_.begin(); it != observer_lists_.end(); ++it) 185 for (it = observer_lists_.begin(); it != observer_lists_.end(); ++it)
165 delete (*it).second; 186 delete (*it).second;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 250
230 // These are marked mutable to facilitate having NotifyAll be const. 251 // These are marked mutable to facilitate having NotifyAll be const.
231 base::Lock list_lock_; // Protects the observer_lists_. 252 base::Lock list_lock_; // Protects the observer_lists_.
232 ObserversListMap observer_lists_; 253 ObserversListMap observer_lists_;
233 const NotificationType type_; 254 const NotificationType type_;
234 255
235 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); 256 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe);
236 }; 257 };
237 258
238 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ 259 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/sync_internals/chrome_sync.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698