Bug 1639833 - IntrisincStoragePrincipal should always be partitioned - part 5 - Use RemoteWorkerData CTOR in serviceWorkers, r=dimi
☠☠ backed out by ac227265b747 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 01 Jun 2020 11:08:56 +0000
changeset 597402 b36af8d9db34c248e222dfd6df6522412d11522d
parent 597401 712c11904dbec950a42ce82ffa76f477121a3fa6
child 597403 e3649ae5343792404cbef30728e0560c6e31880c
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs1639833
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1639833 - IntrisincStoragePrincipal should always be partitioned - part 5 - Use RemoteWorkerData CTOR in serviceWorkers, r=dimi Differential Revision: https://phabricator.services.mozilla.com/D76918
dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
--- a/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
+++ b/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
@@ -155,41 +155,47 @@ nsresult ServiceWorkerPrivateImpl::Initi
 
   ServiceWorkerData serviceWorkerData;
   serviceWorkerData.cacheName() = mOuter->mInfo->CacheName();
   serviceWorkerData.loadFlags() =
       static_cast<uint32_t>(mOuter->mInfo->GetImportsLoadFlags() |
                             nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
   serviceWorkerData.id() = std::move(id);
 
-  mRemoteWorkerData.originalScriptURL() =
-      NS_ConvertUTF8toUTF16(mOuter->mInfo->ScriptSpec());
-  mRemoteWorkerData.baseScriptURL() = baseScriptURL;
-  mRemoteWorkerData.resolvedScriptURL() = baseScriptURL;
-  mRemoteWorkerData.name() = VoidString();
+  nsAutoCString domain;
+  rv = uri->GetHost(domain);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
 
-  mRemoteWorkerData.loadingPrincipalInfo() = principalInfo;
-  mRemoteWorkerData.principalInfo() = principalInfo;
-  // partitionedPrincipalInfo for ServiceWorkers is equal to principalInfo
-  // because, at the moment, ServiceWorkers are not exposed in partitioned
-  // contexts.
-  mRemoteWorkerData.partitionedPrincipalInfo() = principalInfo;
+  mRemoteWorkerData = RemoteWorkerData(
+      NS_ConvertUTF8toUTF16(mOuter->mInfo->ScriptSpec()), baseScriptURL,
+      baseScriptURL, /* name */ VoidString(),
+      /* loading principal */ principalInfo, principalInfo,
 
-  // ServiceWorkers run as first-party, no storage-access permission needed.
-  mRemoteWorkerData.useRegularPrincipal() = true;
-  mRemoteWorkerData.hasStorageAccessPermissionGranted() = false;
+      // partitionedPrincipalInfo for ServiceWorkers is equal to principalInfo
+      // because, at the moment, ServiceWorkers are not exposed in partitioned
+      // contexts.
+      principalInfo,
+      /* useRegularPrincipal */ true,
+
+      // ServiceWorkers run as first-party, no storage-access permission needed.
+      /* hasStorageAccessPermissionGranted */ false,
 
-  rv = uri->GetHost(mRemoteWorkerData.domain());
-  NS_ENSURE_SUCCESS(rv, rv);
-  mRemoteWorkerData.isSecureContext() = true;
+      domain,
+      /* isSecureContext */ true,
+      /* clientInfo*/ Nothing(),
+
+      // The RemoteWorkerData CTOR doesn't allow to set the referrerInfo via
+      // already_AddRefed<>. Let's set it to null.
+      /* referrerInfo */ nullptr,
+
+      storageAccess, std::move(serviceWorkerData), regInfo->AgentClusterId());
+
   mRemoteWorkerData.referrerInfo() = MakeAndAddRef<ReferrerInfo>();
-  mRemoteWorkerData.storageAccess() = storageAccess;
-  mRemoteWorkerData.serviceWorkerData() = std::move(serviceWorkerData);
-
-  mRemoteWorkerData.agentClusterId() = regInfo->AgentClusterId();
 
   // This fills in the rest of mRemoteWorkerData.serviceWorkerData().
   RefreshRemoteWorkerData(regInfo);
 
   return NS_OK;
 }
 
 RefPtr<GenericPromise> ServiceWorkerPrivateImpl::SetSkipWaitingFlag() {