ServiceWorker: Remove |options| from ServiceWorkerRegistrationObjectInfo,
and add |scope| and |update_via_cache| instead.

Remove |options| from ServiceWorkerRegistrationObjectInfo, and add |scope|
and |update_via_cache| because ServiceWorkerRegistration doesn't need
the information of script type which is included in |options|.
Related unit tests are updated.

Spec: https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface

Bug: 824647
Change-Id: I9bb26a54807c2ee857bc1abe9a9c598be9f39b76
Reviewed-on: https://chromium-review.googlesource.com/c/1424599
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Asami Doi <d0iasm.pub@gmail.com>
Cr-Commit-Position: refs/heads/master@{#625024}
diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc
index 17e96ea..0b51af3 100644
--- a/content/browser/service_worker/service_worker_provider_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
@@ -813,7 +813,7 @@
   EXPECT_EQ(blink::mojom::ServiceWorkerErrorType::kNone,
             GetRegistration(remote_endpoint.host_ptr()->get(), kScope, &info));
   ASSERT_TRUE(info);
-  EXPECT_EQ(kScope, info->options->scope);
+  EXPECT_EQ(kScope, info->scope);
 }
 
 TEST_P(ServiceWorkerProviderHostTest,
diff --git a/content/browser/service_worker/service_worker_registration_object_host.cc b/content/browser/service_worker/service_worker_registration_object_host.cc
index 0309c6a..34c9948 100644
--- a/content/browser/service_worker/service_worker_registration_object_host.cc
+++ b/content/browser/service_worker/service_worker_registration_object_host.cc
@@ -99,17 +99,10 @@
 
 blink::mojom::ServiceWorkerRegistrationObjectInfoPtr
 ServiceWorkerRegistrationObjectHost::CreateObjectInfo() {
-  // |info->options->script_type| is never accessed anywhere, so just set it to
-  // kClassic.
-  // TODO(asamidoi, nhiroki): Remove |options| from
-  // ServiceWorkerRegistrationObjectInfo, since |script_type| is a
-  // non-per-registration property.
-  blink::mojom::ScriptType script_type = blink::mojom::ScriptType::kClassic;
-
   auto info = blink::mojom::ServiceWorkerRegistrationObjectInfo::New();
-  info->options = blink::mojom::ServiceWorkerRegistrationOptions::New(
-      registration_->scope(), script_type, registration_->update_via_cache());
   info->registration_id = registration_->id();
+  info->scope = registration_->scope();
+  info->update_via_cache = registration_->update_via_cache();
   bindings_.AddBinding(this, mojo::MakeRequest(&info->host_ptr_info));
   info->request = mojo::MakeRequest(&remote_registration_);
 
diff --git a/content/renderer/service_worker/service_worker_context_client_unittest.cc b/content/renderer/service_worker/service_worker_context_client_unittest.cc
index 15119097..c02da84e 100644
--- a/content/renderer/service_worker/service_worker_context_client_unittest.cc
+++ b/content/renderer/service_worker/service_worker_context_client_unittest.cc
@@ -295,10 +295,9 @@
     auto registration_info =
         blink::mojom::ServiceWorkerRegistrationObjectInfo::New();
     registration_info->registration_id = 100;  // dummy
-    registration_info->options =
-        blink::mojom::ServiceWorkerRegistrationOptions::New(
-            kScope, blink::mojom::ScriptType::kClassic,
-            blink::mojom::ServiceWorkerUpdateViaCache::kAll);
+    registration_info->scope = kScope;
+    registration_info->update_via_cache =
+        blink::mojom::ServiceWorkerUpdateViaCache::kAll;
     out_pipes->registration_host_request =
         mojo::MakeRequest(&registration_info->host_ptr_info);
     registration_info->request = mojo::MakeRequest(&out_pipes->registration);
diff --git a/content/renderer/service_worker/service_worker_type_converters.cc b/content/renderer/service_worker/service_worker_type_converters.cc
index 6796060..b89df9a 100644
--- a/content/renderer/service_worker/service_worker_type_converters.cc
+++ b/content/renderer/service_worker/service_worker_type_converters.cc
@@ -151,7 +151,6 @@
   if (!input) {
     return blink::WebServiceWorkerRegistrationObjectInfo(
         blink::mojom::kInvalidServiceWorkerRegistrationId, blink::WebURL(),
-        blink::mojom::ScriptType::kClassic,
         blink::mojom::ServiceWorkerUpdateViaCache::kImports,
         mojo::ScopedInterfaceEndpointHandle() /* host_ptr_info */,
         mojo::ScopedInterfaceEndpointHandle() /* request */,
@@ -163,9 +162,8 @@
             .To<blink::WebServiceWorkerObjectInfo>() /* active */);
   }
   return blink::WebServiceWorkerRegistrationObjectInfo(
-      input->registration_id, input->options->scope, input->options->type,
-      input->options->update_via_cache, input->host_ptr_info.PassHandle(),
-      input->request.PassHandle(),
+      input->registration_id, input->scope, input->update_via_cache,
+      input->host_ptr_info.PassHandle(), input->request.PassHandle(),
       input->installing.To<blink::WebServiceWorkerObjectInfo>(),
       input->waiting.To<blink::WebServiceWorkerObjectInfo>(),
       input->active.To<blink::WebServiceWorkerObjectInfo>());
diff --git a/third_party/blink/public/mojom/service_worker/service_worker_registration.mojom b/third_party/blink/public/mojom/service_worker/service_worker_registration.mojom
index ec05b66..42ef27f 100644
--- a/third_party/blink/public/mojom/service_worker/service_worker_registration.mojom
+++ b/third_party/blink/public/mojom/service_worker/service_worker_registration.mojom
@@ -40,9 +40,10 @@
   // The globally unique identifier of a service worker registration entity.
   int64 registration_id = kInvalidServiceWorkerRegistrationId;
 
-  // The registration options attached with this registration object, including
-  // some information such as scope of this registration.
-  ServiceWorkerRegistrationOptions options;
+  // Corresponds to ServiceWorkerRegistration#scope.
+  url.mojom.Url scope;
+  // Corresponds to ServiceWorkerRegistration#updateViaCache.
+  ServiceWorkerUpdateViaCache update_via_cache;
 
   // Holds one mojo connection to browser process, acts as a reference count to
   // control lifetime of ServiceWorkerRegistration in the browser process.
diff --git a/third_party/blink/public/platform/modules/service_worker/web_service_worker_registration_object_info.h b/third_party/blink/public/platform/modules/service_worker/web_service_worker_registration_object_info.h
index cdc2b57..050a1d4 100644
--- a/third_party/blink/public/platform/modules/service_worker/web_service_worker_registration_object_info.h
+++ b/third_party/blink/public/platform/modules/service_worker/web_service_worker_registration_object_info.h
@@ -27,7 +27,6 @@
   WebServiceWorkerRegistrationObjectInfo(
       int64_t registration_id,
       WebURL scope,
-      mojom::ScriptType type,
       mojom::ServiceWorkerUpdateViaCache update_via_cache,
       mojo::ScopedInterfaceEndpointHandle host_ptr_info,
       mojo::ScopedInterfaceEndpointHandle request,
@@ -36,7 +35,6 @@
       WebServiceWorkerObjectInfo active)
       : registration_id(registration_id),
         scope(std::move(scope)),
-        type(type),
         update_via_cache(update_via_cache),
         host_ptr_info(std::move(host_ptr_info)),
         request(std::move(request)),
@@ -49,7 +47,6 @@
   int64_t registration_id;
 
   WebURL scope;
-  mojom::ScriptType type;
   mojom::ServiceWorkerUpdateViaCache update_via_cache;
 
   // For blink::mojom::ServiceWorkerRegistrationObjectHostAssociatedPtrInfo.
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc b/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc
index dc27807..1f9aba8 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc
@@ -131,7 +131,6 @@
     : ContextLifecycleObserver(execution_context),
       registration_id_(info.registration_id),
       scope_(std::move(info.scope)),
-      type_(info.type),
       binding_(this),
       stopped_(false) {
   DCHECK_NE(mojom::blink::kInvalidServiceWorkerRegistrationId,
@@ -143,7 +142,6 @@
     WebServiceWorkerRegistrationObjectInfo info) {
   DCHECK_EQ(registration_id_, info.registration_id);
   DCHECK_EQ(scope_.GetString(), WTF::String(info.scope.GetString()));
-  DCHECK_EQ(type_, info.type);
 
   // If |host_| is bound, it already points to the same object host as
   // |info.host_ptr_info|, so there is no need to bind again.
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_registration.h b/third_party/blink/renderer/modules/service_worker/service_worker_registration.h
index 9884fb0..452a044 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_registration.h
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_registration.h
@@ -111,7 +111,6 @@
 
   const int64_t registration_id_;
   const KURL scope_;
-  const mojom::ScriptType type_;
   mojom::ServiceWorkerUpdateViaCache update_via_cache_;
   // Both |host_| and |binding_| are associated with
   // content.mojom.ServiceWorkerContainer interface for a Document, and