Bug 1533066 - replace OptionalIPCClientInfo with IPCClientInfo? in IPDL; r=valentin
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 06 Mar 2019 17:57:04 +0000
changeset 520573 1f0368105e07f22633e4ea0d0dfe8becccb8bdc0
parent 520572 413190773025f4c6ea37fd32914ae8c8cc98a1cc
child 520574 690713aece131e39b8539ecd206d4295ab1f1879
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1533066
milestone67.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 1533066 - replace OptionalIPCClientInfo with IPCClientInfo? in IPDL; r=valentin Differential Revision: https://phabricator.services.mozilla.com/D22332
dom/clients/manager/ClientIPCTypes.ipdlh
dom/workers/remoteworkers/RemoteWorkerChild.cpp
dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
dom/workers/sharedworkers/SharedWorker.cpp
ipc/glue/BackgroundUtils.cpp
netwerk/ipc/NeckoChannelParams.ipdlh
--- a/dom/clients/manager/ClientIPCTypes.ipdlh
+++ b/dom/clients/manager/ClientIPCTypes.ipdlh
@@ -29,22 +29,16 @@ struct IPCClientInfo
   nsID id;
   ClientType type;
   PrincipalInfo principalInfo;
   TimeStamp creationTime;
   nsCString url;
   FrameType frameType;
 };
 
-union OptionalIPCClientInfo
-{
-  IPCClientInfo;
-  void_t;
-};
-
 struct IPCClientWindowState
 {
   VisibilityState visibilityState;
   TimeStamp lastFocusTime;
   StorageAccess storageAccess;
   bool focused;
 };
 
--- a/dom/workers/remoteworkers/RemoteWorkerChild.cpp
+++ b/dom/workers/remoteworkers/RemoteWorkerChild.cpp
@@ -286,18 +286,18 @@ nsresult RemoteWorkerChild::ExecWorkerOn
   info.mInterfaceRequestor->SetOuterRequestor(requestor);
 
   rv = info.SetPrincipalOnMainThread(info.mPrincipal, info.mLoadGroup);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   Maybe<ClientInfo> clientInfo;
