mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858 NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart calls std::make_unique<InProgressRequest>, which needs a routing_id. This PR uses the member field `routing_id_` since there's no longer one being passed into CreateLoaderAndStart.
This commit is contained in:
committed by
Samuel Attard
parent
4e33ee0ad3
commit
70759ad342
@@ -1334,7 +1334,6 @@ class FileURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
|
||||
@@ -29,7 +29,6 @@ AsarURLLoaderFactory::~AsarURLLoaderFactory() = default;
|
||||
|
||||
void AsarURLLoaderFactory::CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
|
||||
@@ -24,7 +24,6 @@ class AsarURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
|
||||
@@ -192,7 +192,6 @@ ElectronURLLoaderFactory::~ElectronURLLoaderFactory() = default;
|
||||
|
||||
void ElectronURLLoaderFactory::CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
@@ -200,11 +199,11 @@ void ElectronURLLoaderFactory::CreateLoaderAndStart(
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> proxy_factory;
|
||||
handler_.Run(request, base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
|
||||
std::move(loader), routing_id,
|
||||
request_id, options, request,
|
||||
std::move(client), traffic_annotation,
|
||||
std::move(proxy_factory), type_));
|
||||
handler_.Run(
|
||||
request,
|
||||
base::BindOnce(&ElectronURLLoaderFactory::StartLoading, std::move(loader),
|
||||
request_id, options, request, std::move(client),
|
||||
traffic_annotation, std::move(proxy_factory), type_));
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -222,7 +221,6 @@ void ElectronURLLoaderFactory::OnComplete(
|
||||
// static
|
||||
void ElectronURLLoaderFactory::StartLoading(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
@@ -312,7 +310,7 @@ void ElectronURLLoaderFactory::StartLoading(
|
||||
std::move(proxy_factory));
|
||||
|
||||
proxy_factory_remote->CreateLoaderAndStart(
|
||||
std::move(loader), routing_id, request_id, options, new_request,
|
||||
std::move(loader), request_id, options, new_request,
|
||||
std::move(client), traffic_annotation);
|
||||
} else {
|
||||
StartLoadingHttp(std::move(loader), new_request, std::move(client),
|
||||
@@ -356,7 +354,7 @@ void ElectronURLLoaderFactory::StartLoading(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
StartLoading(std::move(loader), routing_id, request_id, options, request,
|
||||
StartLoading(std::move(loader), request_id, options, request,
|
||||
std::move(client), traffic_annotation,
|
||||
std::move(proxy_factory), type, args);
|
||||
break;
|
||||
|
||||
@@ -49,7 +49,6 @@ class ElectronURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
@@ -59,7 +58,6 @@ class ElectronURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
|
||||
static void StartLoading(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
|
||||
@@ -513,9 +513,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
|
||||
if (has_any_extra_headers_listeners_)
|
||||
options |= network::mojom::kURLLoadOptionUseHeaderClient;
|
||||
factory_->target_factory_->CreateLoaderAndStart(
|
||||
mojo::MakeRequest(&target_loader_), routing_id_,
|
||||
network_service_request_id_, options, request_,
|
||||
proxied_client_receiver_.BindNewPipeAndPassRemote(),
|
||||
mojo::MakeRequest(&target_loader_), network_service_request_id_,
|
||||
options, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(),
|
||||
traffic_annotation_);
|
||||
}
|
||||
|
||||
@@ -790,7 +789,6 @@ bool ProxyingURLLoaderFactory::ShouldIgnoreConnectionsLimit(
|
||||
|
||||
void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& original_request,
|
||||
@@ -812,11 +810,10 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
||||
|
||||
// <scheme, <type, handler>>
|
||||
it->second.second.Run(
|
||||
request,
|
||||
base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
|
||||
std::move(loader), routing_id, request_id, options,
|
||||
request, std::move(client), traffic_annotation,
|
||||
std::move(loader_remote), it->second.first));
|
||||
request, base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
|
||||
std::move(loader), request_id, options, request,
|
||||
std::move(client), traffic_annotation,
|
||||
std::move(loader_remote), it->second.first));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -832,9 +829,9 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
||||
|
||||
if (!web_request_api()->HasListener()) {
|
||||
// Pass-through to the original factory.
|
||||
target_factory_->CreateLoaderAndStart(
|
||||
std::move(loader), routing_id, request_id, options, request,
|
||||
std::move(client), traffic_annotation);
|
||||
target_factory_->CreateLoaderAndStart(std::move(loader), request_id,
|
||||
options, request, std::move(client),
|
||||
traffic_annotation);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -854,7 +851,7 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
||||
auto result = requests_.emplace(
|
||||
web_request_id,
|
||||
std::make_unique<InProgressRequest>(
|
||||
this, web_request_id, routing_id, request_id, options, request,
|
||||
this, web_request_id, routing_id_, request_id, options, request,
|
||||
traffic_annotation, std::move(loader), std::move(client)));
|
||||
result.first->second->Restart();
|
||||
}
|
||||
|
||||
@@ -191,7 +191,6 @@ class ProxyingURLLoaderFactory
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
|
||||
@@ -73,7 +73,6 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
|
||||
// mojom::URLLoaderFactory implementation:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> request,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& url_request,
|
||||
@@ -84,8 +83,8 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
|
||||
if (!manager_)
|
||||
return;
|
||||
manager_->GetURLLoaderFactory()->CreateLoaderAndStart(
|
||||
std::move(request), routing_id, request_id, options, url_request,
|
||||
std::move(client), traffic_annotation);
|
||||
std::move(request), request_id, options, url_request, std::move(client),
|
||||
traffic_annotation);
|
||||
}
|
||||
|
||||
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
|
||||
|
||||
@@ -13,6 +13,46 @@
|
||||
|
||||
namespace electron {
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
namespace {
|
||||
|
||||
// Provide support for accessing asar archives in file:// protocol.
|
||||
class AsarURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
public:
|
||||
static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create() {
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote;
|
||||
|
||||
// The AsarURLLoaderFactory will delete itself when there are no more
|
||||
// receivers - see the SelfDeletingURLLoaderFactory::OnDisconnect method.
|
||||
new AsarURLLoaderFactory(pending_remote.InitWithNewPipeAndPassReceiver());
|
||||
|
||||
return pending_remote;
|
||||
}
|
||||
|
||||
private:
|
||||
AsarURLLoaderFactory(
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver)
|
||||
: network::SelfDeletingURLLoaderFactory(std::move(factory_receiver)) {}
|
||||
~AsarURLLoaderFactory() override = default;
|
||||
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
|
||||
override {
|
||||
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
|
||||
new net::HttpResponseHeaders(""));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
>>>>>>> refactor: remove routing_id from CreateLoaderAndStart
|
||||
// static
|
||||
ProtocolRegistry* ProtocolRegistry::FromBrowserContext(
|
||||
content::BrowserContext* context) {
|
||||
|
||||
Reference in New Issue
Block a user