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

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

Issue 1844343005: WIP - Control the lifetime of RenderThreadManager from Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rework; BVR still needs to be informed of the SRS pointer. Created 4 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
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
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 06ead1d1c420d238965cd9c1d7b04ee25386908a..6b730cb45e7425a3a8a0825415c73ef13faef78d 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -41,6 +41,7 @@ import android.view.inputmethod.InputConnection;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
+import org.chromium.android_webview.browser.SharedRendererStateProxy;
import org.chromium.android_webview.permission.AwGeolocationCallback;
import org.chromium.android_webview.permission.AwPermissionRequest;
import org.chromium.base.LocaleUtils;
@@ -220,6 +221,7 @@ public class AwContents implements SmartClipProvider,
private long mNativeAwContents;
private final AwBrowserContext mBrowserContext;
private ViewGroup mContainerView;
+ private SharedRendererStateProxy mSharedRendererStateProxy;
private final Context mContext;
private final int mAppTargetSdkVersion;
private ContentViewCore mContentViewCore;
@@ -318,13 +320,17 @@ public class AwContents implements SmartClipProvider,
// Hold onto a reference to the window (via its wrapper), so that it is not destroyed
// until we are done here.
private final WindowAndroidWrapper mWindowAndroid;
+ private final SharedRendererStateProxy mProxy;
- private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid) {
+ private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid,
+ SharedRendererStateProxy proxy) {
mNativeAwContents = nativeAwContents;
mWindowAndroid = windowAndroid;
+ mProxy = proxy;
}
@Override
public void run() {
+ mProxy.setClient(0);
nativeDestroy(mNativeAwContents);
}
}
@@ -637,6 +643,9 @@ public class AwContents implements SmartClipProvider,
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
+ if (level >= 60) { // XXX: TRIM_MEMORY_MODERATE
+ mSharedRendererStateProxy.deleteHardwareRenderer();
+ }
nativeTrimMemory(mNativeAwContents, level, visible);
}
});
@@ -967,6 +976,8 @@ public class AwContents implements SmartClipProvider,
mContentViewCore = createAndInitializeContentViewCore(mContainerView, mContext,
mInternalAccessAdapter, webContents, new AwGestureStateListener(),
mContentViewClient, mZoomControls, mWindowAndroid.getWindowAndroid());
+ mSharedRendererStateProxy = new SharedRendererStateProxy();
+ mSharedRendererStateProxy.setClient(mNativeAwContents);
nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
mIoThreadClient, mInterceptNavigationDelegate);
mWebContents = mContentViewCore.getWebContents();
@@ -978,8 +989,8 @@ public class AwContents implements SmartClipProvider,
// The native side object has been bound to this java instance, so now is the time to
// bind all the native->java relationships.
- mCleanupReference =
- new CleanupReference(this, new DestroyRunnable(mNativeAwContents, mWindowAndroid));
+ mCleanupReference = new CleanupReference(this,
+ new DestroyRunnable(mNativeAwContents, mWindowAndroid, mSharedRendererStateProxy));
}
private void installWebContentsObserver() {
@@ -1216,10 +1227,7 @@ public class AwContents implements SmartClipProvider,
// Only called during early construction, so client should not have had a chance to
// call destroy yet.
assert !isDestroyed(NO_WARN);
-
- // Using the native pointer as the returned viewContext. This is matched by the
- // reinterpret_cast back to BrowserViewRenderer pointer in the native DrawGLFunction.
- return nativeGetAwDrawGLViewContext(mNativeAwContents);
+ return mSharedRendererStateProxy.getAwDrawGLViewContext();
}
// This is only to avoid heap allocations inside getGlobalVisibleRect. It should treated
@@ -3089,6 +3097,7 @@ public class AwContents implements SmartClipProvider,
}
mIsAttachedToWindow = false;
hideAutofillPopup();
+ mSharedRendererStateProxy.deleteHardwareRenderer();
nativeOnDetachedFromWindow(mNativeAwContents);
mContentViewCore.onDetachedFromWindow();
@@ -3276,7 +3285,6 @@ public class AwContents implements SmartClipProvider,
private native void nativeFocusFirstNode(long nativeAwContents);
private native void nativeSetBackgroundColor(long nativeAwContents, int color);
- private native long nativeGetAwDrawGLViewContext(long nativeAwContents);
private native long nativeCapturePicture(long nativeAwContents, int width, int height);
private native void nativeEnableOnNewPicture(long nativeAwContents, boolean enabled);
private native void nativeInsertVisualStateCallback(

Powered by Google App Engine
This is Rietveld 408576698