Bug 1231213 - Add OptionalServiceWorkerData to RemoteWorkerData. r=asuth
☠☠ backed out by 3cf55b7f12f2 ☠ ☠
authorPerry Jiang <perry@mozilla.com>
Wed, 14 Aug 2019 16:19:53 +0000
changeset 488068 6ed55807374f0ba63a36990d06200f77baf713a6
parent 488067 395062aef2ec1c0abd3b1426fb376f5fef3e0c11
child 488069 11f010e6d6e7166b92c2638832896962bd8a71a7
push id113900
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:53:50 +0000
treeherdermozilla-inbound@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1231213
milestone70.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 1231213 - Add OptionalServiceWorkerData to RemoteWorkerData. r=asuth Differential Revision: https://phabricator.services.mozilla.com/D26167
dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
dom/workers/sharedworkers/SharedWorker.cpp
netwerk/ipc/NeckoMessageUtils.h
--- a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
+++ b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
@@ -1,23 +1,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include ClientIPCTypes;
+include IPCServiceWorkerDescriptor;
+include IPCServiceWorkerRegistrationDescriptor;
 include PBackgroundSharedTypes;
 include URIParams;
 include DOMTypes;
 
+using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::StorageAccess from "mozilla/dom/ClientIPCUtils.h";
 
 namespace mozilla {
 namespace dom {
 
+struct KeyAndPermissions {
+  nsCString key;
+  Permission[] permissions;
+};
+
+struct ServiceWorkerData {
+  KeyAndPermissions[] permissionsByKey;
+  IPCServiceWorkerDescriptor descriptor;
+  IPCServiceWorkerRegistrationDescriptor registrationDescriptor;
+  nsString cacheName;
+  uint32_t loadFlags;
+};
+
+union OptionalServiceWorkerData {
+  void_t;
+  ServiceWorkerData;
+};
+
 struct RemoteWorkerData
 {
   // This should only be used for devtools.
   nsString originalScriptURL;
 
   // It is important to pass these as URIParams instead of strings for blob
   // URLs: they carry an additional bit of state with them (mIsRevoked) that
   // gives us a chance to use them, even after they've been revoked. Because
@@ -41,16 +62,17 @@ struct RemoteWorkerData
 
   IPCClientInfo? clientInfo;
 
   nsIReferrerInfo referrerInfo;
 
   StorageAccess storageAccess;
 
   bool isSharedWorker;
+  OptionalServiceWorkerData serviceWorkerData;
 };
 
 // ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote
 // which in turn correspond to JSErrorReport/JSErrorNotes which allows JS to
 // report complicated errors such as redeclarations that involve multiple
 // distinct lines.  For more generic error-propagation IPC structures, see bug
 // 1357463 on making ErrorResult usable over IPC.
 
--- a/dom/workers/sharedworkers/SharedWorker.cpp
+++ b/dom/workers/sharedworkers/SharedWorker.cpp
@@ -190,17 +190,17 @@ already_AddRefed<SharedWorker> SharedWor
   if (clientInfo.isSome()) {
     ipcClientInfo.emplace(clientInfo.value().ToIPC());
   }
 
   RemoteWorkerData remoteWorkerData(
       nsString(aScriptURL), baseURL, resolvedScriptURL, name,
       loadingPrincipalInfo, principalInfo, storagePrincipalInfo,
       loadInfo.mDomain, isSecureContext, ipcClientInfo, loadInfo.mReferrerInfo,
-      storageAllowed, true /* sharedWorker */);
+      storageAllowed, void_t() /* OptionalServiceWorkerData */);
 
   PSharedWorkerChild* pActor = actorChild->SendPSharedWorkerConstructor(
       remoteWorkerData, loadInfo.mWindowID, portIdentifier);
 
   RefPtr<SharedWorkerChild> actor = static_cast<SharedWorkerChild*>(pActor);
   MOZ_ASSERT(actor);
 
   RefPtr<SharedWorker> sharedWorker =
--- a/netwerk/ipc/NeckoMessageUtils.h
+++ b/netwerk/ipc/NeckoMessageUtils.h
@@ -32,16 +32,22 @@ struct Permission {
   Permission(const nsCString& aOrigin, const nsACString& aType,
              const uint32_t aCapability, const uint32_t aExpireType,
              const int64_t aExpireTime)
       : origin(aOrigin),
         type(aType),
         capability(aCapability),
         expireType(aExpireType),
         expireTime(aExpireTime) {}
+
+  bool operator==(const Permission& aOther) const {
+    return aOther.origin == origin && aOther.type == type &&
+           aOther.capability == capability && aOther.expireType == expireType &&
+           aOther.expireTime == expireTime;
+  }
 };
 
 template <>
 struct ParamTraits<Permission> {
   static void Write(Message* aMsg, const Permission& aParam) {
     WriteParam(aMsg, aParam.origin);
     WriteParam(aMsg, aParam.type);
     WriteParam(aMsg, aParam.capability);