-  if (aData.clientInfo().type() == OptionalIPCClientInfo::TIPCClientInfo) {
-    clientInfo.emplace(ClientInfo(aData.clientInfo().get_IPCClientInfo()));
+  if (aData.clientInfo().isSome()) {
+    clientInfo.emplace(ClientInfo(aData.clientInfo().ref()));
   }
 
   // Top level workers' main script use the document charset for the script
   // uri encoding.
   rv = ChannelFromScriptURLMainThread(
       info.mLoadingPrincipal, nullptr /* parent document */, info.mLoadGroup,
       info.mResolvedScriptURI, clientInfo,
       aData.isSharedWorker() ? nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER
--- a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
+++ b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh
@@ -36,17 +36,17 @@ struct RemoteWorkerData
   PrincipalInfo principalInfo;
   ContentSecurityPolicy[] principalCsp;
   ContentSecurityPolicy[] principalPreloadCsp;
 
   nsCString domain;
 
   bool isSecureContext;
 
-  OptionalIPCClientInfo clientInfo;
+  IPCClientInfo? clientInfo;
 
   bool isStorageAccessAllowed;
 
   bool isSharedWorker;
 };
 
 // ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote
 // which in turn correspond to JSErrorReport/JSErrorNotes which allows JS to
--- a/dom/workers/sharedworkers/SharedWorker.cpp
+++ b/dom/workers/sharedworkers/SharedWorker.cpp
@@ -193,22 +193,20 @@ already_AddRefed<SharedWorker> SharedWor
   URIParams baseURL;
   SerializeURI(loadInfo.mBaseURI, baseURL);
 
   // Register this component to PBackground.
   PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
 
   bool isSecureContext = JS::GetIsSecureContext(js::GetContextRealm(cx));
 
-  OptionalIPCClientInfo ipcClientInfo;
+  Maybe<IPCClientInfo> ipcClientInfo;
   Maybe<ClientInfo> clientInfo = window->GetClientInfo();
   if (clientInfo.isSome()) {
-    ipcClientInfo = clientInfo.value().ToIPC();
-  } else {
-    ipcClientInfo = void_t();
+    ipcClientInfo.emplace(clientInfo.value().ToIPC());
   }
 
   bool storageAccessAllowed =
       storageAllowed > nsContentUtils::StorageAccess::eDeny;
 
   RemoteWorkerData remoteWorkerData(
       nsString(aScriptURL), baseURL, resolvedScriptURL, name,
       loadingPrincipalInfo, loadingPrincipalCSP, loadingPrincipalPreloadCSP,
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -452,34 +452,34 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadI
   nsTArray<PrincipalInfo> ancestorPrincipals;
   ancestorPrincipals.SetCapacity(aLoadInfo->AncestorPrincipals().Length());
   for (const auto& principal : aLoadInfo->AncestorPrincipals()) {
     rv =
         PrincipalToPrincipalInfo(principal, ancestorPrincipals.AppendElement());
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  OptionalIPCClientInfo ipcClientInfo = mozilla::void_t();
+  Maybe<IPCClientInfo> ipcClientInfo;
   const Maybe<ClientInfo>& clientInfo = aLoadInfo->GetClientInfo();
   if (clientInfo.isSome()) {
-    ipcClientInfo = clientInfo.ref().ToIPC();
+    ipcClientInfo.emplace(clientInfo.ref().ToIPC());
   }
 
-  OptionalIPCClientInfo ipcReservedClientInfo = mozilla::void_t();
+  Maybe<IPCClientInfo> ipcReservedClientInfo;
   const Maybe<ClientInfo>& reservedClientInfo =
       aLoadInfo->GetReservedClientInfo();
   if (reservedClientInfo.isSome()) {
-    ipcReservedClientInfo = reservedClientInfo.ref().ToIPC();
+    ipcReservedClientInfo.emplace(reservedClientInfo.ref().ToIPC());
   }
 
-  OptionalIPCClientInfo ipcInitialClientInfo = mozilla::void_t();
+  Maybe<IPCClientInfo> ipcInitialClientInfo;
   const Maybe<ClientInfo>& initialClientInfo =
       aLoadInfo->GetInitialClientInfo();
   if (initialClientInfo.isSome()) {
-    ipcInitialClientInfo = initialClientInfo.ref().ToIPC();
+    ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC());
   }
 
   OptionalIPCServiceWorkerDescriptor ipcController = mozilla::void_t();
   const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController();
   if (controller.isSome()) {
     ipcController = controller.ref().ToIPC();
   }
 
@@ -602,33 +602,30 @@ nsresult LoadInfoArgsToLoadInfo(
   for (const PrincipalInfo& principalInfo : loadInfoArgs.ancestorPrincipals()) {
     nsCOMPtr<nsIPrincipal> ancestorPrincipal =
         PrincipalInfoToPrincipal(principalInfo, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     ancestorPrincipals.AppendElement(ancestorPrincipal.forget());
   }
 
   Maybe<ClientInfo> clientInfo;
-  if (loadInfoArgs.clientInfo().type() != OptionalIPCClientInfo::Tvoid_t) {
-    clientInfo.emplace(
-        ClientInfo(loadInfoArgs.clientInfo().get_IPCClientInfo()));
+  if (loadInfoArgs.clientInfo().isSome()) {
+    clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref()));
   }
 
   Maybe<ClientInfo> reservedClientInfo;
-  if (loadInfoArgs.reservedClientInfo().type() !=
-      OptionalIPCClientInfo::Tvoid_t) {
+  if (loadInfoArgs.reservedClientInfo().isSome()) {
     reservedClientInfo.emplace(
-        ClientInfo(loadInfoArgs.reservedClientInfo().get_IPCClientInfo()));
+        ClientInfo(loadInfoArgs.reservedClientInfo().ref()));
   }
 
   Maybe<ClientInfo> initialClientInfo;
-  if (loadInfoArgs.initialClientInfo().type() !=
-      OptionalIPCClientInfo::Tvoid_t) {
+  if (loadInfoArgs.initialClientInfo().isSome()) {
     initialClientInfo.emplace(
-        ClientInfo(loadInfoArgs.initialClientInfo().get_IPCClientInfo()));
+        ClientInfo(loadInfoArgs.initialClientInfo().ref()));
   }
 
   // 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);
@@ -746,30 +743,30 @@ nsresult MergeParentLoadInfoForwarder(
 
   return NS_OK;
 }
 
 void LoadInfoToChildLoadInfoForwarder(
     nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
   if (!aLoadInfo) {
     *aForwarderArgsOut =
-        ChildLoadInfoForwarderArgs(void_t(), void_t(), void_t());
+        ChildLoadInfoForwarderArgs(Nothing(), Nothing(), void_t());
     return;
   }
 
-  OptionalIPCClientInfo ipcReserved = void_t();
+  Maybe<IPCClientInfo> ipcReserved;
   Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo());
   if (reserved.isSome()) {
-    ipcReserved = reserved.ref().ToIPC();
+    ipcReserved.emplace(reserved.ref().ToIPC());
   }
 
-  OptionalIPCClientInfo ipcInitial = void_t();
+  Maybe<IPCClientInfo> ipcInitial;
   Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo());
   if (initial.isSome()) {
-    ipcInitial = initial.ref().ToIPC();
+    ipcInitial.emplace(initial.ref().ToIPC());
   }
 
   OptionalIPCServiceWorkerDescriptor ipcController = void_t();
   Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
   if (controller.isSome()) {
     ipcController = controller.ref().ToIPC();
   }
 
@@ -780,24 +777,24 @@ void LoadInfoToChildLoadInfoForwarder(
 nsresult MergeChildLoadInfoForwarder(
     const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) {
   if (!aLoadInfo) {
     return NS_OK;
   }
 
   Maybe<ClientInfo> reservedClientInfo;
   auto& ipcReserved = aForwarderArgs.reservedClientInfo();
-  if (ipcReserved.type() != OptionalIPCClientInfo::Tvoid_t) {
-    reservedClientInfo.emplace(ClientInfo(ipcReserved.get_IPCClientInfo()));
+  if (ipcReserved.isSome()) {
+    reservedClientInfo.emplace(ClientInfo(ipcReserved.ref()));
   }
 
   Maybe<ClientInfo> initialClientInfo;
   auto& ipcInitial = aForwarderArgs.initialClientInfo();
-  if (ipcInitial.type() != OptionalIPCClientInfo::Tvoid_t) {
-    initialClientInfo.emplace(ClientInfo(ipcInitial.get_IPCClientInfo()));
+  if (ipcInitial.isSome()) {
+    initialClientInfo.emplace(ClientInfo(ipcInitial.ref()));
   }
 
   // There should only be at most one reserved or initial ClientInfo.
   if (NS_WARN_IF(reservedClientInfo.isSome() && initialClientInfo.isSome())) {
     return NS_ERROR_FAILURE;
   }
 
   // If we received no reserved or initial ClientInfo, then we must not
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -89,29 +89,29 @@ struct LoadInfoArgs
    * Ancestor data for use with the WebRequest API.
    * See nsILoadInfo.idl for details.
    */
   PrincipalInfo[]             ancestorPrincipals;
   uint64_t[]                  ancestorOuterWindowIDs;
 
   /**
    * ClientInfo structure representing the window or worker that triggered
-   * this network request.  May be void_t if its a system internal request.
+   * this network request.  May be Nothing if its a system internal request.
    */
-  OptionalIPCClientInfo       clientInfo;
+  IPCClientInfo?              clientInfo;
 
   /**
    * Non-subresource requests will result in the creation of a window or
    * worker client.  The reserved and initial ClientInfo values represent
    * this resulting client.  An initial ClientInfo represents an initial
    * about:blank window that will be re-used while a reserved ClientInfo
    * represents a to-be-newly-created window/worker.
    */
-  OptionalIPCClientInfo       reservedClientInfo;
-  OptionalIPCClientInfo       initialClientInfo;
+  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.
    */
   OptionalIPCServiceWorkerDescriptor controller;
 
@@ -169,18 +169,18 @@ struct ParentLoadInfoForwarderArgs
  * during a redirect.  We don't want to use LoadInfoArgs for that since
  * it's too huge and we only care about small subpart of properties
  * anyway.
  */
 struct ChildLoadInfoForwarderArgs
 {
   // The reserved and initial ClientInfo values may change during a
   // redirect if the new channel is cross-origin to the old channel.
-  OptionalIPCClientInfo reservedClientInfo;
-  OptionalIPCClientInfo initialClientInfo;
+  IPCClientInfo? reservedClientInfo;
+  IPCClientInfo? initialClientInfo;
 
   // The ServiceWorker controller may be cleared in the child during
   // a redirect.
   OptionalIPCServiceWorkerDescriptor controller;
 };
 
 //-----------------------------------------------------------------------------
 // HTTP IPDL structs