Commit eea83424 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert WrapperSharedURLLoaderFactoryInfo to new Mojo types

This CL converts WrapperSharedURLLoaderFactoryInfo to new Mojo types
using PendingRemote and Remote.

It also updates |script_loader_factory_ptr_info| from
service_worker_provider.mojom to |script_loader_factory_remote|
using pending_remote.

Bug: 955171
Change-Id: I71682eea94a2f297261f1374aa3f43d7f8897b7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861814
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#707641}
parent 9c981fb3
...@@ -67,7 +67,8 @@ ...@@ -67,7 +67,8 @@
#include "content/public/common/referrer.h" #include "content/public/common/referrer.h"
#include "content/public/common/url_utils.h" #include "content/public/common/url_utils.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/elements_upload_data_stream.h" #include "net/base/elements_upload_data_stream.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
...@@ -268,13 +269,12 @@ CreateSharedURLLoaderFactoryInfo(StoragePartitionImpl* storage_partition, ...@@ -268,13 +269,12 @@ CreateSharedURLLoaderFactoryInfo(StoragePartitionImpl* storage_partition,
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
CreateSharedURLLoaderFactoryInfoFromURLLoaderFactory( CreateSharedURLLoaderFactoryInfoFromURLLoaderFactory(
std::unique_ptr<network::mojom::URLLoaderFactory> factory) { std::unique_ptr<network::mojom::URLLoaderFactory> factory) {
network::mojom::URLLoaderFactoryPtr factory_ptr; mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
mojo::MakeStrongBinding(std::move(factory), mojo::MakeRequest(&factory_ptr)); mojo::MakeSelfOwnedReceiver(std::move(factory),
network::mojom::URLLoaderFactoryPtrInfo factory_ptr_info = factory_remote.InitWithNewPipeAndPassReceiver());
factory_ptr.PassInterface();
return std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>( return std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(
std::move(factory_ptr_info)); std::move(factory_remote));
} }
} // namespace } // namespace
......
...@@ -1365,12 +1365,13 @@ NavigationURLLoaderImpl::NavigationURLLoaderImpl( ...@@ -1365,12 +1365,13 @@ NavigationURLLoaderImpl::NavigationURLLoaderImpl(
partition->GetURLLoaderFactoryForBrowserProcess()->Clone(); partition->GetURLLoaderFactoryForBrowserProcess()->Clone();
if (header_client) { if (header_client) {
needs_loader_factory_interceptor = true; needs_loader_factory_interceptor = true;
network::mojom::URLLoaderFactoryPtrInfo factory_info; mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
CreateURLLoaderFactoryWithHeaderClient( CreateURLLoaderFactoryWithHeaderClient(
std::move(header_client), mojo::MakeRequest(&factory_info), partition); std::move(header_client),
factory_remote.InitWithNewPipeAndPassReceiver(), partition);
network_factory_info = network_factory_info =
std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>( std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(
std::move(factory_info)); std::move(factory_remote));
} }
DCHECK(!request_controller_); DCHECK(!request_controller_);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/public/browser/ssl_status.h" #include "content/public/browser/ssl_status.h"
#include "content/public/common/previews_state.h" #include "content/public/common/previews_state.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/loader/url_loader_factory_bundle.mojom.h" #include "third_party/blink/public/mojom/loader/url_loader_factory_bundle.mojom.h"
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom.h" #include "third_party/blink/public/mojom/renderer_preference_watcher.mojom.h"
...@@ -662,8 +662,8 @@ class EmbeddedWorkerInstance::StartTask { ...@@ -662,8 +662,8 @@ class EmbeddedWorkerInstance::StartTask {
// this is a non-installed service worker. // this is a non-installed service worker.
DCHECK(factory_bundle_for_new_scripts || is_installed_); DCHECK(factory_bundle_for_new_scripts || is_installed_);
if (factory_bundle_for_new_scripts) { if (factory_bundle_for_new_scripts) {
params->provider_info->script_loader_factory_ptr_info = params->provider_info->script_loader_factory_remote =
instance_->MakeScriptLoaderFactoryPtrInfo( instance_->MakeScriptLoaderFactoryRemote(
std::move(factory_bundle_for_new_scripts)); std::move(factory_bundle_for_new_scripts));
} }
...@@ -1296,21 +1296,22 @@ void EmbeddedWorkerInstance::NotifyForegroundServiceWorkerRemoved() { ...@@ -1296,21 +1296,22 @@ void EmbeddedWorkerInstance::NotifyForegroundServiceWorkerRemoved() {
} }
} }
network::mojom::URLLoaderFactoryPtrInfo mojo::PendingRemote<network::mojom::URLLoaderFactory>
EmbeddedWorkerInstance::MakeScriptLoaderFactoryPtrInfo( EmbeddedWorkerInstance::MakeScriptLoaderFactoryRemote(
std::unique_ptr<blink::URLLoaderFactoryBundleInfo> script_bundle) { std::unique_ptr<blink::URLLoaderFactoryBundleInfo> script_bundle) {
network::mojom::URLLoaderFactoryPtrInfo script_loader_factory_ptr_info; mojo::PendingRemote<network::mojom::URLLoaderFactory>
script_loader_factory_remote;
auto script_bundle_factory = auto script_bundle_factory =
base::MakeRefCounted<blink::URLLoaderFactoryBundle>( base::MakeRefCounted<blink::URLLoaderFactoryBundle>(
std::move(script_bundle)); std::move(script_bundle));
script_loader_factory_ = mojo::MakeStrongBinding( script_loader_factory_ = mojo::MakeSelfOwnedReceiver(
std::make_unique<ServiceWorkerScriptLoaderFactory>( std::make_unique<ServiceWorkerScriptLoaderFactory>(
context_, owner_version_->provider_host()->AsWeakPtr(), context_, owner_version_->provider_host()->AsWeakPtr(),
std::move(script_bundle_factory)), std::move(script_bundle_factory)),
mojo::MakeRequest(&script_loader_factory_ptr_info)); script_loader_factory_remote.InitWithNewPipeAndPassReceiver());
return script_loader_factory_ptr_info; return script_loader_factory_remote;
} }
} // namespace content } // namespace content
...@@ -315,7 +315,8 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -315,7 +315,8 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
void NotifyForegroundServiceWorkerAdded(); void NotifyForegroundServiceWorkerAdded();
void NotifyForegroundServiceWorkerRemoved(); void NotifyForegroundServiceWorkerRemoved();
network::mojom::URLLoaderFactoryPtrInfo MakeScriptLoaderFactoryPtrInfo( mojo::PendingRemote<network::mojom::URLLoaderFactory>
MakeScriptLoaderFactoryRemote(
std::unique_ptr<blink::URLLoaderFactoryBundleInfo> script_bundle); std::unique_ptr<blink::URLLoaderFactoryBundleInfo> script_bundle);
base::WeakPtr<ServiceWorkerContextCore> context_; base::WeakPtr<ServiceWorkerContextCore> context_;
......
...@@ -80,7 +80,7 @@ void FakeEmbeddedWorkerInstanceClient::StartWorker( ...@@ -80,7 +80,7 @@ void FakeEmbeddedWorkerInstanceClient::StartWorker(
// storage. We do that manually here. // storage. We do that manually here.
// //
// TODO(falken): For new workers, this should use // TODO(falken): For new workers, this should use
// |script_loader_factory_ptr_info| from |start_params_->provider_info| // |script_loader_factory_remote| from |start_params_->provider_info|
// to request the script and the browser process should be able to mock it. // to request the script and the browser process should be able to mock it.
// For installed workers, the map should already be populated. // For installed workers, the map should already be populated.
ServiceWorkerVersion* version = helper_->context()->GetLiveVersion( ServiceWorkerVersion* version = helper_->context()->GetLiveVersion(
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "content/browser/service_worker/service_worker_navigation_handle_core.h" #include "content/browser/service_worker/service_worker_navigation_handle_core.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/test/fake_network_url_loader_factory.h" #include "content/test/fake_network_url_loader_factory.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/network_isolation_key.h" #include "net/base/network_isolation_key.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
...@@ -46,8 +47,9 @@ class WorkerScriptLoaderFactoryTest : public testing::Test { ...@@ -46,8 +47,9 @@ class WorkerScriptLoaderFactoryTest : public testing::Test {
// Set up the network factory. // Set up the network factory.
network_loader_factory_instance_ = network_loader_factory_instance_ =
std::make_unique<FakeNetworkURLLoaderFactory>(); std::make_unique<FakeNetworkURLLoaderFactory>();
network::mojom::URLLoaderFactoryPtrInfo factory; mojo::PendingRemote<network::mojom::URLLoaderFactory> factory;
network_loader_factory_instance_->Clone(mojo::MakeRequest(&factory)); network_loader_factory_instance_->Clone(
factory.InitWithNewPipeAndPassReceiver());
auto info = std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>( auto info = std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(
std::move(factory)); std::move(factory));
network_loader_factory_ = network_loader_factory_ =
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "content/renderer/service_worker/navigation_preload_request.h" #include "content/renderer/service_worker/navigation_preload_request.h"
#include "content/renderer/service_worker/service_worker_fetch_context_impl.h" #include "content/renderer/service_worker/service_worker_fetch_context_impl.h"
#include "content/renderer/service_worker/service_worker_type_converters.h" #include "content/renderer/service_worker/service_worker_type_converters.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
...@@ -377,7 +378,7 @@ ServiceWorkerContextClient::CreateWorkerFetchContextOnInitiatorThread() { ...@@ -377,7 +378,7 @@ ServiceWorkerContextClient::CreateWorkerFetchContextOnInitiatorThread() {
// URLLoaderFactoryInfo. // URLLoaderFactoryInfo.
auto script_loader_factory_info = auto script_loader_factory_info =
std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(std::move( std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(std::move(
service_worker_provider_info_->script_loader_factory_ptr_info)); service_worker_provider_info_->script_loader_factory_remote));
return base::MakeRefCounted<ServiceWorkerFetchContextImpl>( return base::MakeRefCounted<ServiceWorkerFetchContextImpl>(
*renderer_preferences_, script_url_, loader_factories_->PassInterface(), *renderer_preferences_, script_url_, loader_factories_->PassInterface(),
......
...@@ -239,7 +239,7 @@ class CONTENT_EXPORT ServiceWorkerContextClient ...@@ -239,7 +239,7 @@ class CONTENT_EXPORT ServiceWorkerContextClient
// This holds blink.mojom.ServiceWorkerContainer(Host) connections to the // This holds blink.mojom.ServiceWorkerContainer(Host) connections to the
// browser-side ServiceWorkerProviderHost to keep it alive there. // browser-side ServiceWorkerProviderHost to keep it alive there.
// Note: |service_worker_provider_info_->script_loader_factory_ptr_info| is // Note: |service_worker_provider_info_->script_loader_factory_remote| is
// moved to WebServiceWorkerNetworkProviderImpl when // moved to WebServiceWorkerNetworkProviderImpl when
// CreateServiceWorkerNetworkProvider is called. // CreateServiceWorkerNetworkProvider is called.
blink::mojom::ServiceWorkerProviderInfoForStartWorkerPtr blink::mojom::ServiceWorkerProviderInfoForStartWorkerPtr
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
namespace network { namespace network {
...@@ -46,11 +46,11 @@ void WeakWrapperSharedURLLoaderFactory::Clone( ...@@ -46,11 +46,11 @@ void WeakWrapperSharedURLLoaderFactory::Clone(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
WeakWrapperSharedURLLoaderFactory::Clone() { WeakWrapperSharedURLLoaderFactory::Clone() {
mojom::URLLoaderFactoryPtrInfo factory_ptr_info; mojo::PendingRemote<mojom::URLLoaderFactory> factory_remote;
if (factory()) if (factory())
factory()->Clone(mojo::MakeRequest(&factory_ptr_info)); factory()->Clone(factory_remote.InitWithNewPipeAndPassReceiver());
return std::make_unique<WrapperSharedURLLoaderFactoryInfo>( return std::make_unique<WrapperSharedURLLoaderFactoryInfo>(
std::move(factory_ptr_info)); std::move(factory_remote));
} }
WeakWrapperSharedURLLoaderFactory::~WeakWrapperSharedURLLoaderFactory() = WeakWrapperSharedURLLoaderFactory::~WeakWrapperSharedURLLoaderFactory() =
......
...@@ -10,8 +10,8 @@ WrapperSharedURLLoaderFactoryInfo::WrapperSharedURLLoaderFactoryInfo() = ...@@ -10,8 +10,8 @@ WrapperSharedURLLoaderFactoryInfo::WrapperSharedURLLoaderFactoryInfo() =
default; default;
WrapperSharedURLLoaderFactoryInfo::WrapperSharedURLLoaderFactoryInfo( WrapperSharedURLLoaderFactoryInfo::WrapperSharedURLLoaderFactoryInfo(
network::mojom::URLLoaderFactoryPtrInfo factory_ptr_info) mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote)
: factory_ptr_info_(std::move(factory_ptr_info)) {} : factory_remote_(std::move(factory_remote)) {}
WrapperSharedURLLoaderFactoryInfo::~WrapperSharedURLLoaderFactoryInfo() = WrapperSharedURLLoaderFactoryInfo::~WrapperSharedURLLoaderFactoryInfo() =
default; default;
...@@ -19,7 +19,7 @@ WrapperSharedURLLoaderFactoryInfo::~WrapperSharedURLLoaderFactoryInfo() = ...@@ -19,7 +19,7 @@ WrapperSharedURLLoaderFactoryInfo::~WrapperSharedURLLoaderFactoryInfo() =
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
WrapperSharedURLLoaderFactoryInfo::CreateFactory() { WrapperSharedURLLoaderFactoryInfo::CreateFactory() {
return base::MakeRefCounted<WrapperSharedURLLoaderFactory>( return base::MakeRefCounted<WrapperSharedURLLoaderFactory>(
std::move(factory_ptr_info_)); std::move(factory_remote_));
} }
} // namespace network } // namespace network
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/component_export.h" #include "base/component_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h"
...@@ -15,13 +16,13 @@ ...@@ -15,13 +16,13 @@
namespace network { namespace network {
// A SharedURLLoaderFactoryInfo implementation that wraps a // A SharedURLLoaderFactoryInfo implementation that wraps a
// network::mojom::URLLoaderFactoryPtrInfo. // mojo::PendingRemote<network::mojom::URLLoaderFactory>.
class COMPONENT_EXPORT(NETWORK_CPP) WrapperSharedURLLoaderFactoryInfo class COMPONENT_EXPORT(NETWORK_CPP) WrapperSharedURLLoaderFactoryInfo
: public network::SharedURLLoaderFactoryInfo { : public network::SharedURLLoaderFactoryInfo {
public: public:
WrapperSharedURLLoaderFactoryInfo(); WrapperSharedURLLoaderFactoryInfo();
explicit WrapperSharedURLLoaderFactoryInfo( explicit WrapperSharedURLLoaderFactoryInfo(
network::mojom::URLLoaderFactoryPtrInfo factory_ptr_info); mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote);
~WrapperSharedURLLoaderFactoryInfo() override; ~WrapperSharedURLLoaderFactoryInfo() override;
...@@ -29,7 +30,7 @@ class COMPONENT_EXPORT(NETWORK_CPP) WrapperSharedURLLoaderFactoryInfo ...@@ -29,7 +30,7 @@ class COMPONENT_EXPORT(NETWORK_CPP) WrapperSharedURLLoaderFactoryInfo
// SharedURLLoaderFactoryInfo implementation. // SharedURLLoaderFactoryInfo implementation.
scoped_refptr<network::SharedURLLoaderFactory> CreateFactory() override; scoped_refptr<network::SharedURLLoaderFactory> CreateFactory() override;
network::mojom::URLLoaderFactoryPtrInfo factory_ptr_info_; mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote_;
}; };
// A SharedURLLoaderFactory implementation that wraps a // A SharedURLLoaderFactory implementation that wraps a
......
...@@ -40,7 +40,7 @@ struct ServiceWorkerProviderInfoForStartWorker { ...@@ -40,7 +40,7 @@ struct ServiceWorkerProviderInfoForStartWorker {
// The loader to use for loading the worker's main script and // The loader to use for loading the worker's main script and
// importScripts(). // importScripts().
network.mojom.URLLoaderFactory? script_loader_factory_ptr_info; pending_remote<network.mojom.URLLoaderFactory>? script_loader_factory_remote;
// |cache_storage| is an optional optimization so the service worker can use // |cache_storage| is an optional optimization so the service worker can use
// the Cache Storage API immediately without using InterfaceProvider. May be // the Cache Storage API immediately without using InterfaceProvider. May be
......
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