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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/ios/crb_protocol_observers.mm » ('j') | base/ios/crb_protocol_observers.mm » ('J')
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 #ifndef BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_ 5 #ifndef BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_
6 #define BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_ 6 #define BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 typedef void (^ExecutionWithObserverBlock)(id); 10 typedef void (^ExecutionWithObserverBlock)(id);
11 11
12 // Implements a container for observers that implement a specific Objective-C 12 // Implements a container for observers that implement a specific Objective-C
13 // protocol. The container forwards method invocations to its contained 13 // protocol. The container forwards method invocations to its contained
14 // observers, so that sending a message to all the observers is as simple as 14 // observers, so that sending a message to all the observers is as simple as
15 // sending the message to the container. 15 // sending the message to the container.
16 // It is safe for an observer to remove itself or another observer while being
17 // notified. It is also safe to add an other observer while being notified but
18 // the newly added observer will not be notified as part of the current
19 // notification dispatch.
16 @interface CRBProtocolObservers : NSObject 20 @interface CRBProtocolObservers : NSObject
17 21
18 // The Objective-C protocol that the observers in this container conform to. 22 // The Objective-C protocol that the observers in this container conform to.
19 @property(nonatomic, readonly) Protocol* protocol; 23 @property(nonatomic, readonly) Protocol* protocol;
20 24
21 // Returns a CRBProtocolObservers container for observers that conform to 25 // Returns a CRBProtocolObservers container for observers that conform to
22 // |protocol|. 26 // |protocol|.
23 + (CRBProtocolObservers*)observersWithProtocol:(Protocol*)protocol; 27 + (instancetype)observersWithProtocol:(Protocol*)protocol;
24 28
25 // Adds |observer| to this container. 29 // Adds |observer| to this container.
26 - (void)addObserver:(id)observer; 30 - (void)addObserver:(id)observer;
27 31
28 // Remove |observer| from this container. 32 // Remove |observer| from this container.
29 - (void)removeObserver:(id)observer; 33 - (void)removeObserver:(id)observer;
30 34
35 // Returns true if there is currently no observers.
stuartmorgan 2015/06/04 13:40:05 s/is/are/
jbbegue 2015/06/04 16:03:10 Done.
36 - (BOOL)empty;
37
31 // Executes callback on every observer. |callback| cannot be nil. 38 // Executes callback on every observer. |callback| cannot be nil.
32 - (void)executeOnObservers:(ExecutionWithObserverBlock)callback; 39 - (void)executeOnObservers:(ExecutionWithObserverBlock)callback;
33 40
34 @end 41 @end
35 42
36 #endif // BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_ 43 #endif // BASE_IOS_CRB_PROTOCOL_OBSERVERS_H_
OLDNEW
« 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