From c6c318dffbb411c2cb04740a8dcc18d21c14f361 Mon Sep 17 00:00:00 2001 From: Grace Kloba <> Date: Wed, 1 Apr 2009 09:44:18 -0700 Subject: AI 143999: am: CL 143998 Fix #1750489. Call WebKit's setNetworkOnLine from WebCore thread instead of UI thread as WebKit is not thread safe. Using the same code pattern as the rest of the file: . throw IllegalStateException if BrowserFrame.sJavaBridge is null in pauseTimers/resumeTimers. . use (msg.arg1 == 1) to pass the boolean from WebView to WebViewCore as in CLEAR_CACHE Original author: klobag Merged from: //branches/cupcake/... Automated import of CL 143999 --- core/java/android/webkit/WebView.java | 3 ++- core/java/android/webkit/WebViewCore.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'core/java') diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 3205820..1822ba4 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -913,7 +913,8 @@ public class WebView extends AbsoluteLayout * @hide pending API Council approval */ public void setNetworkAvailable(boolean networkUp) { - BrowserFrame.sJavaBridge.setNetworkOnLine(networkUp); + mWebViewCore.sendMessage(EventHub.SET_NETWORK_STATE, + networkUp ? 1 : 0, 0); } /** diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 3e4daf7..72b30f6 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -521,7 +521,7 @@ final class WebViewCore { "SET_GLOBAL_BOUNDS", // = 116; "UPDATE_CACHE_AND_TEXT_ENTRY", // = 117; "CLICK", // = 118; - "119", + "SET_NETWORK_STATE", // = 119; "DOC_HAS_IMAGES", // = 120; "SET_SNAP_ANCHOR", // = 121; "DELETE_SELECTION", // = 122; @@ -567,6 +567,7 @@ final class WebViewCore { static final int SET_GLOBAL_BOUNDS = 116; static final int UPDATE_CACHE_AND_TEXT_ENTRY = 117; static final int CLICK = 118; + static final int SET_NETWORK_STATE = 119; static final int DOC_HAS_IMAGES = 120; static final int SET_SNAP_ANCHOR = 121; static final int DELETE_SELECTION = 122; @@ -781,6 +782,15 @@ final class WebViewCore { } break; + case SET_NETWORK_STATE: + if (BrowserFrame.sJavaBridge == null) { + throw new IllegalStateException("No WebView " + + "has been created in this process!"); + } + BrowserFrame.sJavaBridge + .setNetworkOnLine(msg.arg1 == 1); + break; + case CLEAR_CACHE: mBrowserFrame.clearCache(); if (msg.arg1 == 1) { -- cgit v1.1