am 9217c458: When we destroy a WebView, RESUME_TIMERS/PAUSE_TIMERS may be still in the queue. We need to pass them to WebViewCore as they are per process base. If we drop them, the counter in the JWebCoreJavaBridge can be out of order.

Merge commit '9217c45829da4d0c9c9dbdc6bc950c7f3e03e4f5' into eclair-plus-aosp

* commit '9217c45829da4d0c9c9dbdc6bc950c7f3e03e4f5':
  When we destroy a WebView, RESUME_TIMERS/PAUSE_TIMERS may be still in the queue.
This commit is contained in:
Grace Kloba
2009-09-01 15:02:34 -07:00
committed by Android Git Automerger

View File

@@ -1244,6 +1244,18 @@ final class WebViewCore {
}
}
private synchronized boolean hasMessages(int what) {
if (mBlockMessages) {
return false;
}
if (mMessages != null) {
Log.w(LOGTAG, "hasMessages() is not supported in this case.");
return false;
} else {
return mHandler.hasMessages(what);
}
}
private synchronized void sendMessageDelayed(Message msg, long delay) {
if (mBlockMessages) {
return;
@@ -1355,9 +1367,22 @@ final class WebViewCore {
// We don't want anyone to post a message between removing pending
// messages and sending the destroy message.
synchronized (mEventHub) {
// RESUME_TIMERS and PAUSE_TIMERS are per process base. They need to
// be preserved even the WebView is destroyed.
// Note: we should not have more than one RESUME_TIMERS/PAUSE_TIMERS
boolean hasResume = mEventHub.hasMessages(EventHub.RESUME_TIMERS);
boolean hasPause = mEventHub.hasMessages(EventHub.PAUSE_TIMERS);
mEventHub.removeMessages();
mEventHub.sendMessageAtFrontOfQueue(
Message.obtain(null, EventHub.DESTROY));
if (hasPause) {
mEventHub.sendMessageAtFrontOfQueue(
Message.obtain(null, EventHub.PAUSE_TIMERS));
}
if (hasResume) {
mEventHub.sendMessageAtFrontOfQueue(
Message.obtain(null, EventHub.RESUME_TIMERS));
}
mEventHub.blockMessages();
mWebView = null;
}