Bug 1376496 - Part 5 - Don't send child nsILoadInfo's to the parent for requests. r=ckerschb

MozReview-Commit-ID: G8fCPL7aLT0

--HG--
extra : rebase_source : 3c49008eaedf65befffc2f0327529817d9879cd5
This commit is contained in:
Haik Aftandilian 2017-07-20 11:49:29 -07:00
Родитель 546c76f86e
Коммит 9ab2f249f0
5 изменённых файлов: 16 добавлений и 46 удалений

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

@ -962,7 +962,6 @@ NeckoParent::RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWind
mozilla::ipc::IPCResult
NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
const LoadInfoArgs& aLoadInfo,
GetExtensionStreamResolver&& aResolve)
{
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
@ -970,13 +969,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
return IPC_FAIL_NO_REASON(this);
}
nsCOMPtr<nsILoadInfo> deserializedLoadInfo;
nsresult rv;
rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo));
if (NS_FAILED(rv)) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
MOZ_ASSERT(ph);
@ -991,9 +983,7 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
AutoIPCStream autoStream;
nsCOMPtr<nsIInputStream> inputStream;
bool terminateSender = true;
auto inputStreamOrReason = ph->NewStream(deserializedURI,
deserializedLoadInfo,
&terminateSender);
auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender);
if (inputStreamOrReason.isOk()) {
inputStream = inputStreamOrReason.unwrap();
ContentParent* contentParent = static_cast<ContentParent*>(Manager());
@ -1014,7 +1004,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
mozilla::ipc::IPCResult
NeckoParent::RecvGetExtensionFD(const URIParams& aURI,
const OptionalLoadInfoArgs& aLoadInfo,
GetExtensionFDResolver&& aResolve)
{
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
@ -1022,13 +1011,6 @@ NeckoParent::RecvGetExtensionFD(const URIParams& aURI,
return IPC_FAIL_NO_REASON(this);
}
nsCOMPtr<nsILoadInfo> deserializedLoadInfo;
nsresult rv;
rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo));
if (NS_FAILED(rv)) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
MOZ_ASSERT(ph);
@ -1041,8 +1023,7 @@ NeckoParent::RecvGetExtensionFD(const URIParams& aURI,
// an extension is allowed to access via moz-extension URI's should be
// accepted.
bool terminateSender = true;
auto result = ph->NewFD(deserializedURI, deserializedLoadInfo,
&terminateSender, aResolve);
auto result = ph->NewFD(deserializedURI, &terminateSender, aResolve);
if (result.isErr() && terminateSender) {
return IPC_FAIL_NO_REASON(this);

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

@ -240,12 +240,10 @@ protected:
/* WebExtensions */
virtual mozilla::ipc::IPCResult
RecvGetExtensionStream(const URIParams& aURI,
const LoadInfoArgs& aLoadInfo,
GetExtensionStreamResolver&& aResolve) override;
virtual mozilla::ipc::IPCResult
RecvGetExtensionFD(const URIParams& aURI,
const OptionalLoadInfoArgs& aLoadInfo,
GetExtensionFDResolver&& aResolve) override;
};

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

@ -131,10 +131,8 @@ parent:
/**
* WebExtension-specific remote resource loading
*/
async GetExtensionStream(URIParams uri, LoadInfoArgs loadInfo) returns
(OptionalIPCStream stream);
async GetExtensionFD(URIParams uri, OptionalLoadInfoArgs loadInfo) returns
(FileDescriptor fd);
async GetExtensionStream(URIParams uri) returns (OptionalIPCStream stream);
async GetExtensionFD(URIParams uri) returns (FileDescriptor fd);
child:
/*

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

@ -20,6 +20,7 @@
#include "LoadInfo.h"
#include "nsContentUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsContentUtils.h"
#include "nsIFile.h"
#include "nsIFileChannel.h"
#include "nsIFileStreams.h"
@ -253,14 +254,10 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener,
mozilla::ipc::URIParams uri;
SerializeURI(mURI, uri);
// Serialize the LoadInfo to send to parent
OptionalLoadInfoArgs loadInfo;
NS_TRY(mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfo));
RefPtr<ExtensionStreamGetter> self = this;
if (mIsJarChannel) {
// Request an FD for this moz-extension URI
gNeckoChild->SendGetExtensionFD(uri, loadInfo)->Then(
gNeckoChild->SendGetExtensionFD(uri)->Then(
mMainThreadEventTarget,
__func__,
[self] (const FileDescriptor& fd) {
@ -274,7 +271,7 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener,
}
// Request an input stream for this moz-extension URI
gNeckoChild->SendGetExtensionStream(uri, loadInfo)->Then(
gNeckoChild->SendGetExtensionStream(uri)->Then(
mMainThreadEventTarget,
__func__,
[self] (const OptionalIPCStream& stream) {
@ -555,13 +552,10 @@ ExtensionProtocolHandler::DevRepoContains(nsIFile* aRequestedFile,
#endif /* !defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) */
Result<nsCOMPtr<nsIInputStream>, nsresult>
ExtensionProtocolHandler::NewStream(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender)
ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, bool* aTerminateSender)
{
MOZ_ASSERT(!IsNeckoChild());
NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG);
NS_TRY(aChildLoadInfo ? NS_OK : NS_ERROR_INVALID_ARG);
NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG);
*aTerminateSender = true;
@ -614,10 +608,15 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI,
* channel is a file channel.
*/
// We use the system principal to get a file channel for the request,
// but only after we've checked (above) that the child URI is of
// moz-extension scheme and that the URI host maps to a directory.
nsCOMPtr<nsIChannel> channel;
NS_TRY(NS_NewChannelInternal(getter_AddRefs(channel),
NS_TRY(NS_NewChannel(getter_AddRefs(channel),
aChildURI,
aChildLoadInfo));
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER));
// Channel should be a file channel. It should never be a JAR
// channel because we only request remote streams for unpacked
@ -671,13 +670,11 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI,
Result<Ok, nsresult>
ExtensionProtocolHandler::NewFD(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender,
NeckoParent::GetExtensionFDResolver& aResolve)
{
MOZ_ASSERT(!IsNeckoChild());
NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG);
NS_TRY(aChildLoadInfo ? NS_OK : NS_ERROR_INVALID_ARG);
NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG);
*aTerminateSender = true;

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

@ -32,7 +32,6 @@ public:
*
* @param aChildURI a moz-extension URI sent from the child that refers
* to a web accessible resource file in an enabled unpacked extension
* @param aChildLoadInfo the loadinfo for the request sent from the child
* @param aTerminateSender out param set to true when the params are invalid
* and indicate the child should be terminated. If |aChildURI| is
* not a moz-extension URI, the child is in an invalid state and
@ -46,7 +45,6 @@ public:
* set to true.
*/
Result<nsCOMPtr<nsIInputStream>, nsresult> NewStream(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender);
/**
@ -55,7 +53,6 @@ public:
*
* @param aChildURI a moz-extension URI sent from the child that refers
* to a web accessible resource file in an enabled unpacked extension
* @param aChildLoadInfo the loadinfo for the request sent from the child
* @param aTerminateSender out param set to true when the params are invalid
* and indicate the child should be terminated. If |aChildURI| is
* not a moz-extension URI, the child is in an invalid state and
@ -71,7 +68,6 @@ public:
* set to true.
*/
Result<Ok, nsresult> NewFD(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender,
NeckoParent::GetExtensionFDResolver& aResolve);