DCHECK that a committing frame receives valid URLLoaderFactory bundle.
The primary goal of this CL, is being able to add the following DCHECKs:
DCHECK(loader_factories_);
DCHECK(loader_factories_->HasBoundDefaultFactory());
to RenderFrameImpl::DidCommitNavigation. If these DCHECKs hold, then
ChildURLLoaderFactoryBundle::GetFactory should always get the
|base_result| from the base class and therefore shouldn't ever need to
fall back ot the |direct_network_factory_| fallback (which wraps the
deprecated, process-wide / frame-agnostic factory).
One scenario where the new DCHECKs didn't hold before this CL is
RenderFrameImpl::LoadHTMLString which is mostly used from tests, but
also has a call in the product from
MimeHandlerViewContainerManager::LoadEmptyPage which is used by
MimeHandlerViewEmbedder::CheckSandboxFlags to load an empty page when
security checks fail. Another scenario is unit tests like
RenderViewImplTest going through TestRenderFrame (where tests drive the
simulated commit). All of these cases don't actually use the factory
bundle and therefore can just use the NotImplementedURLLoaderFactory.
The CL splits GetLoaderFactoryBundleFallback from
GetLoaderFactoryBundleFromCreator to make it more obvious when the
fallback is actually needed. In particular, this allows the new DCHECKs
in RenderFrameImpl::DidCommitNavigation to explicitly avoid the
fallback.
To facilitate reuse of NotImplementedURLLoaderFactory from
//content/renderer the CL moves this class from //content/test into
//services/network/public/cpp. The CL also adds NOTREACHED to
NotImplementedURLLoaderFactory::CreateLoaderAndStart to ensure that
future callers don't accidentally start using the factory.
NOTREACHED is also added to the non-opaque-origin/DwoC case in
ChildURLLoaderFactoryBundle::GetFactory (this probably should have been
part of r792963 which added a test that would have hit this NOTREACHED
before the fix).
Bug: 1098938, 1105794
Change-Id: Ifaedf40be35871b0a30797c09a236ea131b24447
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321346
Reviewed-by: Kinuko Yasuda <[email protected]>
Commit-Queue: Ćukasz Anforowicz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#794566}
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
index 6780010..ef81b1a 100644
--- a/content/renderer/render_frame_impl.h
+++ b/content/renderer/render_frame_impl.h
@@ -1032,6 +1032,13 @@
scoped_refptr<ChildURLLoaderFactoryBundle>
GetLoaderFactoryBundleFromCreator();
+ // Returns a mostly empty bundle, with a fallback that uses a process-wide,
+ // direct-network factory.
+ //
+ // TODO(lukasza): https://crbug.com/1098938: Remove once the fallback is no
+ // longer needed.
+ scoped_refptr<ChildURLLoaderFactoryBundle> GetLoaderFactoryBundleFallback();
+
scoped_refptr<ChildURLLoaderFactoryBundle> CreateLoaderFactoryBundle(
std::unique_ptr<blink::PendingURLLoaderFactoryBundle> info,
base::Optional<std::vector<blink::mojom::TransferrableURLLoaderPtr>>