Commit c43dbd15 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

S13nServiceWorker: Save the ptr to non_network_loader_factory.

ServiceWorkerNewScriptLoader was using the ptr then letting it fall
out of scope. ServiceWorkerScriptLoaderFactory still held a ptr to the
factory which is strongly bound, so the factory shouldn't die anyway,
but it seems safer if ServiceWorkerNewScriptLoader holds the cloned
ptr too throughout its life.

I'm not sure if this is actually needed for ExtensionURLLoaderFactory,
but it seems possible to write a factory that would fail if the
cloned ptr falls out of scope.

Bug: 836129
Change-Id: Id7b4ab9d72bb758fe639e963e2747f915e67aea3
Reviewed-on: https://chromium-review.googlesource.com/1029271Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553929}
parent 158cb3e2
...@@ -46,6 +46,7 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader( ...@@ -46,6 +46,7 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader(
network_watcher_(FROM_HERE, network_watcher_(FROM_HERE,
mojo::SimpleWatcher::ArmingPolicy::MANUAL, mojo::SimpleWatcher::ArmingPolicy::MANUAL,
base::SequencedTaskRunnerHandle::Get()), base::SequencedTaskRunnerHandle::Get()),
non_network_loader_factory_(std::move(non_network_loader_factory)),
client_(std::move(client)), client_(std::move(client)),
weak_factory_(this) { weak_factory_(this) {
// ServiceWorkerNewScriptLoader is used for fetching the service worker main // ServiceWorkerNewScriptLoader is used for fetching the service worker main
...@@ -112,8 +113,8 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader( ...@@ -112,8 +113,8 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader(
network::mojom::URLLoaderClientPtr network_client; network::mojom::URLLoaderClientPtr network_client;
network_client_binding_.Bind(mojo::MakeRequest(&network_client)); network_client_binding_.Bind(mojo::MakeRequest(&network_client));
if (non_network_loader_factory) { if (non_network_loader_factory_) {
non_network_loader_factory->CreateLoaderAndStart( non_network_loader_factory_->CreateLoaderAndStart(
mojo::MakeRequest(&network_loader_), routing_id, request_id, options, mojo::MakeRequest(&network_loader_), routing_id, request_id, options,
*resource_request_.get(), std::move(network_client), *resource_request_.get(), std::move(network_client),
traffic_annotation); traffic_annotation);
......
...@@ -154,6 +154,10 @@ class CONTENT_EXPORT ServiceWorkerNewScriptLoader ...@@ -154,6 +154,10 @@ class CONTENT_EXPORT ServiceWorkerNewScriptLoader
mojo::ScopedDataPipeConsumerHandle network_consumer_; mojo::ScopedDataPipeConsumerHandle network_consumer_;
mojo::SimpleWatcher network_watcher_; mojo::SimpleWatcher network_watcher_;
bool network_load_completed_ = false; bool network_load_completed_ = false;
// |non_network_loader_factory_| is non-null when the script URL is
// non-http(s). It is used to make the "network" request because the usual
// network factory can't be used in that case. See class comments.
network::mojom::URLLoaderFactoryPtr non_network_loader_factory_;
// Used for responding with the fetched script to this loader's client. // Used for responding with the fetched script to this loader's client.
network::mojom::URLLoaderClientPtr client_; network::mojom::URLLoaderClientPtr client_;
......
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