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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java

Issue 126453006: aw: Clean up android webview lint suppressions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove .class from suppression Created 6 years, 11 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
Index: android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java b/android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java
index a1bcc352cc9b44ba3e339a301699ad457ab95f4e..6eee70b0c387bd46720dbf7dd2a5625e05320913 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwQuotaManagerBridge.java
@@ -4,15 +4,13 @@
package org.chromium.android_webview;
+import android.util.SparseArray;
import android.webkit.ValueCallback;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Bridge between android.webview.WebStorage and native QuotaManager. This object is owned by Java
* AwBrowserContext and the native side is owned by the native AwBrowserContext.
@@ -57,16 +55,16 @@ public class AwQuotaManagerBridge {
// The Java callbacks are saved here. An incrementing callback id is generated for each saved
// callback and is passed to the native side to identify callback.
private int mNextId;
- private Map<Integer, ValueCallback<Origins>> mPendingGetOriginCallbacks;
- private Map<Integer, ValueCallback<Long>> mPendingGetQuotaForOriginCallbacks;
- private Map<Integer, ValueCallback<Long>> mPendingGetUsageForOriginCallbacks;
+ private SparseArray<ValueCallback<Origins>> mPendingGetOriginCallbacks;
+ private SparseArray<ValueCallback<Long>> mPendingGetQuotaForOriginCallbacks;
+ private SparseArray<ValueCallback<Long>> mPendingGetUsageForOriginCallbacks;
private AwQuotaManagerBridge(long nativeAwQuotaManagerBridgeImpl) {
mNativeAwQuotaManagerBridgeImpl = nativeAwQuotaManagerBridgeImpl;
mPendingGetOriginCallbacks =
- new HashMap<Integer, ValueCallback<Origins>>();
- mPendingGetQuotaForOriginCallbacks = new HashMap<Integer, ValueCallback<Long>>();
- mPendingGetUsageForOriginCallbacks = new HashMap<Integer, ValueCallback<Long>>();
+ new SparseArray<ValueCallback<Origins>>();
+ mPendingGetQuotaForOriginCallbacks = new SparseArray<ValueCallback<Long>>();
+ mPendingGetUsageForOriginCallbacks = new SparseArray<ValueCallback<Long>>();
nativeInit(mNativeAwQuotaManagerBridgeImpl);
}
@@ -106,7 +104,7 @@ public class AwQuotaManagerBridge {
*/
public void getOrigins(ValueCallback<Origins> callback) {
int callbackId = getNextId();
- assert !mPendingGetOriginCallbacks.containsKey(callbackId);
+ assert mPendingGetOriginCallbacks.get(callbackId) == null;
mPendingGetOriginCallbacks.put(callbackId, callback);
nativeGetOrigins(mNativeAwQuotaManagerBridgeImpl, callbackId);
}
@@ -117,7 +115,7 @@ public class AwQuotaManagerBridge {
*/
public void getQuotaForOrigin(String origin, ValueCallback<Long> callback) {
int callbackId = getNextId();
- assert !mPendingGetQuotaForOriginCallbacks.containsKey(callbackId);
+ assert mPendingGetQuotaForOriginCallbacks.get(callbackId) == null;
mPendingGetQuotaForOriginCallbacks.put(callbackId, callback);
nativeGetUsageAndQuotaForOrigin(mNativeAwQuotaManagerBridgeImpl, origin, callbackId, true);
}
@@ -128,7 +126,7 @@ public class AwQuotaManagerBridge {
*/
public void getUsageForOrigin(String origin, ValueCallback<Long> callback) {
int callbackId = getNextId();
- assert !mPendingGetUsageForOriginCallbacks.containsKey(callbackId);
+ assert mPendingGetUsageForOriginCallbacks.get(callbackId) == null;
mPendingGetUsageForOriginCallbacks.put(callbackId, callback);
nativeGetUsageAndQuotaForOrigin(mNativeAwQuotaManagerBridgeImpl, origin, callbackId, false);
}
@@ -136,20 +134,23 @@ public class AwQuotaManagerBridge {
@CalledByNative
private void onGetOriginsCallback(int callbackId, String[] origin, long[] usages,
long[] quotas) {
- assert mPendingGetOriginCallbacks.containsKey(callbackId);
- mPendingGetOriginCallbacks.remove(callbackId).onReceiveValue(
+ assert mPendingGetOriginCallbacks.get(callbackId) != null;
+ mPendingGetOriginCallbacks.get(callbackId).onReceiveValue(
new Origins(origin, usages, quotas));
+ mPendingGetOriginCallbacks.remove(callbackId);
}
@CalledByNative
private void onGetUsageAndQuotaForOriginCallback(
int callbackId, boolean isQuota, long usage, long quota) {
if (isQuota) {
- assert mPendingGetQuotaForOriginCallbacks.containsKey(callbackId);
- mPendingGetQuotaForOriginCallbacks.remove(callbackId).onReceiveValue(quota);
+ assert mPendingGetQuotaForOriginCallbacks.get(callbackId) != null;
+ mPendingGetQuotaForOriginCallbacks.get(callbackId).onReceiveValue(quota);
+ mPendingGetQuotaForOriginCallbacks.remove(callbackId);
} else {
- assert mPendingGetUsageForOriginCallbacks.containsKey(callbackId);
- mPendingGetUsageForOriginCallbacks.remove(callbackId).onReceiveValue(usage);
+ assert mPendingGetUsageForOriginCallbacks.get(callbackId) != null;
+ mPendingGetUsageForOriginCallbacks.get(callbackId).onReceiveValue(usage);
+ mPendingGetUsageForOriginCallbacks.remove(callbackId);
}
}

Powered by Google App Engine
This is Rietveld 408576698