Bug 1528814: Serialize Loadinfo for PExternalHelperApp. r=mayhemer

This commit is contained in:
Christoph Kerschbaumer 2019-02-18 18:11:22 +01:00
Родитель 643fbfc678
Коммит 05ad5a1c28
8 изменённых файлов: 39 добавлений и 20 удалений

Просмотреть файл

@ -1969,8 +1969,9 @@ bool ContentChild::DeallocPPSMContentDownloaderChild(
}
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,

Просмотреть файл

@ -281,8 +281,9 @@ class ContentChild final : public PContentChild,
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,

Просмотреть файл

@ -3596,14 +3596,15 @@ bool ContentParent::DeallocPPSMContentDownloaderParent(
}
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);

Просмотреть файл

@ -11,6 +11,7 @@
#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"
@ -897,8 +898,9 @@ class ContentParent final : public PContentParent,
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,

Просмотреть файл

@ -894,6 +894,7 @@ parent:
async PPSMContentDownloader(uint32_t aCertType);
async PExternalHelperApp(OptionalURIParams uri,
OptionalLoadInfoArgs loadInfoArgs,
nsCString aMimeContentType,
nsCString aContentDisposition,
uint32_t aContentDispositionHint,

Просмотреть файл

@ -33,8 +33,10 @@ NS_IMPL_ISUPPORTS_INHERITED(ExternalHelperAppParent, nsHashPropertyBag,
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)),
@ -59,6 +61,8 @@ ExternalHelperAppParent::ExternalHelperAppParent(
mContentDisposition = aContentDispositionHint;
mContentDispositionFilename = aContentDispositionFilename;
}
mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
getter_AddRefs(mLoadInfo));
}
already_AddRefed<nsIInterfaceRequestor> GetWindowFromTabParent(
@ -322,7 +326,7 @@ ExternalHelperAppParent::SetOwner(nsISupports* aOwner) {
NS_IMETHODIMP
ExternalHelperAppParent::GetLoadInfo(nsILoadInfo** aLoadInfo) {
*aLoadInfo = nullptr;
NS_IF_ADDREF(*aLoadInfo = mLoadInfo);
return NS_OK;
}

Просмотреть файл

@ -5,6 +5,7 @@
* 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"
@ -83,9 +84,10 @@ class ExternalHelperAppParent
bool WasFileChannel() override { return mWasFileChannel; }
ExternalHelperAppParent(const OptionalURIParams& uri,
const int64_t& contentLength,
const bool& wasFileChannel,
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);
@ -102,6 +104,7 @@ class ExternalHelperAppParent
private:
nsCOMPtr<nsIStreamListener> mListener;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsILoadInfo> mLoadInfo;
bool mPending;
#ifdef DEBUG
bool mDiverted;

Просмотреть файл

@ -616,6 +616,7 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper(
bool wasFileChannel = false;
uint32_t contentDisposition = -1;
nsAutoString fileName;
nsCOMPtr<nsILoadInfo> loadInfo;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
@ -624,6 +625,7 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper(
channel->GetContentDisposition(&contentDisposition);
channel->GetContentDispositionFilename(fileName);
channel->GetContentDispositionHeader(disp);
loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(aRequest));
wasFileChannel = fileChan != nullptr;
@ -636,14 +638,18 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper(
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);