From af20d1c10b3627301307e4e240b26632b1686544 Mon Sep 17 00:00:00 2001 From: Andreea Pavel Date: Thu, 14 Mar 2019 23:14:31 +0200 Subject: [PATCH] Backed out changeset a5beba8cc190 (bug 1534364) for assertion failures --- .../IPCServiceWorkerDescriptor.ipdlh | 6 ++ ...CServiceWorkerRegistrationDescriptor.ipdlh | 6 +- .../ServiceWorkerRegistrationDescriptor.cpp | 57 +++++++++++-------- .../ServiceWorkerRegistrationDescriptor.h | 1 + ipc/glue/BackgroundUtils.cpp | 33 ++++++----- netwerk/ipc/NeckoChannelParams.ipdlh | 6 +- 6 files changed, 63 insertions(+), 46 deletions(-) diff --git a/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh b/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh index ec6df6d9e52e..feb4be18ef53 100644 --- a/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh +++ b/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh @@ -23,5 +23,11 @@ struct IPCServiceWorkerDescriptor ServiceWorkerState state; }; +union OptionalIPCServiceWorkerDescriptor +{ + IPCServiceWorkerDescriptor; + void_t; +}; + } // namespace dom } // namespace mozilla diff --git a/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh b/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh index a411023e241c..988780b687d3 100644 --- a/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh +++ b/dom/serviceworkers/IPCServiceWorkerRegistrationDescriptor.ipdlh @@ -29,9 +29,9 @@ struct IPCServiceWorkerRegistrationDescriptor ServiceWorkerUpdateViaCache updateViaCache; - IPCServiceWorkerDescriptor? installing; - IPCServiceWorkerDescriptor? waiting; - IPCServiceWorkerDescriptor? active; + OptionalIPCServiceWorkerDescriptor installing; + OptionalIPCServiceWorkerDescriptor waiting; + OptionalIPCServiceWorkerDescriptor active; }; union IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult diff --git a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp index 52e17880215a..5ac1501959de 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.cpp @@ -19,12 +19,15 @@ using mozilla::ipc::PrincipalInfoToPrincipal; Maybe ServiceWorkerRegistrationDescriptor::NewestInternal() const { Maybe 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; } @@ -40,9 +43,9 @@ ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor( 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( @@ -51,7 +54,7 @@ ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor( ServiceWorkerUpdateViaCache aUpdateViaCache) : mData(MakeUnique( aId, aVersion, aPrincipalInfo, nsCString(aScope), aUpdateViaCache, - Nothing(), Nothing(), Nothing())) {} + void_t(), void_t(), void_t())) {} ServiceWorkerRegistrationDescriptor::ServiceWorkerRegistrationDescriptor( const IPCServiceWorkerRegistrationDescriptor& aDescriptor) @@ -132,8 +135,10 @@ Maybe ServiceWorkerRegistrationDescriptor::GetInstalling() const { Maybe 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; @@ -143,8 +148,9 @@ Maybe ServiceWorkerRegistrationDescriptor::GetWaiting() const { Maybe 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; @@ -154,8 +160,9 @@ Maybe ServiceWorkerRegistrationDescriptor::GetActive() const { Maybe 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; @@ -184,13 +191,13 @@ bool ServiceWorkerRegistrationDescriptor::HasWorker( namespace { bool IsValidWorker( - const Maybe& 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; } @@ -239,23 +246,23 @@ void ServiceWorkerRegistrationDescriptor::SetWorkers( 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()); diff --git a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h index 81d92a3e7b59..41c5d93b8bde 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h +++ b/dom/serviceworkers/ServiceWorkerRegistrationDescriptor.h @@ -19,6 +19,7 @@ class PrincipalInfo; namespace dom { class IPCServiceWorkerRegistrationDescriptor; +class OptionalIPCServiceWorkerDescriptor; class ServiceWorkerInfo; enum class ServiceWorkerUpdateViaCache : uint8_t; diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index ff205708c3a5..fff925bcc181 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -494,10 +494,10 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo, ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC()); } - Maybe ipcController; + OptionalIPCServiceWorkerDescriptor ipcController = mozilla::void_t(); const Maybe& controller = aLoadInfo->GetController(); if (controller.isSome()) { - ipcController.emplace(controller.ref().ToIPC()); + ipcController = controller.ref().ToIPC(); } nsAutoString cspNonce; @@ -656,9 +656,10 @@ nsresult LoadInfoArgsToLoadInfo( NS_ERROR_UNEXPECTED); Maybe 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 cookieSettings; @@ -708,7 +709,7 @@ 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 @@ -716,10 +717,10 @@ void LoadInfoToParentLoadInfoForwarder( return; } - Maybe ipcController; + OptionalIPCServiceWorkerDescriptor ipcController = void_t(); Maybe controller(aLoadInfo->GetController()); if (controller.isSome()) { - ipcController.emplace(controller.ref().ToIPC()); + ipcController = controller.ref().ToIPC(); } uint32_t tainting = nsILoadInfo::TAINTING_BASIC; @@ -760,8 +761,9 @@ nsresult MergeParentLoadInfoForwarder( 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()) { @@ -797,7 +799,7 @@ void LoadInfoToChildLoadInfoForwarder( nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) { if (!aLoadInfo) { *aForwarderArgsOut = - ChildLoadInfoForwarderArgs(Nothing(), Nothing(), Nothing()); + ChildLoadInfoForwarderArgs(Nothing(), Nothing(), void_t()); return; } @@ -813,10 +815,10 @@ void LoadInfoToChildLoadInfoForwarder( ipcInitial.emplace(initial.ref().ToIPC()); } - Maybe ipcController; + OptionalIPCServiceWorkerDescriptor ipcController = void_t(); Maybe controller(aLoadInfo->GetController()); if (controller.isSome()) { - ipcController.emplace(controller.ref().ToIPC()); + ipcController = controller.ref().ToIPC(); } *aForwarderArgsOut = @@ -868,8 +870,9 @@ nsresult MergeChildLoadInfoForwarder( 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; diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 96d79bc220e8..23109b33a360 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -130,7 +130,7 @@ struct LoadInfoArgs * window/worker client. We must send this across IPC to support * performing interception in the parent. */ - IPCServiceWorkerDescriptor? controller; + OptionalIPCServiceWorkerDescriptor controller; nsCString[] corsUnsafeHeaders; bool forcePreflight; @@ -162,7 +162,7 @@ struct ParentLoadInfoForwarderArgs // 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. @@ -200,7 +200,7 @@ struct ChildLoadInfoForwarderArgs // The ServiceWorker controller may be cleared in the child during // a redirect. - IPCServiceWorkerDescriptor? controller; + OptionalIPCServiceWorkerDescriptor controller; }; //-----------------------------------------------------------------------------