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

Side by Side Diff: base/observer_list_threadsafe.h

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop_proxy_impl_unittest.cc ('k') | base/threading/thread.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 (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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 // TODO(mbelshe): Add more wrappers for Notify() with more arguments. 180 // TODO(mbelshe): Add more wrappers for Notify() with more arguments.
181 181
182 private: 182 private:
183 // See comment above ObserverListThreadSafeTraits' definition. 183 // See comment above ObserverListThreadSafeTraits' definition.
184 friend struct ObserverListThreadSafeTraits<ObserverType>; 184 friend struct ObserverListThreadSafeTraits<ObserverType>;
185 185
186 struct ObserverListContext { 186 struct ObserverListContext {
187 explicit ObserverListContext(NotificationType type) 187 explicit ObserverListContext(NotificationType type)
188 : loop(base::MessageLoopProxy::CreateForCurrentThread()), 188 : loop(base::MessageLoopProxy::current()),
189 list(type) { 189 list(type) {
190 } 190 }
191 191
192 scoped_refptr<base::MessageLoopProxy> loop; 192 scoped_refptr<base::MessageLoopProxy> loop;
193 ObserverList<ObserverType> list; 193 ObserverList<ObserverType> list;
194 194
195 DISALLOW_COPY_AND_ASSIGN(ObserverListContext); 195 DISALLOW_COPY_AND_ASSIGN(ObserverListContext);
196 }; 196 };
197 197
198 ~ObserverListThreadSafe() { 198 ~ObserverListThreadSafe() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 typedef std::map<MessageLoop*, ObserverListContext*> ObserversListMap; 263 typedef std::map<MessageLoop*, ObserverListContext*> ObserversListMap;
264 264
265 base::Lock list_lock_; // Protects the observer_lists_. 265 base::Lock list_lock_; // Protects the observer_lists_.
266 ObserversListMap observer_lists_; 266 ObserversListMap observer_lists_;
267 const NotificationType type_; 267 const NotificationType type_;
268 268
269 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); 269 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe);
270 }; 270 };
271 271
272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ 272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_
OLDNEW
« no previous file with comments | « base/message_loop_proxy_impl_unittest.cc ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698