Commit 045a3277 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Remove legacy non-S13nServiceWorker path from content/renderer/worker/

S13nServiceWorker is now enabled by default. This CL removes unused
non-S13nServiceWorker path and IsServicificationEnabled() checks.

Bug: 926114
Change-Id: Iefd0c5f07cd75d05883dd8be874cf1d804e83fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504605
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638042}
parent a71bfc30
......@@ -20,7 +20,6 @@
#include "content/renderer/loader/navigation_response_override_parameters.h"
#include "content/renderer/loader/tracked_child_url_loader_factory_bundle.h"
#include "content/renderer/loader/web_worker_fetch_context_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_blink_platform_impl.h"
#include "content/renderer/service_worker/service_worker_provider_context.h"
#include "content/renderer/worker/service_worker_network_provider_for_worker.h"
......@@ -31,7 +30,6 @@
#include "third_party/blink/public/common/loader/url_loader_factory_bundle.h"
#include "third_party/blink/public/common/messaging/message_port_channel.h"
#include "third_party/blink/public/common/privacy_preferences.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "third_party/blink/public/mojom/service_worker/controller_service_worker.mojom.h"
......@@ -113,6 +111,7 @@ EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub(
renderer_preferences_(renderer_preferences),
preference_watcher_request_(std::move(preference_watcher_request)),
appcache_host_id_(appcache_host_id) {
DCHECK(factory_bundle);
// The ID of the precreated AppCacheHost can be valid only when the
// NetworkService is enabled.
DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService) ||
......@@ -141,28 +140,6 @@ EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub(
main_script_loader_factory_ = std::move(main_script_loader_factory);
controller_info_ = std::move(controller_info);
// |factory_bundle| is provided in the
// ServiceWorkerServicification or NetworkService case.
DCHECK(factory_bundle ||
!blink::ServiceWorkerUtils::IsServicificationEnabled());
// Make the factory bundle.
subresource_loader_factories_ =
base::MakeRefCounted<HostChildURLLoaderFactoryBundle>(
impl_->GetTaskRunner(blink::TaskType::kInternalLoading));
// If NetworkService or S13nSW is enabled, the default factory must be
// given as a |factory_bundle|.
// In some tests |render_thread| could be null.
RenderThreadImpl* render_thread = RenderThreadImpl::current();
if (render_thread && !blink::ServiceWorkerUtils::IsServicificationEnabled()) {
subresource_loader_factories_->Update(
render_thread->blink_platform_impl()
->CreateDefaultURLLoaderFactoryBundle()
->PassInterface());
}
if (factory_bundle) {
// If the network service crashes, then self-destruct so clients don't get
// stuck with a worker with a broken loader. Self-destruction is effectively
// the same as the worker's process crashing.
......@@ -176,10 +153,12 @@ EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub(
&EmbeddedSharedWorkerStub::Terminate, base::Unretained(this)));
}
subresource_loader_factories_ =
base::MakeRefCounted<HostChildURLLoaderFactoryBundle>(
impl_->GetTaskRunner(blink::TaskType::kInternalLoading));
subresource_loader_factories_->Update(
std::make_unique<ChildURLLoaderFactoryBundleInfo>(
std::move(factory_bundle)));
}
impl_->StartWorkerContext(
url_, blink::WebString::FromUTF8(name_),
......
......@@ -127,8 +127,7 @@ class EmbeddedSharedWorkerStub : public blink::WebSharedWorkerClient,
const int appcache_host_id_;
WebApplicationCacheHostImpl* app_cache_host_ = nullptr; // Not owned.
// S13nServiceWorker: The info needed to connect to the
// ServiceWorkerProviderHost on the browser.
// The info needed to connect to the ServiceWorkerProviderHost on the browser.
blink::mojom::ServiceWorkerProviderInfoForWorkerPtr
service_worker_provider_info_;
......@@ -139,8 +138,7 @@ class EmbeddedSharedWorkerStub : public blink::WebSharedWorkerClient,
// NetworkService:
blink::mojom::ControllerServiceWorkerInfoPtr controller_info_;
// S13nServiceWorker: The factory bundle used for loading subresources for
// this shared worker.
// The factory bundle used for loading subresources for this shared worker.
scoped_refptr<HostChildURLLoaderFactoryBundle> subresource_loader_factories_;
// NetworkService (PlzWorker): The response override parameters used for
......
......@@ -29,10 +29,9 @@ ServiceWorkerNetworkProviderForWorker::Create(
scoped_refptr<network::SharedURLLoaderFactory> fallback_loader_factory,
bool is_secure_context,
std::unique_ptr<NavigationResponseOverrideParameters> response_override) {
DCHECK(info);
auto provider = base::WrapUnique(new ServiceWorkerNetworkProviderForWorker(
is_secure_context, std::move(response_override)));
if (blink::ServiceWorkerUtils::IsServicificationEnabled()) {
DCHECK(info);
provider->context_ = base::MakeRefCounted<ServiceWorkerProviderContext>(
info->provider_id,
blink::mojom::ServiceWorkerProviderType::kForSharedWorker,
......@@ -42,35 +41,6 @@ ServiceWorkerNetworkProviderForWorker::Create(
provider->script_loader_factory_.Bind(
std::move(script_loader_factory_info));
}
} else {
DCHECK(!info);
int provider_id = ServiceWorkerProviderContext::GetNextId();
auto host_info = blink::mojom::ServiceWorkerProviderHostInfo::New(
provider_id, MSG_ROUTING_NONE,
blink::mojom::ServiceWorkerProviderType::kForSharedWorker,
true /* is_parent_frame_secure */, nullptr /* host_request */,
nullptr /* client_ptr_info */);
blink::mojom::ServiceWorkerContainerAssociatedRequest client_request =
mojo::MakeRequest(&host_info->client_ptr_info);
blink::mojom::ServiceWorkerContainerHostAssociatedPtrInfo host_ptr_info;
host_info->host_request = mojo::MakeRequest(&host_ptr_info);
provider->context_ = base::MakeRefCounted<ServiceWorkerProviderContext>(
provider_id, blink::mojom::ServiceWorkerProviderType::kForSharedWorker,
std::move(client_request), std::move(host_ptr_info),
std::move(controller_info), std::move(fallback_loader_factory));
if (ChildThreadImpl::current()) {
ChildThreadImpl::current()->channel()->GetRemoteAssociatedInterface(
&provider->dispatcher_host_);
provider->dispatcher_host_->OnProviderCreated(std::move(host_info));
} else {
// current() may be null in tests. Silently drop messages sent over
// ServiceWorkerContainerHost since we couldn't set it up correctly due
// to this test limitation. This way we don't crash when the associated
// interface ptr is used.
mojo::AssociateWithDisconnectedPipe(host_info->host_request.PassHandle());
}
}
return provider;
}
......@@ -107,11 +77,6 @@ ServiceWorkerNetworkProviderForWorker::CreateURLLoader(
return nullptr;
}
// S13nServiceWorker:
// We only install our own URLLoader if Servicification is enabled.
if (!blink::ServiceWorkerUtils::IsServicificationEnabled())
return nullptr;
// If the |script_loader_factory_| exists, use it.
if (script_loader_factory_) {
RenderThreadImpl* render_thread = RenderThreadImpl::current();
......
......@@ -26,8 +26,7 @@ struct NavigationResponseOverrideParameters;
class ServiceWorkerNetworkProviderForWorker final
: public blink::WebServiceWorkerNetworkProvider {
public:
// Creates a new instance. Some params might only be used in S13nServiceWorker
// or PlzSharedWorker.
// Creates a new instance.
// - |info|: provider info from the browser
// - |script_loader_factory_info|: the factory for loading the worker's
// scripts
......
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