summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2016-03-25 16:38:57 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-25 23:42:10 +0000
commitd1c68aa675d8d5586e2cda7df1ad56d5e4129e59 (patch)
tree497e0692e690a504763785fc04eb0355a8a29d85
parent08bddd4b5abb2cfe1610d0e101707074965ddbba (diff)
downloadchromium_src-d1c68aa675d8d5586e2cda7df1ad56d5e4129e59.zip
chromium_src-d1c68aa675d8d5586e2cda7df1ad56d5e4129e59.tar.gz
chromium_src-d1c68aa675d8d5586e2cda7df1ad56d5e4129e59.tar.bz2
aw: Remove WindowAndroid caching
Caching sCachedWindowAndroid is incorrect since it is possible for the one Application context to be wrapped differently. There is no point in caching ActivityWindowAndroid either due to the way ResourcesContextWrapperFactory works. So remove caching altogether and always create a new WindowAndroid instance. BUG=597526 Review URL: https://codereview.chromium.org/1831373003 Cr-Commit-Position: refs/heads/master@{#383408}
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java26
1 files changed, 5 insertions, 21 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 046ccfc..1332679 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -82,7 +82,6 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.WeakHashMap;
import java.util.concurrent.Callable;
/**
@@ -921,31 +920,16 @@ public class AwContents implements SmartClipProvider,
return mWindowAndroid;
}
}
- private static WindowAndroidWrapper sCachedWindowAndroid;
- private static WeakHashMap<Context, WindowAndroidWrapper> sActivityContextWindowMap;
- // getWindowAndroid is only called on UI thread, so there are no threading issues with lazy
- // initialization.
- @SuppressFBWarnings("LI_LAZY_INIT_STATIC")
- private static WindowAndroidWrapper getWindowAndroid(Context context) {
+ private static WindowAndroidWrapper createWindowAndroid(Context context) {
// TODO(boliu): WebView does not currently initialize ApplicationStatus, crbug.com/470582.
boolean contextWrapsActivity = activityFromContext(context) != null;
if (!contextWrapsActivity) {
- if (sCachedWindowAndroid == null) {
- sCachedWindowAndroid = new WindowAndroidWrapper(new WindowAndroid(context));
- }
- return sCachedWindowAndroid;
+ return new WindowAndroidWrapper(new WindowAndroid(context));
}
- if (sActivityContextWindowMap == null) sActivityContextWindowMap = new WeakHashMap<>();
- WindowAndroidWrapper activityWindowAndroid = sActivityContextWindowMap.get(context);
- if (activityWindowAndroid == null) {
- final boolean listenToActivityState = false;
- activityWindowAndroid = new WindowAndroidWrapper(
- new ActivityWindowAndroid(context, listenToActivityState));
- sActivityContextWindowMap.put(context, activityWindowAndroid);
- }
- return activityWindowAndroid;
+ final boolean listenToActivityState = false;
+ return new WindowAndroidWrapper(new ActivityWindowAndroid(context, listenToActivityState));
}
@VisibleForTesting
@@ -979,7 +963,7 @@ public class AwContents implements SmartClipProvider,
WebContents webContents = nativeGetWebContents(mNativeAwContents);
- mWindowAndroid = getWindowAndroid(mContext);
+ mWindowAndroid = createWindowAndroid(mContext);
mContentViewCore = createAndInitializeContentViewCore(mContainerView, mContext,
mInternalAccessAdapter, webContents, new AwGestureStateListener(),
mContentViewClient, mZoomControls, mWindowAndroid.getWindowAndroid());