chore: bump chromium to f755b70e34659441e72c1a928a406 (master) (#21000)

This commit is contained in:
Electron Bot 2019-12-10 16:22:35 -08:00 committed by Jeremy Apthorp
parent a5c9bd53e0
commit 49b47ee4ed
181 changed files with 1117 additions and 1786 deletions

View file

@ -13,6 +13,7 @@
#include "base/task/post_task.h"
#include "content/public/browser/file_url_loader.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "mojo/public/cpp/system/file_data_source.h"
#include "net/base/filename_util.h"
@ -59,13 +60,13 @@ class AsarURLLoader : public network::mojom::URLLoader {
static void CreateAndStart(
const network::ResourceRequest& request,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtrInfo client_info,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
// Owns itself. Will live as long as its URLLoader and URLLoaderClientPtr
// bindings are alive - essentially until either the client gives up or all
// file data has been sent to it.
auto* asar_url_loader = new AsarURLLoader;
asar_url_loader->Start(request, std::move(loader), std::move(client_info),
asar_url_loader->Start(request, std::move(loader), std::move(client),
std::move(extra_response_headers));
}
@ -84,18 +85,20 @@ class AsarURLLoader : public network::mojom::URLLoader {
void Start(const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader,
network::mojom::URLLoaderClientPtrInfo client_info,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
network::ResourceResponseHead head;
head.request_start = base::TimeTicks::Now();
head.response_start = base::TimeTicks::Now();
head.headers = extra_response_headers;
client_.Bind(std::move(client_info));
base::FilePath path;
if (!net::FileURLToFilePath(request.url, &path)) {
OnClientComplete(net::ERR_FAILED);
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
MaybeDeleteSelf();
return;
}
@ -103,12 +106,13 @@ class AsarURLLoader : public network::mojom::URLLoader {
base::FilePath asar_path, relative_path;
if (!GetAsarArchivePath(path, &asar_path, &relative_path)) {
content::CreateFileURLLoader(request, std::move(loader),
std::move(client_), nullptr, false,
std::move(client), nullptr, false,
extra_response_headers);
MaybeDeleteSelf();
return;
}
client_.Bind(std::move(client));
receiver_.Bind(std::move(loader));
receiver_.set_disconnect_handler(base::BindOnce(
&AsarURLLoader::OnConnectionError, base::Unretained(this)));
@ -281,7 +285,7 @@ class AsarURLLoader : public network::mojom::URLLoader {
std::unique_ptr<mojo::DataPipeProducer> data_producer_;
mojo::Receiver<network::mojom::URLLoader> receiver_{this};
network::mojom::URLLoaderClientPtr client_;
mojo::Remote<network::mojom::URLLoaderClient> client_;
// In case of successful loads, this holds the total number of bytes written
// to the response (this may be smaller than the total size of the file when
@ -298,15 +302,15 @@ class AsarURLLoader : public network::mojom::URLLoader {
void CreateAsarURLLoader(
const network::ResourceRequest& request,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
auto task_runner = base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
task_runner->PostTask(
FROM_HERE, base::BindOnce(&AsarURLLoader::CreateAndStart, request,
std::move(loader), client.PassInterface(),
std::move(extra_response_headers)));
FROM_HERE,
base::BindOnce(&AsarURLLoader::CreateAndStart, request, std::move(loader),
std::move(client), std::move(extra_response_headers)));
}
} // namespace asar

View file

@ -5,6 +5,7 @@
#ifndef SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_H_
#define SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_H_
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/network/public/mojom/url_loader.mojom.h"
namespace asar {
@ -12,7 +13,7 @@ namespace asar {
void CreateAsarURLLoader(
const network::ResourceRequest& request,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers);
} // namespace asar

View file

@ -141,7 +141,7 @@ network::ResourceResponseHead ToResponseHead(
// Helper to write string to pipe.
struct WriteData {
network::mojom::URLLoaderClientPtr client;
mojo::Remote<network::mojom::URLLoaderClient> client;
std::string data;
std::unique_ptr<mojo::DataPipeProducer> producer;
};
@ -173,7 +173,7 @@ void AtomURLLoaderFactory::CreateLoaderAndStart(
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
handler_.Run(
@ -195,7 +195,7 @@ void AtomURLLoaderFactory::StartLoading(
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
network::mojom::URLLoaderFactory* proxy_factory,
ProtocolType type,
@ -206,7 +206,9 @@ void AtomURLLoaderFactory::StartLoading(
// passed, to keep compatibility with old code.
v8::Local<v8::Value> response;
if (!args->GetNext(&response)) {
client->OnComplete(
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_NOT_IMPLEMENTED));
return;
}
@ -216,7 +218,9 @@ void AtomURLLoaderFactory::StartLoading(
if (!dict.IsEmpty()) {
int error_code;
if (dict.Get("error", &error_code)) {
client->OnComplete(network::URLLoaderCompletionStatus(error_code));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(network::URLLoaderCompletionStatus(error_code));
return;
}
}
@ -260,7 +264,9 @@ void AtomURLLoaderFactory::StartLoading(
// Some protocol accepts non-object responses.
if (dict.IsEmpty() && ResponseMustBeObject(type)) {
client->OnComplete(
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_NOT_IMPLEMENTED));
return;
}
@ -288,7 +294,10 @@ void AtomURLLoaderFactory::StartLoading(
case ProtocolType::kFree:
ProtocolType type;
if (!gin::ConvertFromV8(args->isolate(), response, &type)) {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
StartLoading(std::move(loader), routing_id, request_id, options, request,
@ -300,13 +309,16 @@ void AtomURLLoaderFactory::StartLoading(
// static
void AtomURLLoaderFactory::StartLoadingBuffer(
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict) {
v8::Local<v8::Value> buffer = dict.GetHandle();
dict.Get("data", &buffer);
if (!node::Buffer::HasInstance(buffer)) {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
@ -317,7 +329,7 @@ void AtomURLLoaderFactory::StartLoadingBuffer(
// static
void AtomURLLoaderFactory::StartLoadingString(
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict,
v8::Isolate* isolate,
@ -328,7 +340,10 @@ void AtomURLLoaderFactory::StartLoadingString(
} else if (!dict.IsEmpty()) {
dict.Get("data", &contents);
} else {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
@ -339,7 +354,7 @@ void AtomURLLoaderFactory::StartLoadingString(
void AtomURLLoaderFactory::StartLoadingFile(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
network::ResourceRequest request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict,
v8::Isolate* isolate,
@ -353,7 +368,10 @@ void AtomURLLoaderFactory::StartLoadingFile(
if (dict.Get("path", &path))
request.url = net::FilePathToFileURL(path);
} else {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
@ -366,7 +384,7 @@ void AtomURLLoaderFactory::StartLoadingFile(
void AtomURLLoaderFactory::StartLoadingHttp(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
const network::ResourceRequest& original_request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
const gin_helper::Dictionary& dict) {
auto request = std::make_unique<network::ResourceRequest>();
@ -407,7 +425,7 @@ void AtomURLLoaderFactory::StartLoadingHttp(
// static
void AtomURLLoaderFactory::StartLoadingStream(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict) {
v8::Local<v8::Value> stream;
@ -415,25 +433,30 @@ void AtomURLLoaderFactory::StartLoadingStream(
// Assume the opts is already a stream.
stream = dict.GetHandle();
} else if (stream->IsNullOrUndefined()) {
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
// "data" was explicitly passed as null or undefined, assume the user wants
// to send an empty body.
//
// Note that We must submit a empty body otherwise NetworkService would
// crash.
client->OnReceiveResponse(head);
client_remote->OnReceiveResponse(head);
mojo::ScopedDataPipeProducerHandle producer;
mojo::ScopedDataPipeConsumerHandle consumer;
if (mojo::CreateDataPipe(nullptr, &producer, &consumer) != MOJO_RESULT_OK) {
client->OnComplete(
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
return;
}
producer.reset(); // The data pipe is empty.
client->OnStartLoadingResponseBody(std::move(consumer));
client->OnComplete(network::URLLoaderCompletionStatus(net::OK));
client_remote->OnStartLoadingResponseBody(std::move(consumer));
client_remote->OnComplete(network::URLLoaderCompletionStatus(net::OK));
return;
} else if (!stream->IsObject()) {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
@ -441,7 +464,10 @@ void AtomURLLoaderFactory::StartLoadingStream(
v8::Local<v8::Value> method;
if (!data.Get("on", &method) || !method->IsFunction() ||
!data.Get("removeListener", &method) || !method->IsFunction()) {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_FAILED));
return;
}
@ -451,25 +477,27 @@ void AtomURLLoaderFactory::StartLoadingStream(
// static
void AtomURLLoaderFactory::SendContents(
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
std::string data) {
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
head.headers->AddHeader(kCORSHeader);
client->OnReceiveResponse(head);
client_remote->OnReceiveResponse(head);
// Code bellow follows the pattern of data_url_loader_factory.cc.
mojo::ScopedDataPipeProducerHandle producer;
mojo::ScopedDataPipeConsumerHandle consumer;
if (mojo::CreateDataPipe(nullptr, &producer, &consumer) != MOJO_RESULT_OK) {
client->OnComplete(
client_remote->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
return;
}
client->OnStartLoadingResponseBody(std::move(consumer));
client_remote->OnStartLoadingResponseBody(std::move(consumer));
auto write_data = std::make_unique<WriteData>();
write_data->client = std::move(client);
write_data->client = std::move(client_remote);
write_data->data = std::move(data);
write_data->producer =
std::make_unique<mojo::DataPipeProducer>(std::move(producer));

View file

@ -10,7 +10,9 @@
#include <utility>
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/url_request/url_request_job_factory.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
@ -49,7 +51,7 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
@ -61,25 +63,27 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
network::mojom::URLLoaderFactory* proxy_factory,
ProtocolType type,
gin::Arguments* args);
private:
static void StartLoadingBuffer(network::mojom::URLLoaderClientPtr client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict);
static void StartLoadingString(network::mojom::URLLoaderClientPtr client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict,
v8::Isolate* isolate,
v8::Local<v8::Value> response);
static void StartLoadingBuffer(
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict);
static void StartLoadingString(
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict,
v8::Isolate* isolate,
v8::Local<v8::Value> response);
static void StartLoadingFile(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
network::ResourceRequest request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict,
v8::Isolate* isolate,
@ -87,19 +91,20 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
static void StartLoadingHttp(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
const network::ResourceRequest& original_request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
const gin_helper::Dictionary& dict);
static void StartLoadingStream(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
const gin_helper::Dictionary& dict);
// Helper to send string as response.
static void SendContents(network::mojom::URLLoaderClientPtr client,
network::ResourceResponseHead head,
std::string data);
static void SendContents(
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
network::ResourceResponseHead head,
std::string data);
// TODO(zcbenz): This comes from extensions/browser/extension_protocols.cc
// but I don't know what it actually does, find out the meanings of |Clone|

View file

@ -12,11 +12,12 @@
namespace electron {
NodeStreamLoader::NodeStreamLoader(network::ResourceResponseHead head,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
v8::Isolate* isolate,
v8::Local<v8::Object> emitter)
NodeStreamLoader::NodeStreamLoader(
network::ResourceResponseHead head,
network::mojom::URLLoaderRequest loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
v8::Isolate* isolate,
v8::Local<v8::Object> emitter)
: binding_(this, std::move(loader)),
client_(std::move(client)),
isolate_(isolate),
@ -53,7 +54,6 @@ void NodeStreamLoader::Start(network::ResourceResponseHead head) {
}
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
client_->OnReceiveResponse(head);
client_->OnStartLoadingResponseBody(std::move(consumer));

View file

@ -10,6 +10,8 @@
#include <string>
#include <vector>
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "services/network/public/cpp/resource_response.h"
@ -30,7 +32,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
public:
NodeStreamLoader(network::ResourceResponseHead head,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
v8::Isolate* isolate,
v8::Local<v8::Object> emitter);
@ -58,7 +60,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
void ResumeReadingBodyFromNet() override {}
mojo::Binding<network::mojom::URLLoader> binding_;
network::mojom::URLLoaderClientPtr client_;
mojo::Remote<network::mojom::URLLoaderClient> client_;
v8::Isolate* isolate_;
v8::Global<v8::Object> emitter_;

View file

@ -40,7 +40,7 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
const network::ResourceRequest& request,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
network::mojom::URLLoaderRequest loader_request,
network::mojom::URLLoaderClientPtr client)
mojo::PendingRemote<network::mojom::URLLoaderClient> client)
: factory_(factory),
request_(request),
original_initiator_(request.request_initiator),
@ -52,13 +52,12 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
proxied_loader_binding_(this, std::move(loader_request)),
target_client_(std::move(client)),
current_response_(network::mojom::URLResponseHead::New()),
proxied_client_binding_(this),
// Always use "extraHeaders" mode to be compatible with old APIs, except
// when the |request_id_| is zero, which is not supported in Chromium and
// only happens in Electron when the request is started from net module.
has_any_extra_headers_listeners_(network_service_request_id != 0) {
// If there is a client error, clean up the request.
target_client_.set_connection_error_handler(base::BindOnce(
target_client_.set_disconnect_handler(base::BindOnce(
&ProxyingURLLoaderFactory::InProgressRequest::OnRequestError,
weak_factory_.GetWeakPtr(),
network::URLLoaderCompletionStatus(net::ERR_ABORTED)));
@ -97,7 +96,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::UpdateRequestInfo() {
request_id_, factory_->render_process_id_, request_.render_frame_id,
nullptr, routing_id_, request_for_info, false,
!(options_ & network::mojom::kURLLoadOptionSynchronous),
factory_->IsForServiceWorkerScript()));
factory_->IsForServiceWorkerScript(), factory_->navigation_id_));
current_request_uses_header_client_ =
factory_->url_loader_header_client_receiver_.is_bound() &&
@ -138,8 +137,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::RestartInternal() {
// continue or cancel the request.
//
// We pause the binding here to prevent further client message processing.
if (proxied_client_binding_.is_bound())
proxied_client_binding_.PauseIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Pause();
// Pause the header client, since we want to wait until OnBeforeRequest has
// finished before processing any future events.
@ -332,8 +331,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeSendHeaders(
return;
}
if (proxied_client_binding_.is_bound())
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
auto continuation = base::BindRepeating(
&InProgressRequest::ContinueToSendHeaders, weak_factory_.GetWeakPtr());
@ -353,9 +352,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeSendHeaders(
// they respond. |continuation| above will be invoked asynchronously to
// continue or cancel the request.
//
// We pause the binding here to prevent further client message processing.
if (proxied_client_binding_.is_bound())
proxied_client_binding_.PauseIncomingMethodCallProcessing();
// We pause the receiver here to prevent further client message processing.
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
return;
}
DCHECK_EQ(net::OK, result);
@ -402,8 +401,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToSendHeaders(
pending_follow_redirect_params_.reset();
}
if (proxied_client_binding_.is_bound())
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
// Note: In Electron onSendHeaders is called for all protocols.
factory_->web_request_api()->OnSendHeaders(&info_.value(), request_,
@ -425,8 +424,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
return;
}
if (proxied_client_binding_.is_bound())
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
if (header_client_receiver_.is_bound())
header_client_receiver_.Resume();
@ -434,8 +433,6 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
if (!target_loader_.is_bound() && factory_->target_factory_.is_bound()) {
// No extensions have cancelled us up to this point, so it's now OK to
// initiate the real network request.
network::mojom::URLLoaderClientPtr proxied_client;
proxied_client_binding_.Bind(mojo::MakeRequest(&proxied_client));
uint32_t options = options_;
// Even if this request does not use the header client, future redirects
// might, so we need to set the option on the loader.
@ -444,11 +441,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
factory_->target_factory_->CreateLoaderAndStart(
mojo::MakeRequest(&target_loader_), routing_id_,
network_service_request_id_, options, request_,
std::move(proxied_client), traffic_annotation_);
proxied_client_receiver_.BindNewPipeAndPassRemote(),
traffic_annotation_);
}
// From here the lifecycle of this request is driven by subsequent events on
// either |proxy_loader_binding_|, |proxy_client_binding_|, or
// either |proxy_loader_binding_|, |proxy_client_receiver_|, or
// |header_client_receiver_|.
}
@ -473,8 +471,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::
std::move(on_headers_received_callback_).Run(net::OK, headers, redirect_url_);
override_headers_ = nullptr;
if (proxied_client_binding_)
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
}
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
@ -508,7 +506,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
// These will get re-bound if a new request is initiated by
// |FollowRedirect()|.
proxied_client_binding_.Close();
proxied_client_receiver_.reset();
header_client_receiver_.reset();
target_loader_.reset();
@ -518,7 +516,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
info_->AddResponseInfoFromResourceResponse(*current_response_);
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
proxied_client_receiver_.Resume();
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
target_client_->OnReceiveResponse(std::move(current_response_));
@ -534,8 +532,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
info_->AddResponseInfoFromResourceResponse(*current_response_);
if (proxied_client_binding_.is_bound())
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
factory_->web_request_api()->OnBeforeRedirect(&info_.value(), request_,
redirect_info.new_url);
@ -566,7 +564,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::
// bugs. The latter doesn't know anything about the redirect. Continuing
// the load with it gives unexpected results. See
// https://crbug.com/882661#c72.
proxied_client_binding_.Close();
proxied_client_receiver_.reset();
header_client_receiver_.reset();
target_loader_.reset();
@ -647,8 +645,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::
// they respond. |continuation| above will be invoked asynchronously to
// continue or cancel the request.
//
// We pause the binding here to prevent further client message processing.
proxied_client_binding_.PauseIncomingMethodCallProcessing();
// We pause the receiver here to prevent further client message processing.
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Pause();
return;
}
@ -674,6 +673,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
const HandlersMap& intercepted_handlers,
content::BrowserContext* browser_context,
int render_process_id,
base::Optional<int64_t> navigation_id,
network::mojom::URLLoaderFactoryRequest loader_request,
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote,
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
@ -683,6 +683,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
intercepted_handlers_(intercepted_handlers),
browser_context_(browser_context),
render_process_id_(render_process_id),
navigation_id_(std::move(navigation_id)),
loader_factory_type_(loader_factory_type) {
target_factory_.Bind(std::move(target_factory_remote));
target_factory_.set_disconnect_handler(base::BindOnce(
@ -718,7 +719,7 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
int32_t request_id,
uint32_t options,
const network::ResourceRequest& original_request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
// Take a copy so we can mutate the request.
network::ResourceRequest request = original_request;

View file

@ -93,7 +93,7 @@ class ProxyingURLLoaderFactory
const network::ResourceRequest& request,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
network::mojom::URLLoaderRequest loader_request,
network::mojom::URLLoaderClientPtr client);
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
~InProgressRequest() override;
void Restart();
@ -158,7 +158,7 @@ class ProxyingURLLoaderFactory
const uint32_t options_;
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
mojo::Binding<network::mojom::URLLoader> proxied_loader_binding_;
network::mojom::URLLoaderClientPtr target_client_;
mojo::Remote<network::mojom::URLLoaderClient> target_client_;
base::Optional<extensions::WebRequestInfo> info_;
@ -166,7 +166,8 @@ class ProxyingURLLoaderFactory
scoped_refptr<net::HttpResponseHeaders> override_headers_;
GURL redirect_url_;
mojo::Binding<network::mojom::URLLoaderClient> proxied_client_binding_;
mojo::Receiver<network::mojom::URLLoaderClient> proxied_client_receiver_{
this};
network::mojom::URLLoaderPtr target_loader_;
bool request_completed_ = false;
@ -209,6 +210,7 @@ class ProxyingURLLoaderFactory
const HandlersMap& intercepted_handlers,
content::BrowserContext* browser_context,
int render_process_id,
base::Optional<int64_t> navigation_id,
network::mojom::URLLoaderFactoryRequest loader_request,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
target_factory_remote,
@ -224,7 +226,7 @@ class ProxyingURLLoaderFactory
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory>
@ -266,6 +268,7 @@ class ProxyingURLLoaderFactory
content::BrowserContext* const browser_context_;
const int render_process_id_;
base::Optional<int64_t> navigation_id_;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_;
mojo::Remote<network::mojom::URLLoaderFactory> target_factory_;
mojo::Receiver<network::mojom::TrustedURLLoaderHeaderClient>

View file

@ -56,6 +56,7 @@ void ResolveProxyHelper::StartPendingRequest() {
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
->GetNetworkContext()
->LookUpProxyForURL(pending_requests_.front().url,
net::NetworkIsolationKey::Todo(),
std::move(proxy_lookup_client));
}

View file

@ -18,7 +18,7 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "net/net_buildflags.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h"
#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "shell/browser/atom_browser_client.h"
@ -75,7 +75,7 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
int32_t request_id,
uint32_t options,
const network::ResourceRequest& url_request,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -94,10 +94,10 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
}
// SharedURLLoaderFactory implementation:
std::unique_ptr<network::SharedURLLoaderFactoryInfo> Clone() override {
std::unique_ptr<network::PendingSharedURLLoaderFactory> Clone() override {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return std::make_unique<network::CrossThreadSharedURLLoaderFactoryInfo>(
return std::make_unique<network::CrossThreadPendingSharedURLLoaderFactory>(
this);
}

View file

@ -6,6 +6,7 @@
#include <utility>
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/system/string_data_source.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@ -15,7 +16,7 @@ URLPipeLoader::URLPipeLoader(
scoped_refptr<network::SharedURLLoaderFactory> factory,
std::unique_ptr<network::ResourceRequest> request,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::NetworkTrafficAnnotationTag& annotation,
base::DictionaryValue upload_data)
: binding_(this, std::move(loader)),

View file

@ -9,6 +9,8 @@
#include <string>
#include <vector>
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "services/network/public/cpp/simple_url_loader.h"
@ -34,7 +36,7 @@ class URLPipeLoader : public network::mojom::URLLoader,
URLPipeLoader(scoped_refptr<network::SharedURLLoaderFactory> factory,
std::unique_ptr<network::ResourceRequest> request,
network::mojom::URLLoaderRequest loader,
network::mojom::URLLoaderClientPtr client,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::NetworkTrafficAnnotationTag& annotation,
base::DictionaryValue upload_data);
@ -66,7 +68,7 @@ class URLPipeLoader : public network::mojom::URLLoader,
void ResumeReadingBodyFromNet() override {}
mojo::Binding<network::mojom::URLLoader> binding_;
network::mojom::URLLoaderClientPtr client_;
mojo::Remote<network::mojom::URLLoaderClient> client_;
std::unique_ptr<mojo::DataPipeProducer> producer_;
std::unique_ptr<network::SimpleURLLoader> loader_;