Commit 9657b4f8 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Remove legacy non-S13nServiceWorker path from content/browser/worker_host/

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

Bug: 926114
Change-Id: Ia256db8074e5ab9a98dde0196e584128f8e1d97c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1472012
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638043}
parent 045a3277
......@@ -29,7 +29,6 @@
#include "services/network/public/cpp/features.h"
#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/service_worker/service_worker_utils.h"
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom.h"
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom.h"
......@@ -178,19 +177,17 @@ void SharedWorkerHost::Start(
#if DCHECK_IS_ON()
// Verify the combination of the given args based on the flags. See the
// function comment for details.
DCHECK(service_worker_provider_info);
DCHECK(subresource_loader_factories);
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
// NetworkService (PlzWorker):
DCHECK(service_worker_provider_info);
DCHECK(!main_script_loader_factory);
DCHECK(main_script_load_params);
DCHECK(subresource_loader_factories);
DCHECK(!subresource_loader_factories->default_factory_info());
} else {
// non-NetworkService:
DCHECK(service_worker_provider_info);
DCHECK(main_script_loader_factory);
DCHECK(!main_script_load_params);
DCHECK(subresource_loader_factories);
DCHECK(subresource_loader_factories->default_factory_info());
DCHECK(!controller);
DCHECK(!controller_service_worker_object_host);
......@@ -237,7 +234,7 @@ void SharedWorkerHost::Start(
mojo::MakeRequest(&interface_provider)));
// Set the default factory to the bundle for subresource loading to pass to
// the renderer when NetworkService is on. When S13nServiceWorker is on, the
// the renderer when NetworkService is on. When NetworkService is off, the
// default factory is already provided by
// WorkerScriptFetchInitiator::CreateFactoryBundle().
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
......
......@@ -70,16 +70,13 @@ class CONTENT_EXPORT SharedWorkerHost
// Starts the SharedWorker in the renderer process.
//
// S13nServiceWorker:
// |service_worker_provider_info| is sent to the renderer process and contains
// information about its ServiceWorkerProviderHost, the browser-side host for
// supporting the shared worker as a service worker client.
//
// S13nServiceWorker (non-NetworkService):
// |main_script_loader_factory| is sent to the renderer process and is to be
// used to request the shared worker's main script. Currently it's only
// non-null when S13nServiceWorker is enabled but NetworkService is disabled,
// to allow service worker machinery to observe the request.
// used to request the shared worker's main script. This is null when
// NetworkService is enabled in favor of |main_script_load_params|.
//
// NetworkService (PlzWorker):
// |main_script_load_params| is sent to the renderer process and to be used to
......@@ -97,8 +94,8 @@ class CONTENT_EXPORT SharedWorkerHost
// a ServiceWorker object about the controller is prepared, it is registered
// to |controller_service_worker_object_host|. These can be non-null only when
// NetworkService is enabled.
// When S13nServiceWorker is enabled but NetworkService is disabled, the
// service worker controller is sent via ServiceWorkerContainer#SetController.
// When NetworkService is disabled, the service worker controller is sent via
// ServiceWorkerContainer#SetController.
void Start(
blink::mojom::SharedWorkerFactoryPtr factory,
blink::mojom::ServiceWorkerProviderInfoForWorkerPtr
......
......@@ -29,7 +29,6 @@
#include "services/network/public/cpp/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/messaging/message_port_channel.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "url/origin.h"
using blink::MessagePortChannel;
......@@ -81,8 +80,8 @@ class SharedWorkerHostTest : public testing::Test {
subresource_loader_factories;
base::Optional<SubresourceLoaderParams> subresource_loader_params;
// Set up various mocks based on NetworkService/S13nServiceWorker
// configuration. See the comment on SharedWorkerHost::Start() for details.
// Set up various mocks based on NetworkService configuration. See the
// comment on SharedWorkerHost::Start() for details.
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
provider_info = blink::mojom::ServiceWorkerProviderInfoForWorker::New();
ServiceWorkerProviderHost::PreCreateForSharedWorker(
......@@ -101,7 +100,7 @@ class SharedWorkerHostTest : public testing::Test {
subresource_loader_params->appcache_loader_factory_info =
loader_factory_ptr.PassInterface();
} else if (blink::ServiceWorkerUtils::IsServicificationEnabled()) {
} else {
provider_info = blink::mojom::ServiceWorkerProviderInfoForWorker::New();
ServiceWorkerProviderHost::PreCreateForSharedWorker(
helper_->context()->AsWeakPtr(), mock_render_process_host_.GetID(),
......
......@@ -37,7 +37,6 @@
#include "services/network/loader_util.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/messaging/message_port_channel.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h"
#include "third_party/blink/public/mojom/worker/shared_worker_client.mojom.h"
#include "third_party/blink/public/mojom/worker/shared_worker_info.mojom.h"
......@@ -195,39 +194,25 @@ void SharedWorkerServiceImpl::CreateWorker(
auto weak_host = host->AsWeakPtr();
worker_hosts_.insert(std::move(host));
if (blink::ServiceWorkerUtils::IsServicificationEnabled()) {
// NetworkService (PlzWorker):
// An appcache interceptor is available only when the network service is
// enabled.
AppCacheNavigationHandleCore* appcache_handle_core = nullptr;
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
auto appcache_handle = std::make_unique<AppCacheNavigationHandle>(
appcache_service_.get(), process_id);
appcache_handle_core = appcache_handle->core();
weak_host->SetAppCacheHandle(std::move(appcache_handle));
}
WorkerScriptFetchInitiator::Start(
process_id, weak_host->instance()->url(),
weak_host->instance()->constructor_origin(),
RESOURCE_TYPE_SHARED_WORKER, service_worker_context_,
appcache_handle_core, std::move(blob_url_loader_factory),
storage_partition_,
base::BindOnce(&SharedWorkerServiceImpl::DidCreateScriptLoader,
weak_factory_.GetWeakPtr(), std::move(instance),
weak_host, std::move(client), process_id, frame_id,
message_port));
return;
// NetworkService (PlzWorker):
// An appcache interceptor is available only when the network service is
// enabled.
AppCacheNavigationHandleCore* appcache_handle_core = nullptr;
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
auto appcache_handle = std::make_unique<AppCacheNavigationHandle>(
appcache_service_.get(), process_id);
appcache_handle_core = appcache_handle->core();
weak_host->SetAppCacheHandle(std::move(appcache_handle));
}
// Legacy case (to be deprecated):
StartWorker(std::move(instance), weak_host, std::move(client), process_id,
frame_id, message_port,
nullptr /* service_worker_provider_info */,
{} /* main_script_loader_factory */,
nullptr /* subresource_loader_factories */,
nullptr /* main_script_load_params */, nullptr /* controller */,
nullptr /* controller_service_worker_object_host */);
WorkerScriptFetchInitiator::Start(
process_id, weak_host->instance()->url(),
weak_host->instance()->constructor_origin(), RESOURCE_TYPE_SHARED_WORKER,
service_worker_context_, appcache_handle_core,
std::move(blob_url_loader_factory), storage_partition_,
base::BindOnce(&SharedWorkerServiceImpl::DidCreateScriptLoader,
weak_factory_.GetWeakPtr(), std::move(instance), weak_host,
std::move(client), process_id, frame_id, message_port));
}
void SharedWorkerServiceImpl::DidCreateScriptLoader(
......@@ -249,7 +234,6 @@ void SharedWorkerServiceImpl::DidCreateScriptLoader(
controller_service_worker_object_host,
bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(blink::ServiceWorkerUtils::IsServicificationEnabled());
// NetworkService (PlzWorker):
// If the script fetcher fails to load shared worker's main script, notify the
......
......@@ -40,7 +40,6 @@
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/blink/public/common/loader//url_loader_factory_bundle.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h"
#include "url/origin.h"
......@@ -58,7 +57,6 @@ void WorkerScriptFetchInitiator::Start(
StoragePartitionImpl* storage_partition,
CompletionCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(blink::ServiceWorkerUtils::IsServicificationEnabled());
DCHECK(storage_partition);
DCHECK(resource_type == RESOURCE_TYPE_WORKER ||
resource_type == RESOURCE_TYPE_SHARED_WORKER)
......@@ -129,7 +127,6 @@ WorkerScriptFetchInitiator::CreateFactoryBundle(
StoragePartitionImpl* storage_partition,
bool file_support) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(blink::ServiceWorkerUtils::IsServicificationEnabled());
ContentBrowserClient::NonNetworkURLLoaderFactoryMap non_network_factories;
GetContentClient()
......@@ -254,7 +251,6 @@ void WorkerScriptFetchInitiator::CreateScriptLoaderOnIO(
blob_url_loader_factory_info,
CompletionCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(blink::ServiceWorkerUtils::IsServicificationEnabled());
DCHECK(resource_context);
// Set up for service worker.
......
......@@ -14,7 +14,6 @@
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_provider_type.mojom.h"
namespace content {
......@@ -32,7 +31,6 @@ WorkerScriptLoaderFactory::WorkerScriptLoaderFactory(
loader_factory_(std::move(loader_factory)) {
#if DCHECK_IS_ON()
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(blink::ServiceWorkerUtils::IsServicificationEnabled());
// In the current implementation, dedicated workers use
// ServiceWorkerProviderHost w/ kForSharedWorker.
// TODO(nhiroki): Rename it to kForWorker for both dedicated workers and
......
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