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