chore: tidy up usage of PendingRemote (#26176)

This commit is contained in:
David Sanders 2020-10-27 12:20:41 -07:00 committed by GitHub
parent 430cef8a62
commit 98b0ccbdb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View file

@ -213,9 +213,11 @@ void ElectronURLLoaderFactory::OnComplete(
mojo::PendingRemote<network::mojom::URLLoaderClient> client, mojo::PendingRemote<network::mojom::URLLoaderClient> client,
int32_t request_id, int32_t request_id,
const network::URLLoaderCompletionStatus& status) { const network::URLLoaderCompletionStatus& status) {
if (client.is_valid()) {
mojo::Remote<network::mojom::URLLoaderClient> client_remote( mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client)); std::move(client));
client_remote->OnComplete(status); client_remote->OnComplete(status);
}
} }
// static // static
@ -294,14 +296,13 @@ void ElectronURLLoaderFactory::StartLoading(
// module. // module.
// //
// I'm not sure whether this is an intended behavior in Chromium. // I'm not sure whether this is an intended behavior in Chromium.
if (proxy_factory.is_valid()) {
mojo::Remote<network::mojom::URLLoaderFactory> proxy_factory_remote( mojo::Remote<network::mojom::URLLoaderFactory> proxy_factory_remote(
std::move(proxy_factory)); std::move(proxy_factory));
if (proxy_factory_remote.is_bound()) {
proxy_factory_remote->CreateLoaderAndStart( proxy_factory_remote->CreateLoaderAndStart(
std::move(loader), routing_id, request_id, options, new_request, std::move(loader), routing_id, request_id, options, new_request,
std::move(client), traffic_annotation); std::move(client), traffic_annotation);
proxy_factory = proxy_factory_remote.Unbind();
} else { } else {
StartLoadingHttp(std::move(loader), new_request, std::move(client), StartLoadingHttp(std::move(loader), new_request, std::move(client),
traffic_annotation, traffic_annotation,

View file

@ -802,8 +802,8 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
// Check if user has intercepted this scheme. // Check if user has intercepted this scheme.
auto it = intercepted_handlers_.find(request.url.scheme()); auto it = intercepted_handlers_.find(request.url.scheme());
if (it != intercepted_handlers_.end()) { if (it != intercepted_handlers_.end()) {
mojo::Remote<network::mojom::URLLoaderFactory> loader_remote; mojo::PendingRemote<network::mojom::URLLoaderFactory> loader_remote;
this->Clone(loader_remote.BindNewPipeAndPassReceiver()); this->Clone(loader_remote.InitWithNewPipeAndPassReceiver());
// <scheme, <type, handler>> // <scheme, <type, handler>>
it->second.second.Run( it->second.second.Run(
@ -811,7 +811,7 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
base::BindOnce(&ElectronURLLoaderFactory::StartLoading, base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
std::move(loader), routing_id, request_id, options, std::move(loader), routing_id, request_id, options,
request, std::move(client), traffic_annotation, request, std::move(client), traffic_annotation,
loader_remote.Unbind(), it->second.first)); std::move(loader_remote), it->second.first));
return; return;
} }