Commit 77e3a8b3 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[Android WebView] Add InterceptedRequest class and OnReceivedHttpError callback.

Add InterceptedRequest class, which represents an in-progress network request
and allows to receive callbacks at certain points in the process and control
the flow.

This patch also adds code for the OnReceivedHttpError callback, which fixes
the following tests:
- org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testAfterRedirect
- org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForMainResource
- org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForSubresource
- org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testNotCalledIfNoHttpError

This patch in more detail:
- add IntercepedRequest internal class
- add code necessary for AwContentsClientBridge lookup
- detect http errors and code for the onReceivedHttpError callback
- update tests filter

BUG=891722

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I2123a30b0c9ea8c3f07c34adc0fedb6bc69ca8f3
Reviewed-on: https://chromium-review.googlesource.com/c/1259019
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599250}
parent 247a10a5
...@@ -64,7 +64,6 @@ include_rules = [ ...@@ -64,7 +64,6 @@ include_rules = [
# AwContentBrowserClient::GetDefaultFavicon # AwContentBrowserClient::GetDefaultFavicon
"!ui/resources/grit/ui_resources.h", "!ui/resources/grit/ui_resources.h",
# QuotaStatusCode required by AwQuotaManagerBridge. # QuotaStatusCode required by AwQuotaManagerBridge.
"+third_party/blink/public/mojom/quota", "+third_party/blink/public/mojom/quota",
# Interface required for in-process input event handling. # Interface required for in-process input event handling.
......
...@@ -769,11 +769,12 @@ bool AwContentBrowserClient::WillCreateURLLoaderFactory( ...@@ -769,11 +769,12 @@ bool AwContentBrowserClient::WillCreateURLLoaderFactory(
auto proxied_request = std::move(*factory_request); auto proxied_request = std::move(*factory_request);
network::mojom::URLLoaderFactoryPtrInfo target_factory_info; network::mojom::URLLoaderFactoryPtrInfo target_factory_info;
*factory_request = mojo::MakeRequest(&target_factory_info); *factory_request = mojo::MakeRequest(&target_factory_info);
int process_id = is_navigation ? 0 : frame->GetProcess()->GetID();
// Android WebView has one non off-the-record browser context. // Android WebView has one non off-the-record browser context.
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO}, FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&AwProxyingURLLoaderFactory::CreateProxy, base::BindOnce(&AwProxyingURLLoaderFactory::CreateProxy, process_id,
std::move(proxied_request), std::move(target_factory_info), std::move(proxied_request), std::move(target_factory_info),
nullptr /* AwInterceptedRequestHandler */)); nullptr /* AwInterceptedRequestHandler */));
return true; return true;
......
...@@ -31,6 +31,7 @@ class AwInterceptedRequestHandler {}; ...@@ -31,6 +31,7 @@ class AwInterceptedRequestHandler {};
class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory { class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory {
public: public:
AwProxyingURLLoaderFactory( AwProxyingURLLoaderFactory(
int process_id,
network::mojom::URLLoaderFactoryRequest loader_request, network::mojom::URLLoaderFactoryRequest loader_request,
network::mojom::URLLoaderFactoryPtrInfo target_factory_info, network::mojom::URLLoaderFactoryPtrInfo target_factory_info,
std::unique_ptr<AwInterceptedRequestHandler> request_handler); std::unique_ptr<AwInterceptedRequestHandler> request_handler);
...@@ -39,6 +40,7 @@ class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory { ...@@ -39,6 +40,7 @@ class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory {
// static // static
static void CreateProxy( static void CreateProxy(
int process_id,
network::mojom::URLLoaderFactoryRequest loader, network::mojom::URLLoaderFactoryRequest loader,
network::mojom::URLLoaderFactoryPtrInfo target_factory_info, network::mojom::URLLoaderFactoryPtrInfo target_factory_info,
std::unique_ptr<AwInterceptedRequestHandler> request_handler); std::unique_ptr<AwInterceptedRequestHandler> request_handler);
...@@ -58,6 +60,7 @@ class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory { ...@@ -58,6 +60,7 @@ class AwProxyingURLLoaderFactory : public network::mojom::URLLoaderFactory {
void OnTargetFactoryError(); void OnTargetFactoryError();
void OnProxyBindingError(); void OnProxyBindingError();
const int process_id_;
mojo::BindingSet<network::mojom::URLLoaderFactory> proxy_bindings_; mojo::BindingSet<network::mojom::URLLoaderFactory> proxy_bindings_;
network::mojom::URLLoaderFactoryPtr target_factory_; network::mojom::URLLoaderFactoryPtr target_factory_;
......
...@@ -120,11 +120,7 @@ ...@@ -120,11 +120,7 @@
-org.chromium.android_webview.test.ClientOnReceivedErrorTest.testOnReceivedErrorOnInvalidUrl -org.chromium.android_webview.test.ClientOnReceivedErrorTest.testOnReceivedErrorOnInvalidUrl
# https://crbug.com/891722 # https://crbug.com/891722
-org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testAfterRedirect
-org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForMainResource
-org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForSubresource
-org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForUserGesture -org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testForUserGesture
-org.chromium.android_webview.test.ClientOnReceivedHttpErrorTest.testNotCalledIfNoHttpError
# https://crbug.com/893575 # https://crbug.com/893575
-org.chromium.android_webview.test.CookieManagerStartupTest.testShouldInterceptRequestDeadlock -org.chromium.android_webview.test.CookieManagerStartupTest.testShouldInterceptRequestDeadlock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment