| 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));
|
| }
|
|
|