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

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java

Issue 1890343003: aw: Use functor callback for lifetime management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix UAF for realz Created 4 years, 8 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
« no previous file with comments | « no previous file | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java
index b12cb048e85eba15fdbfa6cde9be3c934be7c034..597313b7deba46b027a806523f1e701391749c9d 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java
@@ -5,6 +5,7 @@
package com.android.webview.chromium;
import android.graphics.Canvas;
+import android.os.Build;
import android.view.View;
import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate;
@@ -52,7 +53,10 @@ class DrawGLFunctor {
}
}
- public boolean requestDrawGL(Canvas canvas, View containerView, boolean waitForCompletion) {
+ private static final boolean sSupportFunctorReleasedCallback =
+ (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) || "N".equals(Build.VERSION.CODENAME);
+ public boolean requestDrawGL(Canvas canvas, View containerView, boolean waitForCompletion,
+ Runnable releasedCallback) {
if (mDestroyRunnable.mNativeDrawGLFunctor == 0) {
throw new RuntimeException("requested DrawGL on already destroyed DrawGLFunctor");
}
@@ -69,15 +73,27 @@ class DrawGLFunctor {
mContainerView = containerView;
if (canvas == null) {
+ assert releasedCallback == null;
mWebViewDelegate.invokeDrawGlFunctor(
containerView, mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion);
return true;
}
- mWebViewDelegate.callDrawGlFunction(canvas, mDestroyRunnable.mNativeDrawGLFunctor);
+ if (sSupportFunctorReleasedCallback) {
+ assert releasedCallback != null;
+ mWebViewDelegate.callDrawGlFunction(
+ canvas, mDestroyRunnable.mNativeDrawGLFunctor, releasedCallback);
+ } else {
+ assert releasedCallback == null;
+ mWebViewDelegate.callDrawGlFunction(canvas, mDestroyRunnable.mNativeDrawGLFunctor);
+ }
return true;
}
+ public static boolean supportsDrawGLFunctorReleasedCallback() {
+ return sSupportFunctorReleasedCallback;
+ }
+
public static void setChromiumAwDrawGLFunction(long functionPointer) {
nativeSetChromiumAwDrawGLFunction(functionPointer);
}
« no previous file with comments | « no previous file | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698