Bug 1528814: Serialize Loadinfo for PExternalHelperApp. r=mayhemer
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Mon, 18 Feb 2019 18:11:22 +0100
changeset 459895 d5bafd3c816e798da0c086687dcd0e0b6f85f777
parent 459894 f3197be1dd896e5582f44a1e6ad53c281471cc0f
child 459896 8c7b302aa952e7a978a10609dc3e3045c0f3d155
push id35579
push userdvarga@mozilla.com
push dateTue, 19 Feb 2019 21:39:51 +0000
treeherdermozilla-central@57c4b2afc95b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1528814
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 1528814: Serialize Loadinfo for PExternalHelperApp. r=mayhemer
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
uriloader/exthandler/ExternalHelperAppParent.cpp
uriloader/exthandler/ExternalHelperAppParent.h
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1964,18 +1964,19 @@ PPSMContentDownloaderChild* ContentChild
 bool ContentChild::DeallocPPSMContentDownloaderChild(
     PPSMContentDownloaderChild* aListener) {
   auto* listener = static_cast<PSMContentDownloaderChild*>(aListener);
   RefPtr<PSMContentDownloaderChild> child = dont_AddRef(listener);
   return true;
 }
 
 PExternalHelperAppChild* ContentChild::AllocPExternalHelperAppChild(
-    const OptionalURIParams& uri, const nsCString& aMimeContentType,
-    const nsCString& aContentDisposition,
+    const OptionalURIParams& uri,
+    const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+    const nsCString& aMimeContentType, const nsCString& aContentDisposition,
     const uint32_t& aContentDispositionHint,
     const nsString& aContentDispositionFilename, const bool& aForceSave,
     const int64_t& aContentLength, const bool& aWasFileChannel,
     const OptionalURIParams& aReferrer, PBrowserChild* aBrowser) {
   auto* child = new ExternalHelperAppChild();
   child->AddRef();
   return child;
 }
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -276,18 +276,19 @@ class ContentChild final : public PConte
 
   PPSMContentDownloaderChild* AllocPPSMContentDownloaderChild(
       const uint32_t& aCertType);
 
   bool DeallocPPSMContentDownloaderChild(
       PPSMContentDownloaderChild* aDownloader);
 
   PExternalHelperAppChild* AllocPExternalHelperAppChild(
-      const OptionalURIParams& uri, const nsCString& aMimeContentType,
-      const nsCString& aContentDisposition,
+      const OptionalURIParams& uri,
+      const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+      const nsCString& aMimeContentType, const nsCString& aContentDisposition,
       const uint32_t& aContentDispositionHint,
       const nsString& aContentDispositionFilename, const bool& aForceSave,
       const int64_t& aContentLength, const bool& aWasFileChannel,
       const OptionalURIParams& aReferrer, PBrowserChild* aBrowser);
 
   bool DeallocPExternalHelperAppChild(PExternalHelperAppChild* aService);
 
   PHandlerServiceChild* AllocPHandlerServiceChild();
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3591,24 +3591,25 @@ PPSMContentDownloaderParent* ContentPare
 bool ContentParent::DeallocPPSMContentDownloaderParent(
     PPSMContentDownloaderParent* aListener) {
   auto* listener = static_cast<PSMContentDownloaderParent*>(aListener);
   RefPtr<PSMContentDownloaderParent> downloader = dont_AddRef(listener);
   return true;
 }
 
 PExternalHelperAppParent* ContentParent::AllocPExternalHelperAppParent(
-    const OptionalURIParams& uri, const nsCString& aMimeContentType,
-    const nsCString& aContentDisposition,
+    const OptionalURIParams& uri,
+    const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+    const nsCString& aMimeContentType, const nsCString& aContentDisposition,
     const uint32_t& aContentDispositionHint,
     const nsString& aContentDispositionFilename, const bool& aForceSave,
     const int64_t& aContentLength, const bool& aWasFileChannel,
     const OptionalURIParams& aReferrer, PBrowserParent* aBrowser) {
   ExternalHelperAppParent* parent = new ExternalHelperAppParent(
-      uri, aContentLength, aWasFileChannel, aContentDisposition,
+      uri, aLoadInfoArgs, aContentLength, aWasFileChannel, aContentDisposition,
       aContentDispositionHint, aContentDispositionFilename);
   parent->AddRef();
   parent->Init(this, aMimeContentType, aForceSave, aReferrer, aBrowser);
   return parent;
 }
 
 bool ContentParent::DeallocPExternalHelperAppParent(
     PExternalHelperAppParent* aService) {
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -6,16 +6,17 @@
 
 #ifndef mozilla_dom_ContentParent_h
 #define mozilla_dom_ContentParent_h
 
 #include "mozilla/dom/PContentParent.h"
 #include "mozilla/dom/nsIContentParent.h"
 #include "mozilla/gfx/gfxVarReceiver.h"
 #include "mozilla/gfx/GPUProcessListener.h"
+#include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/HalTypes.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/MemoryReportingProcess.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TimeStamp.h"
@@ -892,18 +893,19 @@ class ContentParent final : public PCont
 
   PPSMContentDownloaderParent* AllocPPSMContentDownloaderParent(
       const uint32_t& aCertType);
 
   bool DeallocPPSMContentDownloaderParent(
       PPSMContentDownloaderParent* aDownloader);
 
   PExternalHelperAppParent* AllocPExternalHelperAppParent(
-      const OptionalURIParams& aUri, const nsCString& aMimeContentType,
-      const nsCString& aContentDisposition,
+      const OptionalURIParams& aUri,
+      const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+      const nsCString& aMimeContentType, const nsCString& aContentDisposition,
       const uint32_t& aContentDispositionHint,
       const nsString& aContentDispositionFilename, const bool& aForceSave,
       const int64_t& aContentLength, const bool& aWasFileChannel,
       const OptionalURIParams& aReferrer, PBrowserParent* aBrowser);
 
   bool DeallocPExternalHelperAppParent(PExternalHelperAppParent* aService);
 
   PHandlerServiceParent* AllocPHandlerServiceParent();
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -889,16 +889,17 @@ parent:
     // complex. In the long run, the notification implementation will be
     // overhauled to directly process the notification click/close and directly
     // translate that to a ServiceWorker event.
     async NotificationEvent(nsString type, NotificationEventData data);
 
     async PPSMContentDownloader(uint32_t aCertType);
 
     async PExternalHelperApp(OptionalURIParams uri,
+                             OptionalLoadInfoArgs loadInfoArgs,
                              nsCString aMimeContentType,
                              nsCString aContentDisposition,
                              uint32_t aContentDispositionHint,
                              nsString aContentDispositionFilename,
                              bool aForceSave,
                              int64_t aContentLength,
                              bool aWasFileChannel,
                              OptionalURIParams aReferrer,
--- a/uriloader/exthandler/ExternalHelperAppParent.cpp
+++ b/uriloader/exthandler/ExternalHelperAppParent.cpp
@@ -28,18 +28,20 @@ namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS_INHERITED(ExternalHelperAppParent, nsHashPropertyBag,
                             nsIRequest, nsIChannel, nsIMultiPartChannel,
                             nsIPrivateBrowsingChannel, nsIResumableChannel,
                             nsIStreamListener, nsIExternalHelperAppParent)
 
 ExternalHelperAppParent::ExternalHelperAppParent(
-    const OptionalURIParams& uri, const int64_t& aContentLength,
-    const bool& aWasFileChannel, const nsCString& aContentDispositionHeader,
+    const OptionalURIParams& uri,
+    const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+    const int64_t& aContentLength, const bool& aWasFileChannel,
+    const nsCString& aContentDispositionHeader,
     const uint32_t& aContentDispositionHint,
     const nsString& aContentDispositionFilename)
     : mURI(DeserializeURI(uri)),
       mPending(false)
 #ifdef DEBUG
       ,
       mDiverted(false)
 #endif
@@ -54,16 +56,18 @@ ExternalHelperAppParent::ExternalHelperA
     NS_GetFilenameFromDisposition(mContentDispositionFilename,
                                   mContentDispositionHeader, mURI);
     mContentDisposition =
         NS_GetContentDispositionFromHeader(mContentDispositionHeader, this);
   } else {
     mContentDisposition = aContentDispositionHint;
     mContentDispositionFilename = aContentDispositionFilename;
   }
+  mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
+                                       getter_AddRefs(mLoadInfo));
 }
 
 already_AddRefed<nsIInterfaceRequestor> GetWindowFromTabParent(
     PBrowserParent* aBrowser) {
   if (!aBrowser) {
     return nullptr;
   }
 
@@ -317,17 +321,17 @@ ExternalHelperAppParent::GetOwner(nsISup
 
 NS_IMETHODIMP
 ExternalHelperAppParent::SetOwner(nsISupports* aOwner) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 ExternalHelperAppParent::GetLoadInfo(nsILoadInfo** aLoadInfo) {
-  *aLoadInfo = nullptr;
+  NS_IF_ADDREF(*aLoadInfo = mLoadInfo);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ExternalHelperAppParent::SetLoadInfo(nsILoadInfo* aLoadInfo) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/uriloader/exthandler/ExternalHelperAppParent.h
+++ b/uriloader/exthandler/ExternalHelperAppParent.h
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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 "mozilla/dom/PExternalHelperAppParent.h"
+#include "mozilla/ipc/BackgroundUtils.h"
 #include "nsIChannel.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIResumableChannel.h"
 #include "nsIStreamListener.h"
 #include "nsHashPropertyBag.h"
 #include "PrivateBrowsingChannel.h"
 
 namespace IPC {
@@ -78,35 +79,37 @@ class ExternalHelperAppParent
                                               const uint32_t& count) override;
   mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& code) override;
 
   mozilla::ipc::IPCResult RecvDivertToParentUsing(
       PChannelDiverterParent* diverter, PBrowserParent* aBrowser) override;
 
   bool WasFileChannel() override { return mWasFileChannel; }
 
-  ExternalHelperAppParent(const OptionalURIParams& uri,
-                          const int64_t& contentLength,
-                          const bool& wasFileChannel,
-                          const nsCString& aContentDispositionHeader,
-                          const uint32_t& aContentDispositionHint,
-                          const nsString& aContentDispositionFilename);
+  ExternalHelperAppParent(
+      const OptionalURIParams& uri,
+      const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
+      const int64_t& contentLength, const bool& wasFileChannel,
+      const nsCString& aContentDispositionHeader,
+      const uint32_t& aContentDispositionHint,
+      const nsString& aContentDispositionFilename);
   void Init(ContentParent* parent, const nsCString& aMimeContentType,
             const bool& aForceSave, const OptionalURIParams& aReferrer,
             PBrowserParent* aBrowser);
 
  protected:
   virtual ~ExternalHelperAppParent();
 
   virtual void ActorDestroy(ActorDestroyReason why) override;
   void Delete();
 
  private:
   nsCOMPtr<nsIStreamListener> mListener;
   nsCOMPtr<nsIURI> mURI;
+  nsCOMPtr<nsILoadInfo> mLoadInfo;
   bool mPending;
 #ifdef DEBUG
   bool mDiverted;
 #endif
   bool mIPCClosed;
   nsLoadFlags mLoadFlags;
   nsresult mStatus;
   int64_t mContentLength;
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -611,44 +611,50 @@ nsresult nsExternalHelperAppService::DoC
   }
 
   nsCString disp;
   nsCOMPtr<nsIURI> uri;
   int64_t contentLength = -1;
   bool wasFileChannel = false;
   uint32_t contentDisposition = -1;
   nsAutoString fileName;
+  nsCOMPtr<nsILoadInfo> loadInfo;
 
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
   if (channel) {
     channel->GetURI(getter_AddRefs(uri));
     channel->GetContentLength(&contentLength);
     channel->GetContentDisposition(&contentDisposition);
     channel->GetContentDispositionFilename(fileName);
     channel->GetContentDispositionHeader(disp);
+    loadInfo = channel->GetLoadInfo();
 
     nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(aRequest));
     wasFileChannel = fileChan != nullptr;
   }
 
   nsCOMPtr<nsIURI> referrer;
   NS_GetReferrerFromChannel(channel, getter_AddRefs(referrer));
 
   OptionalURIParams uriParams, referrerParams;
   SerializeURI(uri, uriParams);
   SerializeURI(referrer, referrerParams);
 
+  mozilla::net::OptionalLoadInfoArgs loadInfoArgs;
+  MOZ_ALWAYS_SUCCEEDS(LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs));
+
   // Now we build a protocol for forwarding our data to the parent.  The
   // protocol will act as a listener on the child-side and create a "real"
   // helperAppService listener on the parent-side, via another call to
   // DoContent.
   mozilla::dom::PExternalHelperAppChild* pc =
       child->SendPExternalHelperAppConstructor(
-          uriParams, nsCString(aMimeContentType), disp, contentDisposition,
-          fileName, aForceSave, contentLength, wasFileChannel, referrerParams,
+          uriParams, loadInfoArgs, nsCString(aMimeContentType), disp,
+          contentDisposition, fileName, aForceSave, contentLength,
+          wasFileChannel, referrerParams,
           mozilla::dom::TabChild::GetFrom(window));
   ExternalHelperAppChild* childListener =
       static_cast<ExternalHelperAppChild*>(pc);
 
   NS_ADDREF(*aStreamListener = childListener);
 
   uint32_t reason = nsIHelperAppLauncherDialog::REASON_CANTHANDLE;