Backed out changeset a5beba8cc190 (bug 1534364) for assertion failures
authorAndreea Pavel <apavel@mozilla.com>
Thu, 14 Mar 2019 23:14:31 +0200
changeset 521963 1d23b016870a
parent 521962 afb5f4cea791
child 521964 d57870ac257d
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1534364
milestone67.0a1
backs outa5beba8cc190
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
Backed out changeset a5beba8cc190 (bug 1534364) for assertion failures
dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh
dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp
dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h
ipc/glue/BackgroundUtils.cpp
netwerk/ipc/NeckoChannelParams.ipdlh
--- a/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
+++ b/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
@@ -18,10 +18,16 @@ struct IPCServiceWorkerDescriptor
   uint64_t registrationId;
   uint64_t registrationVersion;
   PrincipalInfo principalInfo;
   nsCString scope;
   nsCString scriptURL;
   ServiceWorkerState state;
 };
 
+union OptionalIPCServiceWorkerDescriptor
+{
+  IPCServiceWorkerDescriptor;
+  void_t;
+};
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh
+++ b/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh
@@ -24,19 +24,19 @@ struct IPCServiceWorkerRegistrationDescr
   // but for now we duplicate the information here to ensure correctness.
   // Its possible we may need to reference a registration before the
   // worker is installed yet, etc.
   PrincipalInfo principalInfo;
   nsCString scope;
 
   ServiceWorkerUpdateViaCache updateViaCache;
 
-  IPCServiceWorkerDescriptor? installing;
-  IPCServiceWorkerDescriptor? waiting;
-  IPCServiceWorkerDescriptor? active;
+  OptionalIPCServiceWorkerDescriptor installing;
+  OptionalIPCServiceWorkerDescriptor waiting;
+  OptionalIPCServiceWorkerDescriptor active;
 };
 
 union IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult
 {
   IPCServiceWorkerRegistrationDescriptor;
   CopyableErrorResult;
 };
 
