Commit 0cc58abc authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Move CreateDefaultURLLoaderFactoryBundle to anonymous namespace.

After removing blink::Platform::CreateDefaultURLLoaderFactory method in
r783649, there are no more callers of CreateNetworkURLLoaderFactory and
CreateDefaultURLLoaderFactoryBundle _inside_ RendererBlinkPlatformImpl.
Therefore, this CL moves CreateNetworkURLLoaderFactory and
CreateDefaultURLLoaderFactoryBundle into an anonymous namespace in
render_frame_impl.cc, where their only remaining caller is.

This helps (slightly) in two ways:

1. It helps with encapsulation - after the CL, no headers expose an API
   for getting the origin-agnostic/process-wide factory via
   CreateDefaultURLLoaderFactoryBundle.

2. It highlights that the helpers are unrelated from
   RendererBlinkPlatformImpl - even before this CL they could have been
   |static| methods.

Bug: 1098938
Change-Id: I7a13c4d4fdfaaedda25acfa7f40404d307a2b537
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276227Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784838}
parent cdb58d2c
......@@ -1055,6 +1055,35 @@ void FillNavigationParamsOriginPolicy(
}
}
// Asks RenderProcessHostImpl::CreateURLLoaderFactoryForRendererProcess in the
// browser process for a URLLoaderFactory.
//
// AVOID: see the comment on CreateDefaultURLLoaderFactoryBundle below.
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateDefaultURLLoaderFactory() {
RenderThreadImpl* render_thread = RenderThreadImpl::current();
DCHECK(render_thread);
mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
ChildThread::Get()->BindHostReceiver(
factory_remote.InitWithNewPipeAndPassReceiver());
return factory_remote;
}
// Returns a non-null pointer to a URLLoaderFactory bundle that is not
// associated with any specific origin, frame or worker.
//
// AVOID: prefer to use an origin/frame/worker-specific factory (e.g. via
// content::RenderFrameImpl::FrameURLLoaderFactory::CreateURLLoader). See
// also https://crbug.com/1098938.
//
// It is invalid to call this in an incomplete env where
// RenderThreadImpl::current() returns nullptr (e.g. in some tests).
scoped_refptr<ChildURLLoaderFactoryBundle>
CreateDefaultURLLoaderFactoryBundle() {
return base::MakeRefCounted<ChildURLLoaderFactoryBundle>(
base::BindOnce(&CreateDefaultURLLoaderFactory));
}
} // namespace
// This class uses existing WebNavigationBodyLoader to read the whole response
......@@ -5739,16 +5768,15 @@ RenderFrameImpl::CreateLoaderFactoryBundle(
base::MakeRefCounted<HostChildURLLoaderFactoryBundle>(
GetTaskRunner(blink::TaskType::kInternalLoading));
// In some tests |render_thread| could be null.
RenderThreadImpl* render_thread = RenderThreadImpl::current();
if (render_thread && !info) {
// CreateDefaultURLLoaderFactoryBundle can't be called if (as in some tests)
// RenderThreadImpl::current is null.
if (RenderThreadImpl::current() && !info) {
// This should only happen for a placeholder document or an initial empty
// document cases.
DCHECK(GetLoadingUrl().is_empty() ||
GetLoadingUrl().spec() == url::kAboutBlankURL);
loader_factories->Update(render_thread->blink_platform_impl()
->CreateDefaultURLLoaderFactoryBundle()
->PassInterface());
loader_factories->Update(
CreateDefaultURLLoaderFactoryBundle()->PassInterface());
}
if (info) {
......
......@@ -230,23 +230,6 @@ RendererBlinkPlatformImpl::WrapSharedURLLoaderFactory(
std::move(factory));
}
scoped_refptr<ChildURLLoaderFactoryBundle>
RendererBlinkPlatformImpl::CreateDefaultURLLoaderFactoryBundle() {
return base::MakeRefCounted<ChildURLLoaderFactoryBundle>(
base::BindOnce(&RendererBlinkPlatformImpl::CreateNetworkURLLoaderFactory,
base::Unretained(this)));
}
mojo::PendingRemote<network::mojom::URLLoaderFactory>
RendererBlinkPlatformImpl::CreateNetworkURLLoaderFactory() {
RenderThreadImpl* render_thread = RenderThreadImpl::current();
DCHECK(render_thread);
mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
ChildThread::Get()->BindHostReceiver(
factory_remote.InitWithNewPipeAndPassReceiver());
return factory_remote;
}
void RendererBlinkPlatformImpl::SetDisplayThreadPriority(
base::PlatformThreadId thread_id) {
#if defined(OS_LINUX)
......
......@@ -56,7 +56,6 @@ class RasterContextProvider;
}
namespace content {
class ChildURLLoaderFactoryBundle;
class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
public:
......@@ -205,15 +204,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
media::GpuVideoAcceleratorFactories* GetGpuFactories() override;
// Returns non-null.
// It is invalid to call this in an incomplete env where
// RenderThreadImpl::current() returns nullptr (e.g. in some tests).
scoped_refptr<ChildURLLoaderFactoryBundle>
CreateDefaultURLLoaderFactoryBundle();
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateNetworkURLLoaderFactory();
// Tells this platform that the renderer is locked to a site (i.e., a scheme
// plus eTLD+1, such as https://google.com), or to a more specific origin.
void SetIsLockedToSite();
......
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