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

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

Issue 1350553005: [Android WebView] Call shouldInterceptRequest on a background thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get rid of has_been_killed Created 5 years, 3 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/AwContentsBackgroundThreadClient.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsBackgroundThreadClient.java
similarity index 23%
copy from android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java
copy to android_webview/java/src/org/chromium/android_webview/AwContentsBackgroundThreadClient.java
index 61794004b7f5b060f3d6deaaea90faddade248b8..aa0307d16fb08ca0344320f543cd4a40fa1f535c 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsBackgroundThreadClient.java
@@ -1,4 +1,4 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,51 +8,21 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import java.util.HashMap;
-import java.util.Map;
/**
- * Delegate for handling callbacks. All methods are called on the IO thread.
- *
- * You should create a separate instance for every WebContents that requires the
- * provided functionality.
+ * Delegate for handling callbacks. All methods are called on the background thread.
+ * "Background" means something that isn't UI or IO.
*/
@JNINamespace("android_webview")
-public abstract class AwContentsIoThreadClient {
- @CalledByNative
- public abstract int getCacheMode();
-
- @CalledByNative
- public abstract boolean shouldBlockContentUrls();
-
- @CalledByNative
- public abstract boolean shouldBlockFileUrls();
-
- @CalledByNative
- public abstract boolean shouldBlockNetworkLoads();
-
- @CalledByNative
- public abstract boolean shouldAcceptThirdPartyCookies();
-
- @CalledByNative
- public abstract void onDownloadStart(String url, String userAgent,
- String contentDisposition, String mimeType, long contentLength);
-
- @CalledByNative
- public abstract void newLoginRequest(String realm, String account, String args);
+public abstract class AwContentsBackgroundThreadClient {
public abstract AwWebResourceResponse shouldInterceptRequest(
AwContentsClient.AwWebResourceRequest request);
- public abstract void onReceivedError(AwContentsClient.AwWebResourceRequest request,
- AwContentsClient.AwWebResourceError error);
-
- public abstract void onReceivedHttpError(AwContentsClient.AwWebResourceRequest request,
- AwWebResourceResponse response);
-
// Protected methods ---------------------------------------------------------------------------
@CalledByNative
- protected AwWebResourceResponse shouldInterceptRequest(String url, boolean isMainFrame,
+ private AwWebResourceResponse shouldInterceptRequestFromNative(String url, boolean isMainFrame,
boolean hasUserGesture, String method, String[] requestHeaderNames,
String[] requestHeaderValues) {
AwContentsClient.AwWebResourceRequest request =
@@ -67,65 +37,4 @@ public abstract class AwContentsIoThreadClient {
}
return shouldInterceptRequest(request);
}
-
- @CalledByNative
- protected void onReceivedError(
- // WebResourceRequest
- String url, boolean isMainFrame, boolean hasUserGesture, String method,
- String[] requestHeaderNames, String[] requestHeaderValues,
- // WebResourceError
- int errorCode, String description) {
- AwContentsClient.AwWebResourceRequest request =
- new AwContentsClient.AwWebResourceRequest();
- request.url = url;
- request.isMainFrame = isMainFrame;
- request.hasUserGesture = hasUserGesture;
- request.method = method;
- request.requestHeaders = new HashMap<String, String>(requestHeaderNames.length);
- for (int i = 0; i < requestHeaderNames.length; ++i) {
- request.requestHeaders.put(requestHeaderNames[i], requestHeaderValues[i]);
- }
- AwContentsClient.AwWebResourceError error = new AwContentsClient.AwWebResourceError();
- error.errorCode = errorCode;
- error.description = description;
- onReceivedError(request, error);
- }
-
- @CalledByNative
- protected void onReceivedHttpError(
- // WebResourceRequest
- String url, boolean isMainFrame, boolean hasUserGesture, String method,
- String[] requestHeaderNames, String[] requestHeaderValues,
- // WebResourceResponse
- String mimeType, String encoding, int statusCode, String reasonPhrase,
- String[] responseHeaderNames, String[] responseHeaderValues) {
- AwContentsClient.AwWebResourceRequest request =
- new AwContentsClient.AwWebResourceRequest();
- request.url = url;
- request.isMainFrame = isMainFrame;
- request.hasUserGesture = hasUserGesture;
- request.method = method;
- request.requestHeaders = new HashMap<String, String>(requestHeaderNames.length);
- for (int i = 0; i < requestHeaderNames.length; ++i) {
- request.requestHeaders.put(requestHeaderNames[i], requestHeaderValues[i]);
- }
- Map<String, String> responseHeaders =
- new HashMap<String, String>(responseHeaderNames.length);
- // Note that we receive un-coalesced response header lines, thus we need to combine
- // values for the same header.
- for (int i = 0; i < responseHeaderNames.length; ++i) {
- if (!responseHeaders.containsKey(responseHeaderNames[i])) {
- responseHeaders.put(responseHeaderNames[i], responseHeaderValues[i]);
- } else if (!responseHeaderValues[i].isEmpty()) {
- String currentValue = responseHeaders.get(responseHeaderNames[i]);
- if (!currentValue.isEmpty()) {
- currentValue += ", ";
- }
- responseHeaders.put(responseHeaderNames[i], currentValue + responseHeaderValues[i]);
- }
- }
- AwWebResourceResponse response = new AwWebResourceResponse(
- mimeType, encoding, null, statusCode, reasonPhrase, responseHeaders);
- onReceivedHttpError(request, response);
- }
}

Powered by Google App Engine
This is Rietveld 408576698