Commit d37e4e16 authored by Cammie Smith Barnes's avatar Cammie Smith Barnes Committed by Commit Bot

Split cache: Null checks for DedicatedWorkerHost::CreateNetworkFactory.

We add DCHECKs to CreateNetworkFactory(...) for
PlzDedicatedWorker to ensure that the render frame host exists, in
order to help de-flake the following
webkit_layout_test:
virtual/omt-worker-fetch/external/wpt/fetch/api/request/destination/
fetch-destination-worker.https.html

We also change the erroring out and early return in
DidStartScriptLoad(...) before the call to CreateNetworkFactory(...)
to the condition when |ancestor_render_frame_host| is null, rather
than merely when |worker_process_host| is null.

Bug: 910713
Change-Id: I471e6393392423fce736a0ef16442222629ca613
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1699379
Commit-Queue: Cammie Smith Barnes <cammie@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarShivani Sharma <shivanisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680111}
parent df379183
......@@ -168,8 +168,11 @@ class DedicatedWorkerHost : public service_manager::mojom::InterfaceProvider {
return;
}
auto* worker_process_host = RenderProcessHost::FromID(worker_process_id_);
if (!worker_process_host) {
// TODO(cammie): Change this approach when we support shared workers
// creating dedicated workers, as there might be no ancestor frame.
RenderFrameHostImpl* ancestor_render_frame_host =
GetAncestorRenderFrameHost();
if (!ancestor_render_frame_host) {
client_->OnScriptLoadStartFailed();
return;
}
......@@ -179,7 +182,7 @@ class DedicatedWorkerHost : public service_manager::mojom::InterfaceProvider {
pending_default_factory;
CreateNetworkFactory(
pending_default_factory.InitWithNewPipeAndPassReceiver(),
worker_process_host);
ancestor_render_frame_host);
subresource_loader_factories->pending_default_factory() =
std::move(pending_default_factory);
......@@ -215,20 +218,20 @@ class DedicatedWorkerHost : public service_manager::mojom::InterfaceProvider {
}
void CreateNetworkFactory(network::mojom::URLLoaderFactoryRequest request,
RenderProcessHost* worker_process_host) {
RenderFrameHostImpl* render_frame_host) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(render_frame_host);
network::mojom::TrustedURLLoaderHeaderClientPtrInfo no_header_client;
// Get the origin of the frame tree's root to use as top-frame origin.
// TODO(cammie): Change this approach when we support shared workers
// creating dedicated workers, as there might be no ancestor frame.
RenderFrameHostImpl* ancestor_render_frame_host =
GetAncestorRenderFrameHost();
url::Origin top_frame_origin(ancestor_render_frame_host->frame_tree_node()
// TODO(crbug.com/986167): Resolve issue of potential race condition.
url::Origin top_frame_origin(render_frame_host->frame_tree_node()
->frame_tree()
->root()
->current_origin());
RenderProcessHost* worker_process_host = render_frame_host->GetProcess();
DCHECK(worker_process_host);
worker_process_host->CreateURLLoaderFactory(
origin_, nullptr /* preferences */,
net::NetworkIsolationKey(top_frame_origin, origin_),
......
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