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

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: Re-uploading with standard diff settings to work around Windows patch issues 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/AwContentsBackgroundThreadClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsBackgroundThreadClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..aa0307d16fb08ca0344320f543cd4a40fa1f535c
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsBackgroundThreadClient.java
@@ -0,0 +1,40 @@
+// 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.
+
+package org.chromium.android_webview;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+import java.util.HashMap;
+
+/**
+ * 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 AwContentsBackgroundThreadClient {
+
+ public abstract AwWebResourceResponse shouldInterceptRequest(
+ AwContentsClient.AwWebResourceRequest request);
+
+ // Protected methods ---------------------------------------------------------------------------
+
+ @CalledByNative
+ private AwWebResourceResponse shouldInterceptRequestFromNative(String url, boolean isMainFrame,
+ boolean hasUserGesture, String method, String[] requestHeaderNames,
+ String[] requestHeaderValues) {
+ 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]);
+ }
+ return shouldInterceptRequest(request);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698