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

Side by Side Diff: base/android/java/src/org/chromium/base/ObserverList.java

Issue 2451933003: base: Erase unused FOR_EACH_OBSERVER macro. (Closed)
Patch Set: Created 4 years, 1 month 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 | « PRESUBMIT.py ('k') | base/observer_list.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 package org.chromium.base; 5 package org.chromium.base;
6 6
7 import java.util.ArrayList; 7 import java.util.ArrayList;
8 import java.util.Iterator; 8 import java.util.Iterator;
9 import java.util.List; 9 import java.util.List;
10 import java.util.NoSuchElementException; 10 import java.util.NoSuchElementException;
11 11
12 import javax.annotation.concurrent.NotThreadSafe; 12 import javax.annotation.concurrent.NotThreadSafe;
13 13
14 /** 14 /**
15 * A container for a list of observers. 15 * A container for a list of observers.
16 * <p/> 16 * <p/>
17 * This container can be modified during iteration without invalidating the iter ator. 17 * This container can be modified during iteration without invalidating the iter ator.
18 * So, it safely handles the case of an observer removing itself or other observ ers from the list 18 * So, it safely handles the case of an observer removing itself or other observ ers from the list
19 * while observers are being notified. 19 * while observers are being notified.
20 * <p/> 20 * <p/>
21 * The implementation (and the interface) is heavily influenced by the C++ Obser verList. 21 * The implementation (and the interface) is heavily influenced by the C++ Obser verList.
22 * Notable differences: 22 * Notable differences:
23 * - The iterator implements NOTIFY_EXISTING_ONLY. 23 * - The iterator implements NOTIFY_EXISTING_ONLY.
24 * - The FOR_EACH_OBSERVER closure is left to the clients to implement in term s of iterator(). 24 * - The range-based for loop is left to the clients to implement in terms of iterator().
25 * <p/> 25 * <p/>
26 * This class is not threadsafe. Observers MUST be added, removed and will be no tified on the same 26 * This class is not threadsafe. Observers MUST be added, removed and will be no tified on the same
27 * thread this is created. 27 * thread this is created.
28 * 28 *
29 * @param <E> The type of observers that this list should hold. 29 * @param <E> The type of observers that this list should hold.
30 */ 30 */
31 @NotThreadSafe 31 @NotThreadSafe
32 public class ObserverList<E> implements Iterable<E> { 32 public class ObserverList<E> implements Iterable<E> {
33 /** 33 /**
34 * Extended iterator interface that provides rewind functionality. 34 * Extended iterator interface that provides rewind functionality.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 private void compactListIfNeeded() { 242 private void compactListIfNeeded() {
243 if (!mIsExhausted) { 243 if (!mIsExhausted) {
244 mIsExhausted = true; 244 mIsExhausted = true;
245 ObserverList.this.decrementIterationDepthAndCompactIfNeeded(); 245 ObserverList.this.decrementIterationDepthAndCompactIfNeeded();
246 } 246 }
247 } 247 }
248 } 248 }
249 } 249 }
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | base/observer_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698