Commit 1e6f0927 authored by Arthur Sonzogni's avatar Arthur Sonzogni Committed by Commit Bot

Instrument WebRequestProxyingUrlLoader for bug 882661

What we know about the bug:
* URLLoaderClient::OnStartLoadingResponseBody is sent before
  URLLoaderClient::OnReceiveResponse.
* Users have one or more ad blocking extensions.
* The NetworkService is enabled.
* Websites are loading content inside an iframe that has never
  navigated. Its URL is still about:blank or javascript:*

This CL Instrument WebRequestProxyingUrlLoader. The goal is to confirm this
bug is about extensions.

Bug: 882661
Change-Id: I1ce33cdb703adb1a854c37f46cafd80a85649388
Reviewed-on: https://chromium-review.googlesource.com/c/1319710
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605730}
parent 297891cf
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <utility> #include <utility>
#include "base/debug/alias.h"
#include "base/debug/dump_without_crashing.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -150,6 +152,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest:: ...@@ -150,6 +152,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse( void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse(
const network::ResourceResponseHead& head) { const network::ResourceResponseHead& head) {
current_response_ = head; current_response_ = head;
on_receive_response_received_ = true;
HandleResponseOrRedirectHeaders( HandleResponseOrRedirectHeaders(
base::BindRepeating(&InProgressRequest::ContinueToResponseStarted, base::BindRepeating(&InProgressRequest::ContinueToResponseStarted,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
...@@ -191,6 +194,13 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest:: ...@@ -191,6 +194,13 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
void WebRequestProxyingURLLoaderFactory::InProgressRequest:: void WebRequestProxyingURLLoaderFactory::InProgressRequest::
OnStartLoadingResponseBody(mojo::ScopedDataPipeConsumerHandle body) { OnStartLoadingResponseBody(mojo::ScopedDataPipeConsumerHandle body) {
// TODO(https://crbug.com/882661): Remove this once the bug is fixed.
if (!on_receive_response_sent_) {
bool on_receive_response_received = on_receive_response_received_;
base::debug::Alias(&on_receive_response_received);
DEBUG_ALIAS_FOR_GURL(request_url, request_.url)
base::debug::DumpWithoutCrashing();
}
target_client_->OnStartLoadingResponseBody(std::move(body)); target_client_->OnStartLoadingResponseBody(std::move(body));
} }
...@@ -441,6 +451,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest:: ...@@ -441,6 +451,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
// |FollowRedirect()|. // |FollowRedirect()|.
proxied_client_binding_.Close(); proxied_client_binding_.Close();
target_loader_.reset(); target_loader_.reset();
on_receive_response_received_ = false;
ContinueToBeforeRedirect(redirect_info, net::OK); ContinueToBeforeRedirect(redirect_info, net::OK);
return; return;
...@@ -452,6 +463,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest:: ...@@ -452,6 +463,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted( ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted(
factory_->browser_context_, factory_->info_map_, &info_.value(), net::OK); factory_->browser_context_, factory_->info_map_, &info_.value(), net::OK);
on_receive_response_sent_ = true;
target_client_->OnReceiveResponse(current_response_); target_client_->OnReceiveResponse(current_response_);
} }
......
...@@ -139,6 +139,10 @@ class WebRequestProxyingURLLoaderFactory ...@@ -139,6 +139,10 @@ class WebRequestProxyingURLLoaderFactory
// lifetime. // lifetime.
base::Optional<net::AuthCredentials> auth_credentials_; base::Optional<net::AuthCredentials> auth_credentials_;
// TODO(https://crbug.com/882661): Remove this once the bug is fixed.
bool on_receive_response_received_ = false;
bool on_receive_response_sent_ = false;
bool request_completed_ = false; bool request_completed_ = false;
base::WeakPtrFactory<InProgressRequest> weak_factory_; base::WeakPtrFactory<InProgressRequest> weak_factory_;
......
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