Commit 41b81861 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Reland "Fix ExtensionWebRequestApiTest.WebRequestUnloadImmediately with network service"

This is a reland of c9cbab07

request_completed_ was being set unnecessarily after RemoveRequest was called.

Original change's description:
> Fix ExtensionWebRequestApiTest.WebRequestUnloadImmediately with network service
>
> The error event was not being sent when the client was reset.
>
> Bug: 721414
> Cq-Include-Trybots: luci.chromium.try:linux_mojo
> Change-Id: I951422061022d50644d8453900af14be27bb9eaf
> Reviewed-on: https://chromium-review.googlesource.com/1150403
> Commit-Queue: Clark DuVall <cduvall@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580911}

TBR=jam@chromium.org

Bug: 721414
Change-Id: I48769a4b86d2a18acbe5fbcedb9de3ed478e4c54
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Reviewed-on: https://chromium-review.googlesource.com/1164209Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581058}
parent 36b4b5b0
......@@ -62,11 +62,11 @@ WebRequestProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
target_client_(std::move(client)),
proxied_client_binding_(this),
weak_factory_(this) {
// If there is a client error, remove this request from the proxy. |factory_|
// outlives this class, so base::Unretained is safe.
// If there is a client error, clean up the request.
target_client_.set_connection_error_handler(base::BindOnce(
&WebRequestProxyingURLLoaderFactory::RemoveRequest,
base::Unretained(factory_), network_service_request_id_, request_id_));
&WebRequestProxyingURLLoaderFactory::InProgressRequest::OnRequestError,
weak_factory_.GetWeakPtr(),
network::URLLoaderCompletionStatus(net::ERR_ABORTED)));
}
WebRequestProxyingURLLoaderFactory::InProgressRequest::~InProgressRequest() {
......@@ -79,6 +79,7 @@ WebRequestProxyingURLLoaderFactory::InProgressRequest::~InProgressRequest() {
}
void WebRequestProxyingURLLoaderFactory::InProgressRequest::Restart() {
request_completed_ = false;
// Derive a new WebRequestInfo value any time |Restart()| is called, because
// the details in |request_| may have changed e.g. if we've been redirected.
info_.emplace(
......@@ -496,6 +497,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
redirect_info.new_url);
target_client_->OnReceiveRedirect(redirect_info, current_response_);
request_.url = redirect_info.new_url;
request_completed_ = true;
}
void WebRequestProxyingURLLoaderFactory::InProgressRequest::
......@@ -529,13 +531,14 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::
continuation.Run(net::OK);
}
void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnRequestError(
const network::URLLoaderCompletionStatus& status) {
target_client_->OnComplete(status);
ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
factory_->browser_context_, factory_->info_map_, &info_.value(),
true /* started */, status.error_code);
if (!request_completed_) {
target_client_->OnComplete(status);
ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
factory_->browser_context_, factory_->info_map_, &info_.value(),
true /* started */, status.error_code);
}
// Deletes |this|.
factory_->RemoveRequest(network_service_request_id_, request_id_);
......
......@@ -163,6 +163,8 @@ class WebRequestProxyingURLLoaderFactory
// lifetime.
base::Optional<net::AuthCredentials> auth_credentials_;
bool request_completed_ = false;
base::WeakPtrFactory<InProgressRequest> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InProgressRequest);
......
......@@ -187,11 +187,6 @@
-IOThreadBrowserTestWithHangingPacRequest.Shutdown
-ProxySettingsApiTest.ProxyEventsParseError
# http://crbug.com/721414
# TODO(rockot): add support for webRequest API.
# Note WebRequestUnloadImmediately is disabled on Linux
-ExtensionWebRequestApiTest.WebRequestUnloadImmediately
# http://crbug.com/827582
# Editing response cookies through headers with webRequest is not supported with
# the network service.
......
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