Bug 1441932 P1 Add the ServiceWorker controller to ParentLoadInfoForwarderArgs. r=mayhemer
authorBen Kelly <ben@wanderview.com>
Mon, 04 Jun 2018 09:26:50 -0700
changeset 421206 fcc1e1ae65ddb1282c9e1f78d5154886ec53f008
parent 421205 d9dd4a2f071b4d5db2e4119ba9228a9e1000a6dc
child 421207 503612a3376769c17b107cbecc9641cf11772c66
push id34090
push userbtara@mozilla.com
push dateTue, 05 Jun 2018 09:30:51 +0000
treeherdermozilla-central@a358755643e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1441932
milestone62.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 1441932 P1 Add the ServiceWorker controller to ParentLoadInfoForwarderArgs. r=mayhemer
ipc/glue/BackgroundUtils.cpp
ipc/glue/BackgroundUtils.h
netwerk/ipc/NeckoChannelParams.ipdlh
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -582,38 +582,53 @@ LoadInfoArgsToLoadInfo(const OptionalLoa
                           );
 
    loadInfo.forget(outLoadInfo);
    return NS_OK;
 }
 
 void
 LoadInfoToParentLoadInfoForwarder(nsILoadInfo* aLoadInfo,
-                                  ParentLoadInfoForwarderArgs* outLoadInfoChildForwardArgs)
+                                  ParentLoadInfoForwarderArgs* aForwarderArgsOut)
 {
   if (!aLoadInfo) {
+    *aForwarderArgsOut = ParentLoadInfoForwarderArgs(false, void_t());
     return;
   }
 
-  *outLoadInfoChildForwardArgs = ParentLoadInfoForwarderArgs(
-    aLoadInfo->GetAllowInsecureRedirectToDataURI()
+  OptionalIPCServiceWorkerDescriptor ipcController = void_t();
+  Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
+  if (controller.isSome()) {
+    ipcController = controller.ref().ToIPC();
+  }
+
+  *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
+    aLoadInfo->GetAllowInsecureRedirectToDataURI(),
+    ipcController
   );
 }
 
 nsresult
-MergeParentLoadInfoForwarder(ParentLoadInfoForwarderArgs const& outLoadInfoChildForwardArgs,
+MergeParentLoadInfoForwarder(ParentLoadInfoForwarderArgs const& aForwarderArgs,
                              nsILoadInfo* aLoadInfo)
 {
   if (!aLoadInfo) {
     return NS_OK;
   }
 
   nsresult rv;
 
   rv = aLoadInfo->SetAllowInsecureRedirectToDataURI(
-    outLoadInfoChildForwardArgs.allowInsecureRedirectToDataURI());
+    aForwarderArgs.allowInsecureRedirectToDataURI());
   NS_ENSURE_SUCCESS(rv, rv);
 
+  aLoadInfo->ClearController();
+  auto& controller = aForwarderArgs.controller();
+  if (controller.type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
+    aLoadInfo->SetController(
+      ServiceWorkerDescriptor(controller.get_IPCServiceWorkerDescriptor()));
+  }
+
   return NS_OK;
 }
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/BackgroundUtils.h
+++ b/ipc/glue/BackgroundUtils.h
@@ -112,22 +112,22 @@ nsresult
 LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
                        nsILoadInfo** outLoadInfo);
 
 /**
  * Fills ParentLoadInfoForwarderArgs with properties we want to carry to child processes.
  */
 void
 LoadInfoToParentLoadInfoForwarder(nsILoadInfo *aLoadInfo,
-                                  mozilla::net::ParentLoadInfoForwarderArgs* outLoadInfoChildForwardArgs);
+                                  mozilla::net::ParentLoadInfoForwarderArgs* aForwarderArgsOut);
 
 /**
  * Merges (replaces) properties of an existing LoadInfo on a child process
  * with properties carried down through ParentLoadInfoForwarderArgs.
  */
 nsresult
-MergeParentLoadInfoForwarder(mozilla::net::ParentLoadInfoForwarderArgs const& outLoadInfoChildForwardArgs,
+MergeParentLoadInfoForwarder(mozilla::net::ParentLoadInfoForwarderArgs const& aForwarderArgs,
                              nsILoadInfo *aLoadInfo);
 
 } // namespace ipc
 } // namespace mozilla
 
 #endif // mozilla_ipc_backgroundutils_h__
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -123,16 +123,20 @@ union OptionalLoadInfoArgs
 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.
+  OptionalIPCServiceWorkerDescriptor controller;
+
   // IMPORTANT: when you add new properites here you must also update
   // LoadInfoToParentLoadInfoForwarder and MergeParentLoadInfoForwarder
   // in BackgroundUtils.cpp/.h!
 };
 
 //-----------------------------------------------------------------------------
 // HTTP IPDL structs
 //-----------------------------------------------------------------------------