Commit c9cbab07 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

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: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580911}
parent a8191a7c
......@@ -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(
......@@ -230,6 +231,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnComplete(
// Deletes |this|.
factory_->RemoveRequest(network_service_request_id_, request_id_);
request_completed_ = true;
}
void WebRequestProxyingURLLoaderFactory::InProgressRequest::HandleAuthRequest(
......@@ -496,6 +498,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 +532,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