summaryrefslogtreecommitdiffstats
path: root/sync/android/java
diff options
context:
space:
mode:
authornileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 04:12:44 +0000
committernileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 04:12:44 +0000
commit2fb7f01bfe274a1571735967b03fee926d920b2a (patch)
treecf93929e670ae1dba1b30aa6332217b333782b7a /sync/android/java
parent618bec8b95a6f7b26e912b8aff677aef3aef2403 (diff)
downloadchromium_src-2fb7f01bfe274a1571735967b03fee926d920b2a.zip
chromium_src-2fb7f01bfe274a1571735967b03fee926d920b2a.tar.gz
chromium_src-2fb7f01bfe274a1571735967b03fee926d920b2a.tar.bz2
Android: Use ObserverList to maintain a list of observers/listeners
Using ObserverList allows for observers adding/removing themselves/others while they are being notified, in a safe way BUG= Review URL: https://chromiumcodereview.appspot.com/12388057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/android/java')
-rw-r--r--sync/android/java/src/org/chromium/sync/notifier/SyncStatusHelper.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/sync/android/java/src/org/chromium/sync/notifier/SyncStatusHelper.java b/sync/android/java/src/org/chromium/sync/notifier/SyncStatusHelper.java
index 4b42eb8..43c6fc7 100644
--- a/sync/android/java/src/org/chromium/sync/notifier/SyncStatusHelper.java
+++ b/sync/android/java/src/org/chromium/sync/notifier/SyncStatusHelper.java
@@ -14,12 +14,11 @@ import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;
+import org.chromium.base.ObserverList;
import org.chromium.sync.signin.AccountManagerHelper;
import com.google.common.annotations.VisibleForTesting;
-import java.util.ArrayList;
-
/**
* A helper class to handle the current status of sync for Chrome in Android-land.
*
@@ -52,7 +51,7 @@ public class SyncStatusHelper {
private static SyncStatusHelper sSyncStatusHelper;
- private ArrayList<Listener> mListeners;
+ private ObserverList<Listener> mListeners;
/**
* @param context the context
@@ -62,7 +61,7 @@ public class SyncStatusHelper {
SyncContentResolverDelegate syncContentResolverWrapper) {
mApplicationContext = context.getApplicationContext();
mSyncContentResolverWrapper = syncContentResolverWrapper;
- mListeners = new ArrayList<Listener>();
+ mListeners = new ObserverList<Listener>();
}
/**
@@ -327,15 +326,14 @@ public class SyncStatusHelper {
* @param listener Listener to add.
*/
public void addListener(Listener listener) {
- mListeners.add(listener);
+ mListeners.addObserver(listener);
}
/**
* Removes a Listener.
* @param listener Listener to remove from the list.
- * @returns whether or not the Listener was removed.
*/
- public boolean removeListener(Listener listener) {
- return mListeners.remove(listener);
+ public void removeListener(Listener listener) {
+ mListeners.removeObserver(listener);
}
}