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

Unified Diff: base/android/java/src/org/chromium/base/ObserverList.java

Issue 188783002: ObserverList.removeObserver() should not return true when null is being removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@optimize_remove_observer
Patch Set: Created 6 years, 9 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/android/javatests/src/org/chromium/base/ObserverListTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ObserverList.java
diff --git a/base/android/java/src/org/chromium/base/ObserverList.java b/base/android/java/src/org/chromium/base/ObserverList.java
index 87e5e644e11bf8f8e82d93051b18ef92191810b1..012f4755a00e8b12ea3f1443b0506a3d3100c70f 100644
--- a/base/android/java/src/org/chromium/base/ObserverList.java
+++ b/base/android/java/src/org/chromium/base/ObserverList.java
@@ -73,10 +73,14 @@ public class ObserverList<E> implements Iterable<E> {
* @return true if an element was removed as a result of this call.
*/
public boolean removeObserver(E obs) {
- int index = mObservers.indexOf(obs);
+ if (obs == null) {
+ return false;
+ }
- if (index == -1)
+ int index = mObservers.indexOf(obs);
+ if (index == -1) {
return false;
+ }
if (mIterationDepth == 0) {
// No one is iterating over the list.
« no previous file with comments | « no previous file | base/android/javatests/src/org/chromium/base/ObserverListTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698