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

Unified Diff: base/ios/crb_protocol_observers.h

Issue 1157863009: CRBProtocolObservers can now be mutated while forwarding methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/ios/crb_protocol_observers.mm » ('j') | base/ios/crb_protocol_observers.mm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/ios/crb_protocol_observers.h
diff --git a/base/ios/crb_protocol_observers.h b/base/ios/crb_protocol_observers.h
index 15d16569ff84660365dceaf4088e2b8c9ecfda34..560f0dcbfb39c3d2845f0bd370983f8f32690c4d 100644
--- a/base/ios/crb_protocol_observers.h
+++ b/base/ios/crb_protocol_observers.h
@@ -13,6 +13,10 @@ typedef void (^ExecutionWithObserverBlock)(id);
// protocol. The container forwards method invocations to its contained
// observers, so that sending a message to all the observers is as simple as
// sending the message to the container.
+// It is safe for an observer to remove itself or another observer while being
+// notified. It is also safe to add an other observer while being notified but
+// the newly added observer will not be notified as part of the current
+// notification dispatch.
droger 2015/06/04 10:04:23 Optional, but would be nice: add a code example (s
jbbegue 2015/06/04 12:13:02 Acknowledged.
@interface CRBProtocolObservers : NSObject
// The Objective-C protocol that the observers in this container conform to.
@@ -20,7 +24,7 @@ typedef void (^ExecutionWithObserverBlock)(id);
// Returns a CRBProtocolObservers container for observers that conform to
// |protocol|.
-+ (CRBProtocolObservers*)observersWithProtocol:(Protocol*)protocol;
++ (instancetype)observersWithProtocol:(Protocol*)protocol;
// Adds |observer| to this container.
- (void)addObserver:(id)observer;
@@ -28,6 +32,9 @@ typedef void (^ExecutionWithObserverBlock)(id);
// Remove |observer| from this container.
- (void)removeObserver:(id)observer;
+// Returns true if there is currently no observers.
+- (BOOL)empty;
+
// Executes callback on every observer. |callback| cannot be nil.
- (void)executeOnObservers:(ExecutionWithObserverBlock)callback;
« no previous file with comments | « no previous file | base/ios/crb_protocol_observers.mm » ('j') | base/ios/crb_protocol_observers.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698