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: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638042}
diff --git a/content/renderer/worker/embedded_shared_worker_stub.cc b/content/renderer/worker/embedded_shared_worker_stub.cc
index cf5707e..18a200b 100644
--- a/content/renderer/worker/embedded_shared_worker_stub.cc
+++ b/content/renderer/worker/embedded_shared_worker_stub.cc
@@ -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 @@
       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,45 +140,25 @@
   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());
+  // 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.
+  if (IsOutOfProcessNetworkService()) {
+    default_factory_connection_error_handler_holder_.Bind(
+        std::move(factory_bundle->default_factory_info()));
+    default_factory_connection_error_handler_holder_->Clone(
+        mojo::MakeRequest(&factory_bundle->default_factory_info()));
+    default_factory_connection_error_handler_holder_
+        .set_connection_error_handler(base::BindOnce(
+            &EmbeddedSharedWorkerStub::Terminate, base::Unretained(this)));
+  }
 
-  // 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.
-    if (IsOutOfProcessNetworkService()) {
-      default_factory_connection_error_handler_holder_.Bind(
-          std::move(factory_bundle->default_factory_info()));
-      default_factory_connection_error_handler_holder_->Clone(
-          mojo::MakeRequest(&factory_bundle->default_factory_info()));
-      default_factory_connection_error_handler_holder_
-          .set_connection_error_handler(base::BindOnce(
-              &EmbeddedSharedWorkerStub::Terminate, base::Unretained(this)));
-    }
-
-    subresource_loader_factories_->Update(
-        std::make_unique<ChildURLLoaderFactoryBundleInfo>(
-            std::move(factory_bundle)));
-  }
+  subresource_loader_factories_->Update(
+      std::make_unique<ChildURLLoaderFactoryBundleInfo>(
+          std::move(factory_bundle)));
 
   impl_->StartWorkerContext(
       url_, blink::WebString::FromUTF8(name_),
diff --git a/content/renderer/worker/embedded_shared_worker_stub.h b/content/renderer/worker/embedded_shared_worker_stub.h
index d5d248e..5fb382c 100644
--- a/content/renderer/worker/embedded_shared_worker_stub.h
+++ b/content/renderer/worker/embedded_shared_worker_stub.h
@@ -127,8 +127,7 @@
   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 @@
   // 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
diff --git a/content/renderer/worker/service_worker_network_provider_for_worker.cc b/content/renderer/worker/service_worker_network_provider_for_worker.cc
index 1106d554..f2cffab 100644
--- a/content/renderer/worker/service_worker_network_provider_for_worker.cc
+++ b/content/renderer/worker/service_worker_network_provider_for_worker.cc
@@ -29,47 +29,17 @@
     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,
-        std::move(info->client_request), std::move(info->host_ptr_info),
-        std::move(controller_info), std::move(fallback_loader_factory));
-    if (script_loader_factory_info.is_valid()) {
-      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());
-    }
+  provider->context_ = base::MakeRefCounted<ServiceWorkerProviderContext>(
+      info->provider_id,
+      blink::mojom::ServiceWorkerProviderType::kForSharedWorker,
+      std::move(info->client_request), std::move(info->host_ptr_info),
+      std::move(controller_info), std::move(fallback_loader_factory));
+  if (script_loader_factory_info.is_valid()) {
+    provider->script_loader_factory_.Bind(
+        std::move(script_loader_factory_info));
   }
   return provider;
 }
@@ -107,11 +77,6 @@
     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();
diff --git a/content/renderer/worker/service_worker_network_provider_for_worker.h b/content/renderer/worker/service_worker_network_provider_for_worker.h
index 946f76c..fc8d6f2 100644
--- a/content/renderer/worker/service_worker_network_provider_for_worker.h
+++ b/content/renderer/worker/service_worker_network_provider_for_worker.h
@@ -26,8 +26,7 @@
 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