зеркало из https://github.com/mozilla/gecko-dev.git
Bug 962968 - Replace HashMap with SparseArray in PanelManager (r=rnewman)
This commit is contained in:
Родитель
b1165b1785
Коммит
819952c3f2
|
@ -19,11 +19,10 @@ import android.content.SharedPreferences;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PanelManager implements GeckoEventListener {
|
||||
|
@ -50,7 +49,7 @@ public class PanelManager implements GeckoEventListener {
|
|||
private static AtomicInteger sRequestId = new AtomicInteger(0);
|
||||
|
||||
// Stores set of pending request callbacks.
|
||||
private static final Map<Integer, RequestCallback> sCallbacks = new HashMap<Integer, RequestCallback>();
|
||||
private static final SparseArray<RequestCallback> sCallbacks = new SparseArray<RequestCallback>();
|
||||
|
||||
/**
|
||||
* Asynchronously fetches list of available panels from Gecko.
|
||||
|
@ -62,7 +61,7 @@ public class PanelManager implements GeckoEventListener {
|
|||
|
||||
synchronized(sCallbacks) {
|
||||
// If there are no pending callbacks, register the event listener.
|
||||
if (sCallbacks.isEmpty()) {
|
||||
if (sCallbacks.size() == 0) {
|
||||
GeckoAppShell.getEventDispatcher().registerEventListener("HomePanels:Data", this);
|
||||
}
|
||||
sCallbacks.put(requestId, callback);
|
||||
|
@ -90,10 +89,11 @@ public class PanelManager implements GeckoEventListener {
|
|||
final int requestId = message.getInt("requestId");
|
||||
|
||||
synchronized(sCallbacks) {
|
||||
callback = sCallbacks.remove(requestId);
|
||||
callback = sCallbacks.get(requestId);
|
||||
sCallbacks.delete(requestId);
|
||||
|
||||
// Unregister the event listener if there are no more pending callbacks.
|
||||
if (sCallbacks.isEmpty()) {
|
||||
if (sCallbacks.size() == 0) {
|
||||
GeckoAppShell.getEventDispatcher().unregisterEventListener("HomePanels:Data", this);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче