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

Side by Side Diff: base/observer_list_threadsafe.h

Issue 2802015: Massively simplify the NetworkChangeNotifier infrastructure:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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/browser_main.cc » ('j') | net/base/network_change_notifier.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 7
8 #include <vector> 8 #include <vector>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 10 matching lines...) Expand all
21 // OVERVIEW: 21 // OVERVIEW:
22 // 22 //
23 // A thread-safe container for a list of observers. 23 // A thread-safe container for a list of observers.
24 // This is similar to the observer_list (see observer_list.h), but it 24 // This is similar to the observer_list (see observer_list.h), but it
25 // is more robust for multi-threaded situations. 25 // is more robust for multi-threaded situations.
26 // 26 //
27 // The following use cases are supported: 27 // The following use cases are supported:
28 // * Observers can register for notifications from any thread. 28 // * Observers can register for notifications from any thread.
29 // Callbacks to the observer will occur on the same thread where 29 // Callbacks to the observer will occur on the same thread where
30 // the observer initially called AddObserver() from. 30 // the observer initially called AddObserver() from.
31 // * Any thread may trigger a notification via NOTIFY_OBSERVERS. 31 // * Any thread may trigger a notification via Notify().
32 // * Observers can remove themselves from the observer list inside 32 // * Observers can remove themselves from the observer list inside
33 // of a callback. 33 // of a callback.
34 // * If one thread is notifying observers concurrently with an observer 34 // * If one thread is notifying observers concurrently with an observer
35 // removing itself from the observer list, the notifications will 35 // removing itself from the observer list, the notifications will
36 // be silently dropped. 36 // be silently dropped.
37 // 37 //
38 // The drawback of the threadsafe observer list is that notifications 38 // The drawback of the threadsafe observer list is that notifications
39 // are not as real-time as the non-threadsafe version of this class. 39 // are not as real-time as the non-threadsafe version of this class.
40 // Notifications will always be done via PostTask() to another thread, 40 // Notifications will always be done via PostTask() to another thread,
41 // whereas with the non-thread-safe observer_list, notifications happen 41 // whereas with the non-thread-safe observer_list, notifications happen
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 typedef std::map<MessageLoop*, ObserverList<ObserverType>*> ObserversListMap; 192 typedef std::map<MessageLoop*, ObserverList<ObserverType>*> ObserversListMap;
193 193
194 // These are marked mutable to facilitate having NotifyAll be const. 194 // These are marked mutable to facilitate having NotifyAll be const.
195 Lock list_lock_; // Protects the observer_lists_. 195 Lock list_lock_; // Protects the observer_lists_.
196 ObserversListMap observer_lists_; 196 ObserversListMap observer_lists_;
197 197
198 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); 198 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe);
199 }; 199 };
200 200
201 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ 201 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | net/base/network_change_notifier.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698