Bug 1231213 - Add OptionalServiceWorkerData to RemoteWorkerData. r=asuth
authorPerry Jiang <perry@mozilla.com>
Thu, 15 Aug 2019 17:26:42 +0000
changeset 488302 1db490b0883e9c5448beb6dd653e292318381755
parent 488301 fa280993de59a5e729359aa774391c54313c3807
child 488303 1a0992c678266b12eab5612a13cbe5cb4867e0ad
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [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);