--- a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp
@@ -14,49 +14,52 @@ namespace mozilla {
 namespace dom {
 
 using mozilla::ipc::PrincipalInfo;
 using mozilla::ipc::PrincipalInfoToPrincipal;
 
 Maybe<IPCServiceWorkerDescriptor>
 ServiceWorkerRegistrationDescriptor::NewestInternal() const {
   Maybe<IPCServiceWorkerDescriptor> result;
-  if (mData->installing().isSome()) {
-    result.emplace(mData->installing().ref());
-  } else if (mData->waiting().isSome()) {
-    result.emplace(mData->waiting().ref());
-  } else if (mData->active().isSome()) {
-    result.emplace(mData->active().ref());
+  if (mData->installing().type() !=
+      OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(mData->installing().get_IPCServiceWorkerDescriptor());
+  } else if (mData->waiting().type() !=
+             OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(mData->waiting().get_IPCServiceWorkerDescriptor());
+  } else if (mData->active().type() !=
+             OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(mData->active().get_IPCServiceWorkerDescriptor());
   }
   return result;
 }
 
 ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor(
     uint64_t aId, uint64_t aVersion, nsIPrincipal* aPrincipal,
     const nsACString& aScope, ServiceWorkerUpdateViaCache aUpdateViaCache)
     : mData(MakeUnique<IPCServiceWorkerRegistrationDescriptor>()) {
   MOZ_ALWAYS_SUCCEEDS(
       PrincipalToPrincipalInfo(aPrincipal, &mData->principalInfo()));
 
   mData->id() = aId;
   mData->version() = aVersion;
   mData->scope() = aScope;
   mData->updateViaCache() = aUpdateViaCache;
-  mData->installing() = Nothing();
-  mData->waiting() = Nothing();
-  mData->active() = Nothing();
+  mData->installing() = void_t();
+  mData->waiting() = void_t();
+  mData->active() = void_t();
 }
 
 ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor(
     uint64_t aId, uint64_t aVersion,
     const mozilla::ipc::PrincipalInfo& aPrincipalInfo, const nsACString& aScope,
     ServiceWorkerUpdateViaCache aUpdateViaCache)
     : mData(MakeUnique<IPCServiceWorkerRegistrationDescriptor>(
           aId, aVersion, aPrincipalInfo, nsCString(aScope), aUpdateViaCache,
-          Nothing(), Nothing(), Nothing())) {}
+          void_t(), void_t(), void_t())) {}
 
 ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor(
     const IPCServiceWorkerRegistrationDescriptor& aDescriptor)
     : mData(MakeUnique<IPCServiceWorkerRegistrationDescriptor>(aDescriptor)) {
   MOZ_DIAGNOSTIC_ASSERT(IsValid());
 }
 
 ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor(
@@ -127,40 +130,44 @@ nsCOMPtr<nsIPrincipal> ServiceWorkerRegi
 const nsCString& ServiceWorkerRegistrationDescriptor::Scope() const {
   return mData->scope();
 }
 
 Maybe<ServiceWorkerDescriptor>
 ServiceWorkerRegistrationDescriptor::GetInstalling() const {
   Maybe<ServiceWorkerDescriptor> result;
 
-  if (mData->installing().isSome()) {
-    result.emplace(ServiceWorkerDescriptor(mData->installing().ref()));
+  if (mData->installing().type() !=
+      OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(ServiceWorkerDescriptor(
+        mData->installing().get_IPCServiceWorkerDescriptor()));
   }
 
   return result;
 }
 
 Maybe<ServiceWorkerDescriptor> ServiceWorkerRegistrationDescriptor::GetWaiting()
     const {
   Maybe<ServiceWorkerDescriptor> result;
 
-  if (mData->waiting().isSome()) {
-    result.emplace(ServiceWorkerDescriptor(mData->waiting().ref()));
+  if (mData->waiting().type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(ServiceWorkerDescriptor(
+        mData->waiting().get_IPCServiceWorkerDescriptor()));
   }
 
   return result;
 }
 
 Maybe<ServiceWorkerDescriptor> ServiceWorkerRegistrationDescriptor::GetActive()
     const {
   Maybe<ServiceWorkerDescriptor> result;
 
-  if (mData->active().isSome()) {
-    result.emplace(ServiceWorkerDescriptor(mData->active().ref()));
+  if (mData->active().type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    result.emplace(ServiceWorkerDescriptor(
+        mData->active().get_IPCServiceWorkerDescriptor()));
   }
 
   return result;
 }
 
 Maybe<ServiceWorkerDescriptor> ServiceWorkerRegistrationDescriptor::Newest()
     const {
   Maybe<ServiceWorkerDescriptor> result;
@@ -179,23 +186,23 @@ bool ServiceWorkerRegistrationDescriptor
   return (installing.isSome() && installing.ref().Matches(aDescriptor)) ||
          (waiting.isSome() && waiting.ref().Matches(aDescriptor)) ||
          (active.isSome() && active.ref().Matches(aDescriptor));
 }
 
 namespace {
 
 bool IsValidWorker(
-    const Maybe<IPCServiceWorkerDescriptor>& aWorker, const nsACString& aScope,
+    const OptionalIPCServiceWorkerDescriptor& aWorker, const nsACString& aScope,
     const mozilla::ipc::ContentPrincipalInfo& aContentPrincipal) {
-  if (aWorker.isNothing()) {
+  if (aWorker.type() == OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
     return true;
   }
 
-  auto& worker = aWorker.ref();
+  auto& worker = aWorker.get_IPCServiceWorkerDescriptor();
   if (worker.scope() != aScope) {
     return false;
   }
 
   auto& principalInfo = worker.principalInfo();
   if (principalInfo.type() !=
       mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) {
     return false;
@@ -234,33 +241,33 @@ void ServiceWorkerRegistrationDescriptor
   mData->updateViaCache() = aUpdateViaCache;
 }
 
 void ServiceWorkerRegistrationDescriptor::SetWorkers(
     ServiceWorkerInfo* aInstalling, ServiceWorkerInfo* aWaiting,
     ServiceWorkerInfo* aActive) {
   if (aInstalling) {
     aInstalling->SetRegistrationVersion(Version());
-    mData->installing().emplace(aInstalling->Descriptor().ToIPC());
+    mData->installing() = aInstalling->Descriptor().ToIPC();
   } else {
-    mData->installing() = Nothing();
+    mData->installing() = void_t();
   }
 
   if (aWaiting) {
     aWaiting->SetRegistrationVersion(Version());
-    mData->waiting().emplace(aWaiting->Descriptor().ToIPC());
+    mData->waiting() = aWaiting->Descriptor().ToIPC();
   } else {
-    mData->waiting() = Nothing();
+    mData->waiting() = void_t();
   }
 
   if (aActive) {
     aActive->SetRegistrationVersion(Version());
-    mData->active().emplace(aActive->Descriptor().ToIPC());
+    mData->active() = aActive->Descriptor().ToIPC();
   } else {
-    mData->active() = Nothing();
+    mData->active() = void_t();
   }
 
   MOZ_DIAGNOSTIC_ASSERT(IsValid());
 }
 
 void ServiceWorkerRegistrationDescriptor::SetVersion(uint64_t aVersion) {
   MOZ_DIAGNOSTIC_ASSERT(aVersion > mData->version());
   mData->version() = aVersion;
--- a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h
+++ b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h
@@ -14,16 +14,17 @@ namespace mozilla {
 
 namespace ipc {
 class PrincipalInfo;
 }  // namespace ipc
 
 namespace dom {
 
 class IPCServiceWorkerRegistrationDescriptor;
+class OptionalIPCServiceWorkerDescriptor;
 class ServiceWorkerInfo;
 enum class ServiceWorkerUpdateViaCache : uint8_t;
 
 // This class represents a snapshot of a particular
 // ServiceWorkerRegistrationInfo object. It is threadsafe and can be
 // transferred across processes.
 class ServiceWorkerRegistrationDescriptor final {
   // This class is largely a wrapper wround an IPDL generated struct.  We
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -489,20 +489,20 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadI
 
   Maybe<IPCClientInfo> ipcInitialClientInfo;
   const Maybe<ClientInfo>& initialClientInfo =
       aLoadInfo->GetInitialClientInfo();
   if (initialClientInfo.isSome()) {
     ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC());
   }
 
-  Maybe<IPCServiceWorkerDescriptor> ipcController;
+  OptionalIPCServiceWorkerDescriptor ipcController = mozilla::void_t();
   const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController();
   if (controller.isSome()) {
-    ipcController.emplace(controller.ref().ToIPC());
+    ipcController = controller.ref().ToIPC();
   }
 
   nsAutoString cspNonce;
   Unused << NS_WARN_IF(NS_FAILED(aLoadInfo->GetCspNonce(cspNonce)));
 
   nsCOMPtr<nsICookieSettings> cookieSettings;
   rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -651,19 +651,20 @@ nsresult LoadInfoArgsToLoadInfo(
   // We can have an initial client info or a reserved client info, but not both.
   MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||
                         initialClientInfo.isNothing());
   NS_ENSURE_TRUE(
       reservedClientInfo.isNothing() || initialClientInfo.isNothing(),
       NS_ERROR_UNEXPECTED);
 
   Maybe<ServiceWorkerDescriptor> controller;
-  if (loadInfoArgs.controller().isSome()) {
-    controller.emplace(
-        ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
+  if (loadInfoArgs.controller().type() !=
+      OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    controller.emplace(ServiceWorkerDescriptor(
+        loadInfoArgs.controller().get_IPCServiceWorkerDescriptor()));
   }
 
   nsCOMPtr<nsICookieSettings> cookieSettings;
   CookieSettings::Deserialize(loadInfoArgs.cookieSettings(),
                               getter_AddRefs(cookieSettings));
 
   RefPtr<mozilla::LoadInfo> loadInfo = new mozilla::LoadInfo(
       loadingPrincipal, triggeringPrincipal, principalToInherit,
@@ -703,28 +704,28 @@ nsresult LoadInfoArgsToLoadInfo(
   loadInfo.forget(outLoadInfo);
   return NS_OK;
 }
 
 void LoadInfoToParentLoadInfoForwarder(
     nsILoadInfo* aLoadInfo, ParentLoadInfoForwarderArgs* aForwarderArgsOut) {
   if (!aLoadInfo) {
     *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
-        false, Nothing(), nsILoadInfo::TAINTING_BASIC,
+        false, void_t(), nsILoadInfo::TAINTING_BASIC,
         false,  // serviceWorkerTaintingSynthesized
         false,  // documentHasUserInteracted
         false,  // documentHasLoaded
         nsILoadInfo::OPENER_POLICY_NULL, Maybe<CookieSettingsArgs>());
     return;
   }
 
-  Maybe<IPCServiceWorkerDescriptor> ipcController;
+  OptionalIPCServiceWorkerDescriptor ipcController = void_t();
   Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
   if (controller.isSome()) {
-    ipcController.emplace(controller.ref().ToIPC());
+    ipcController = controller.ref().ToIPC();
   }
 
   uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
   Unused << aLoadInfo->GetTainting(&tainting);
 
   nsILoadInfo::CrossOriginOpenerPolicy openerPolicy =
       aLoadInfo->GetOpenerPolicy();
 
@@ -755,18 +756,19 @@ nsresult MergeParentLoadInfoForwarder(
   nsresult rv;
 
   rv = aLoadInfo->SetAllowInsecureRedirectToDataURI(
       aForwarderArgs.allowInsecureRedirectToDataURI());
   NS_ENSURE_SUCCESS(rv, rv);
 
   aLoadInfo->ClearController();
   auto& controller = aForwarderArgs.controller();
-  if (controller.isSome()) {
-    aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
+  if (controller.type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    aLoadInfo->SetController(
+        ServiceWorkerDescriptor(controller.get_IPCServiceWorkerDescriptor()));
   }
 
   if (aForwarderArgs.serviceWorkerTaintingSynthesized()) {
     aLoadInfo->SynthesizeServiceWorkerTainting(
         static_cast<LoadTainting>(aForwarderArgs.tainting()));
   } else {
     aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
   }
@@ -792,36 +794,36 @@ nsresult MergeParentLoadInfoForwarder(
 
   return NS_OK;
 }
 
 void LoadInfoToChildLoadInfoForwarder(
     nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
   if (!aLoadInfo) {
     *aForwarderArgsOut =
-        ChildLoadInfoForwarderArgs(Nothing(), Nothing(), Nothing());
+        ChildLoadInfoForwarderArgs(Nothing(), Nothing(), void_t());
     return;
   }
 
   Maybe<IPCClientInfo> ipcReserved;
   Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo());
   if (reserved.isSome()) {
     ipcReserved.emplace(reserved.ref().ToIPC());
   }
 
   Maybe<IPCClientInfo> ipcInitial;
   Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo());
   if (initial.isSome()) {
     ipcInitial.emplace(initial.ref().ToIPC());
   }
 
-  Maybe<IPCServiceWorkerDescriptor> ipcController;
+  OptionalIPCServiceWorkerDescriptor ipcController = void_t();
   Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
   if (controller.isSome()) {
-    ipcController.emplace(controller.ref().ToIPC());
+    ipcController = controller.ref().ToIPC();
   }
 
   *aForwarderArgsOut =
       ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController);
 }
 
 nsresult MergeChildLoadInfoForwarder(
     const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) {
@@ -863,17 +865,18 @@ nsresult MergeChildLoadInfoForwarder(
     // child-side of the redirect.
     aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref());
   } else if (initialClientInfo.isSome()) {
     aLoadInfo->SetInitialClientInfo(initialClientInfo.ref());
   }
 
   aLoadInfo->ClearController();
   auto& controller = aForwarderArgs.controller();
-  if (controller.isSome()) {
-    aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
+  if (controller.type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    aLoadInfo->SetController(
+        ServiceWorkerDescriptor(controller.get_IPCServiceWorkerDescriptor()));
   }
 
   return NS_OK;
 }
 
 }  // namespace ipc
 }  // namespace mozilla
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -125,17 +125,17 @@ struct LoadInfoArgs
   IPCClientInfo?              reservedClientInfo;
   IPCClientInfo?              initialClientInfo;
 
   /**
    * Subresource loads may have a controller set based on their owning
    * window/worker client.  We must send this across IPC to support
    * performing interception in the parent.
    */
-  IPCServiceWorkerDescriptor? controller;
+  OptionalIPCServiceWorkerDescriptor controller;
 
   nsCString[]                 corsUnsafeHeaders;
   bool                        forcePreflight;
   bool                        isPreflight;
   bool                        loadTriggeredFromExternal;
   bool                        serviceWorkerTaintingSynthesized;
   bool                        documentHasUserInteracted;
   bool                        documentHasLoaded;
@@ -157,17 +157,17 @@ struct ParentLoadInfoForwarderArgs
   // WebExtextensions' WebRequest API allows extensions to intercept and
   // redirect a channel to a data URI. This modifications happens in
   // the parent and needs to be mirrored to the child so that security
   // checks can pass.
   bool allowInsecureRedirectToDataURI;
 
   // The ServiceWorker controller that may be set in the parent when
   // interception occurs.
-  IPCServiceWorkerDescriptor? controller;
+  OptionalIPCServiceWorkerDescriptor controller;
 
   // The service worker may synthesize a Response with a particular
   // tainting value.
   uint32_t tainting;
 
   // We must also note that the tainting value was explicitly set
   // by the service worker.
   bool serviceWorkerTaintingSynthesized;
@@ -195,17 +195,17 @@ struct ChildLoadInfoForwarderArgs
 {
   // The reserved and initial ClientInfo values may change during a
   // redirect if the new channel is cross-origin to the old channel.
   IPCClientInfo? reservedClientInfo;
   IPCClientInfo? initialClientInfo;
 
   // The ServiceWorker controller may be cleared in the child during
   // a redirect.
-  IPCServiceWorkerDescriptor? controller;
+  OptionalIPCServiceWorkerDescriptor controller;
 };
 
 //-----------------------------------------------------------------------------
 // HTTP IPDL structs
 //-----------------------------------------------------------------------------
 
 struct CorsPreflightArgs
 {