Bug 1590898 - Forward stream filter creation requests across PDocumentChannel. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D50898

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-11-03 22:15:48 +00:00
Родитель 4eba7bb5e1
Коммит 8ad1e883c8
5 изменённых файлов: 57 добавлений и 13 удалений

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

@ -23,6 +23,8 @@
#include "nsSerializationHelper.h"
#include "nsStringStream.h"
#include "mozilla/dom/nsCSPContext.h"
#include "nsStreamListenerWrapper.h"
#include "mozilla/extensions/StreamFilterParent.h"
using namespace mozilla::dom;
using namespace mozilla::ipc;
@ -42,6 +44,7 @@ NS_INTERFACE_MAP_BEGIN(DocumentChannelChild)
"likely broken");
}
NS_INTERFACE_MAP_ENTRY(nsIClassifiedChannel)
NS_INTERFACE_MAP_ENTRY(nsITraceableChannel)
NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentChannelChild)
NS_INTERFACE_MAP_END_INHERITING(nsBaseChannel)
@ -497,6 +500,28 @@ IPCResult DocumentChannelChild::RecvSetClassifierMatchedTrackingInfo(
return IPC_OK();
}
mozilla::ipc::IPCResult DocumentChannelChild::RecvAttachStreamFilter(
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
return IPC_OK();
}
//-----------------------------------------------------------------------------
// DocumentChannelChild::nsITraceableChannel
//-----------------------------------------------------------------------------
NS_IMETHODIMP
DocumentChannelChild::SetNewListener(nsIStreamListener* aListener,
nsIStreamListener** _retval) {
NS_ENSURE_ARG_POINTER(aListener);
nsCOMPtr<nsIStreamListener> wrapper = new nsStreamListenerWrapper(mListener);
wrapper.forget(_retval);
mListener = aListener;
return NS_OK;
}
//-----------------------------------------------------------------------------
// DocumentChannelChild::nsIClassifiedChannel

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

@ -13,6 +13,7 @@
#include "nsBaseChannel.h"
#include "nsIChildChannel.h"
#include "nsIClassifiedChannel.h"
#include "nsITraceableChannel.h"
#define DOCUMENT_CHANNEL_CHILD_IID \
{ \
@ -26,7 +27,8 @@ namespace net {
class DocumentChannelChild final : public PDocumentChannelChild,
public nsBaseChannel,
public nsIClassifiedChannel {
public nsIClassifiedChannel,
public nsITraceableChannel {
public:
DocumentChannelChild(nsDocShellLoadState* aLoadState,
class LoadInfo* aLoadInfo,
@ -37,6 +39,7 @@ class DocumentChannelChild final : public PDocumentChannelChild,
NS_DECL_ISUPPORTS_INHERITED;
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
NS_DECL_NSICLASSIFIEDCHANNEL
NS_DECL_NSITRACEABLECHANNEL
NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_CHANNEL_CHILD_IID)
@ -69,6 +72,9 @@ class DocumentChannelChild final : public PDocumentChannelChild,
const Maybe<nsString>& aContentDispositionFilename,
RedirectToRealChannelResolver&& aResolve);
mozilla::ipc::IPCResult RecvAttachStreamFilter(
Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvNotifyClassificationFlags(
const uint32_t& aClassificationFlags, const bool& aIsThirdParty);
mozilla::ipc::IPCResult RecvNotifyChannelClassifierProtectionDisabled(

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

@ -58,6 +58,8 @@ isThirdParty);
async SetClassifierMatchedInfo(nsCString list, nsCString provider, nsCString fullHash);
async SetClassifierMatchedTrackingInfo(nsCString lists, nsCString fullHash);
async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
// This message is sent to a child that has been redirected to another process.
// As a consequence, it should cleanup the channel listeners and remove the

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

@ -6889,10 +6889,12 @@ nsHttpChannel::SetChannelIsForDownload(bool aChannelIsForDownload) {
base::ProcessId nsHttpChannel::ProcessId() {
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(this, parentChannel);
RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel);
if (httpParent) {
if (RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel)) {
return httpParent->OtherPid();
}
if (RefPtr<DocumentChannelParent> docParent = do_QueryObject(parentChannel)) {
return docParent->OtherPid();
}
return base::GetCurrentProcId();
}
@ -6902,10 +6904,12 @@ bool nsHttpChannel::AttachStreamFilter(
{
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(this, parentChannel);
RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel);
if (httpParent) {
if (RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel)) {
return httpParent->SendAttachStreamFilter(std::move(aEndpoint));
}
if (RefPtr<DocumentChannelParent> docParent = do_QueryObject(parentChannel)) {
return docParent->SendAttachStreamFilter(std::move(aEndpoint));
}
extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
return true;

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

@ -19,6 +19,7 @@
#include "nsQueryObject.h"
#include "nsSocketTransportService2.h"
#include "nsStringStream.h"
#include "mozilla/net/DocumentChannelChild.h"
namespace mozilla {
namespace extensions {
@ -455,15 +456,21 @@ StreamFilterParent::OnStartRequest(nsIRequest* aRequest) {
AssertIsMainThread();
if (aRequest != mChannel) {
mDisconnected = true;
RefPtr<net::DocumentChannelChild> docChild = do_QueryObject(mChannel);
if (docChild && docChild->GetRedirectChain().IsEmpty()) {
mChannel = do_QueryInterface(aRequest);
} else {
mDisconnected = true;
RefPtr<StreamFilterParent> self(this);
RunOnActorThread(FUNC, [=] {
if (self->IPCActive()) {
self->mState = State::Disconnected;
CheckResult(self->SendError(NS_LITERAL_CSTRING("Channel redirected")));
}
});
RefPtr<StreamFilterParent> self(this);
RunOnActorThread(FUNC, [=] {
if (self->IPCActive()) {
self->mState = State::Disconnected;
CheckResult(
self->SendError(NS_LITERAL_CSTRING("Channel redirected")));
}
});
}
}
if (!mDisconnected) {