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

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

Issue 2292393002: aw: Cancel pending callbacks after native destroy (Closed)
Patch Set: Created 4 years, 4 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/AwContentsClientCallbackHelper.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
index 39fc42efe8bfbe07a2bd591994ac33ca385f8312..2fb4a6760f8c7842eea4de1ef761e4bac048cdff 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
@@ -22,6 +22,12 @@ import java.util.concurrent.Callable;
*/
@VisibleForTesting
public class AwContentsClientCallbackHelper {
+ /**
+ * Interface to tell CallbackHelper to cancel posted callbacks.
+ */
+ public static interface CancelCallbackPoller {
+ boolean cancelAllCallbacks();
+ }
// TODO(boliu): Consider removing DownloadInfo and LoginRequestInfo by using native
// MessageLoop to post directly to AwContents.
@@ -126,6 +132,8 @@ public class AwContentsClientCallbackHelper {
private final Handler mHandler;
+ private CancelCallbackPoller mCancelCallbackPoller;
+
private class MyHandler extends Handler {
private MyHandler(Looper looper) {
super(looper);
@@ -133,6 +141,11 @@ public class AwContentsClientCallbackHelper {
@Override
public void handleMessage(Message msg) {
+ if (mCancelCallbackPoller != null && mCancelCallbackPoller.cancelAllCallbacks()) {
+ removeCallbacksAndMessages(null);
+ return;
+ }
+
switch(msg.what) {
case MSG_ON_LOAD_RESOURCE: {
final String url = (String) msg.obj;
@@ -227,6 +240,11 @@ public class AwContentsClientCallbackHelper {
mContentsClient = contentsClient;
}
+ // Public for tests.
+ public void setCancelCallbackPoller(CancelCallbackPoller poller) {
+ mCancelCallbackPoller = poller;
+ }
+
public void postOnLoadResource(String url) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_LOAD_RESOURCE, url));
}

Powered by Google App Engine
This is Rietveld 408576698