Backed out 3 changesets (bug 1597159) for build bustages on netwerk/ipc/target-objects. CLOSED TREE

Backed out changeset 2dd2598b3edb (bug 1597159)
Backed out changeset 0ad16f200740 (bug 1597159)
Backed out changeset 927e82a323c6 (bug 1597159)
This commit is contained in:
Brindusan Cristian 2020-04-09 07:12:47 +03:00
Родитель a6d592bbe2
Коммит 21cc9ecac2
24 изменённых файлов: 105 добавлений и 375 удалений

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

@ -15,8 +15,7 @@ void ChildProcessChannelListener::RegisterCallback(uint64_t aIdentifier,
Callback&& aCallback) {
if (auto args = mChannelArgs.GetAndRemove(aIdentifier)) {
nsresult rv =
aCallback(args->mLoadState, std::move(args->mRedirects),
std::move(args->mStreamFilterEndpoints), args->mTiming);
aCallback(args->mLoadState, std::move(args->mRedirects), args->mTiming);
args->mResolver(rv);
} else {
mCallbacks.Put(aIdentifier, std::move(aCallback));
@ -26,15 +25,12 @@ void ChildProcessChannelListener::RegisterCallback(uint64_t aIdentifier,
void ChildProcessChannelListener::OnChannelReady(
nsDocShellLoadState* aLoadState, uint64_t aIdentifier,
nsTArray<net::DocumentChannelRedirect>&& aRedirects,
nsTArray<Endpoint>&& aStreamFilterEndpoints, nsDOMNavigationTiming* aTiming,
Resolver&& aResolver) {
nsDOMNavigationTiming* aTiming, Resolver&& aResolver) {
if (auto callback = mCallbacks.GetAndRemove(aIdentifier)) {
nsresult rv = (*callback)(aLoadState, std::move(aRedirects),
std::move(aStreamFilterEndpoints), aTiming);
nsresult rv = (*callback)(aLoadState, std::move(aRedirects), aTiming);
aResolver(rv);
} else {
mChannelArgs.Put(aIdentifier, {aLoadState, std::move(aRedirects),
std::move(aStreamFilterEndpoints), aTiming,
mChannelArgs.Put(aIdentifier, {aLoadState, std::move(aRedirects), aTiming,
std::move(aResolver)});
}
}

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

@ -9,7 +9,6 @@
#include <functional>
#include "mozilla/extensions/StreamFilterParent.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "nsDOMNavigationTiming.h"
#include "nsDataHashtable.h"
@ -22,17 +21,15 @@ namespace dom {
class ChildProcessChannelListener final {
NS_INLINE_DECL_REFCOUNTING(ChildProcessChannelListener)
using Endpoint = mozilla::ipc::Endpoint<extensions::PStreamFilterParent>;
using Resolver = std::function<void(const nsresult&)>;
using Callback = std::function<nsresult(
nsDocShellLoadState*, nsTArray<net::DocumentChannelRedirect>&&,
nsTArray<Endpoint>&&, nsDOMNavigationTiming*)>;
nsDOMNavigationTiming*)>;
void RegisterCallback(uint64_t aIdentifier, Callback&& aCallback);
void OnChannelReady(nsDocShellLoadState* aLoadState, uint64_t aIdentifier,
nsTArray<net::DocumentChannelRedirect>&& aRedirects,
nsTArray<Endpoint>&& aStreamFilterEndpoints,
nsDOMNavigationTiming* aTiming, Resolver&& aResolver);
static already_AddRefed<ChildProcessChannelListener> GetSingleton();
@ -43,7 +40,6 @@ class ChildProcessChannelListener final {
struct CallbackArgs {
RefPtr<nsDocShellLoadState> mLoadState;
nsTArray<net::DocumentChannelRedirect> mRedirects;
nsTArray<Endpoint> mStreamFilterEndpoints;
RefPtr<nsDOMNavigationTiming> mTiming;
Resolver mResolver;
};

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

@ -12520,12 +12520,10 @@ nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
// Call into InternalLoad with the pending channel when it is received.
cpcl->RegisterCallback(
aIdentifier, [self, aHistoryIndex](
nsDocShellLoadState* aLoadState,
nsTArray<net::DocumentChannelRedirect>&& aRedirects,
nsTArray<Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
nsDOMNavigationTiming* aTiming) {
aIdentifier,
[self, aHistoryIndex](nsDocShellLoadState* aLoadState,
nsTArray<net::DocumentChannelRedirect>&& aRedirects,
nsDOMNavigationTiming* aTiming) {
MOZ_ASSERT(aLoadState->GetPendingRedirectedChannel());
if (NS_WARN_IF(self->mIsBeingDestroyed)) {
aLoadState->GetPendingRedirectedChannel()->Cancel(NS_BINDING_ABORTED);
@ -12565,11 +12563,6 @@ nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
self->InternalLoad(aLoadState, nullptr, nullptr);
for (auto& endpoint : aStreamFilterEndpoints) {
extensions::StreamFilterParent::Attach(
aLoadState->GetPendingRedirectedChannel(), std::move(endpoint));
}
// If the channel isn't pending, then it means that InternalLoad
// never connected it, and we shouldn't try to continue. This
// can happen even if InternalLoad returned NS_OK.

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

@ -64,7 +64,6 @@
#include "mozilla/dom/WorkerDebugger.h"
#include "mozilla/dom/WorkerDebuggerManager.h"
#include "mozilla/dom/ipc/SharedMap.h"
#include "mozilla/extensions/StreamFilterParent.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/hal_sandbox/PHalChild.h"
@ -3429,7 +3428,6 @@ mozilla::ipc::IPCResult ContentChild::RecvAddDynamicScalars(
mozilla::ipc::IPCResult ContentChild::RecvCrossProcessRedirect(
RedirectToRealChannelArgs&& aArgs,
nsTArray<Endpoint<extensions::PStreamFilterParent>>&& aEndpoints,
CrossProcessRedirectResolver&& aResolve) {
nsCOMPtr<nsILoadInfo> loadInfo;
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(aArgs.loadInfo(),
@ -3523,7 +3521,7 @@ mozilla::ipc::IPCResult ContentChild::RecvCrossProcessRedirect(
// The listener will call completeRedirectSetup or asyncOpen on the channel.
processListener->OnChannelReady(
loadState, aArgs.redirectIdentifier(), std::move(aArgs.redirects()),
std::move(aEndpoints), aArgs.timing().refOr(nullptr), std::move(resolve));
aArgs.timing().refOr(nullptr), std::move(resolve));
scopeExit.release();
// scopeExit will call CrossProcessRedirectFinished(rv) here

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

@ -644,7 +644,6 @@ class ContentChild final
mozilla::ipc::IPCResult RecvCrossProcessRedirect(
RedirectToRealChannelArgs&& aArgs,
nsTArray<Endpoint<extensions::PStreamFilterParent>>&& aEndpoints,
CrossProcessRedirectResolver&& aResolve);
mozilla::ipc::IPCResult RecvStartDelayedAutoplayMediaComponents(

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

@ -3600,15 +3600,11 @@ already_AddRefed<embedding::PrintingParent> ContentParent::GetPrintingParent() {
mozilla::ipc::IPCResult ContentParent::RecvInitStreamFilter(
const uint64_t& aChannelId, const nsString& aAddonId,
InitStreamFilterResolver&& aResolver) {
extensions::StreamFilterParent::Create(this, aChannelId, aAddonId)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[aResolver](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
aResolver(std::move(aEndpoint));
},
[aResolver](bool aDummy) {
aResolver(mozilla::ipc::Endpoint<PStreamFilterChild>());
});
Endpoint<PStreamFilterChild> endpoint;
Unused << extensions::StreamFilterParent::Create(this, aChannelId, aAddonId,
&endpoint);
aResolver(std::move(endpoint));
return IPC_OK();
}

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

@ -818,8 +818,7 @@ child:
// The returned loadInfo needs to be set on the channel - since the channel
// moved to a new process it now has different properties.
async CrossProcessRedirect(RedirectToRealChannelArgs args,
Endpoint<PStreamFilterParent>[] aEndpoint)
async CrossProcessRedirect(RedirectToRealChannelArgs args)
returns (nsresult rv);
/**

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

@ -53,14 +53,15 @@ class ADocumentChannelBridge {
// Initate a switch from the DocumentChannel to the protocol-specific
// real channel.
virtual RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
RedirectToRealChannel(
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
uint32_t aRedirectFlags, uint32_t aLoadFlags) = 0;
RedirectToRealChannel(uint32_t aRedirectFlags, uint32_t aLoadFlags) = 0;
// Returns the process id that this bridge is connected to.
virtual base::ProcessId OtherPid() const = 0;
// Attach a StreamFilterParent to the remote-side nsIChannel of this bridge.
virtual bool AttachStreamFilter(
ipc::Endpoint<mozilla::extensions::PStreamFilterParent>&& aEndpoint) = 0;
protected:
virtual ~ADocumentChannelBridge() = default;
};

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

@ -183,7 +183,6 @@ IPCResult DocumentChannelChild::RecvDeleteSelf() {
IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
RedirectToRealChannelArgs&& aArgs,
nsTArray<Endpoint<extensions::PStreamFilterParent>>&& aEndpoints,
RedirectToRealChannelResolver&& aResolve) {
LOG(("DocumentChannelChild RecvRedirectToRealChannel [this=%p, uri=%s]", this,
aArgs.uri()->GetSpecOrDefault().get()));
@ -291,7 +290,6 @@ IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
}
}
mRedirectChannel = newChannel;
mStreamFilterEndpoints = std::move(aEndpoints);
rv = gHttpHandler->AsyncOnChannelRedirect(
this, newChannel, aArgs.redirectFlags(), GetMainThreadEventTarget());
@ -333,11 +331,6 @@ DocumentChannelChild::OnRedirectVerifyCallback(nsresult aStatusCode) {
redirectChannel->SetNotificationCallbacks(nullptr);
}
for (auto& endpoint : mStreamFilterEndpoints) {
extensions::StreamFilterParent::Attach(redirectChannel,
std::move(endpoint));
}
redirectResolver(rv);
if (NS_FAILED(rv)) {
@ -413,6 +406,12 @@ mozilla::ipc::IPCResult DocumentChannelChild::RecvCSPViolation(
return IPC_OK();
}
mozilla::ipc::IPCResult DocumentChannelChild::RecvAttachStreamFilter(
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
return IPC_OK();
}
NS_IMETHODIMP
DocumentChannelChild::Cancel(nsresult aStatusCode) {
if (mCanceled) {

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

@ -44,9 +44,11 @@ class DocumentChannelChild final : public DocumentChannel,
mozilla::ipc::IPCResult RecvRedirectToRealChannel(
RedirectToRealChannelArgs&& aArgs,
nsTArray<Endpoint<extensions::PStreamFilterParent>>&& aEndpoints,
RedirectToRealChannelResolver&& aResolve);
mozilla::ipc::IPCResult RecvAttachStreamFilter(
Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvCSPViolation(
const CSPInfo& aCSP, bool aIsCspToInherit, nsIURI* aBlockedURI,
uint32_t aBlockedContentSource, nsIURI* aOriginalURI,
@ -61,7 +63,6 @@ class DocumentChannelChild final : public DocumentChannel,
nsCOMPtr<nsIChannel> mRedirectChannel;
RedirectToRealChannelResolver mRedirectResolver;
nsTArray<Endpoint<extensions::PStreamFilterParent>> mStreamFilterEndpoints;
};
} // namespace net

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

@ -62,17 +62,15 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {
}
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
DocumentChannelParent::RedirectToRealChannel(
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
uint32_t aRedirectFlags, uint32_t aLoadFlags) {
DocumentChannelParent::RedirectToRealChannel(uint32_t aRedirectFlags,
uint32_t aLoadFlags) {
if (!CanSend()) {
return PDocumentChannelParent::RedirectToRealChannelPromise::
CreateAndReject(ResponseRejectReason::ChannelClosed, __func__);
}
RedirectToRealChannelArgs args;
mParent->SerializeRedirectData(args, false, aRedirectFlags, aLoadFlags);
return SendRedirectToRealChannel(args, std::move(aStreamFilterEndpoints));
return SendRedirectToRealChannel(args);
}
void DocumentChannelParent::CSPViolation(

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

@ -70,11 +70,13 @@ class DocumentChannelParent final : public ADocumentChannelBridge,
virtual ProcessId OtherPid() const override { return IProtocol::OtherPid(); }
virtual bool AttachStreamFilter(
Endpoint<mozilla::extensions::PStreamFilterParent>&& aEndpoint) override {
return SendAttachStreamFilter(std::move(aEndpoint));
}
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
RedirectToRealChannel(
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
uint32_t aRedirectFlags, uint32_t aLoadFlags) override;
RedirectToRealChannel(uint32_t aRedirectFlags, uint32_t aLoadFlags) override;
~DocumentChannelParent();

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

@ -491,13 +491,6 @@ void DocumentLoadListener::DisconnectChildListeners(nsresult aStatus,
mDocumentChannelBridge->DisconnectChildListeners(aStatus, aLoadGroupStatus);
}
DocumentChannelBridgeDisconnected();
// If we're not going to send anything else to the content process, and
// we haven't yet consumed a stream filter promise, then we're never going
// to.
// TODO: This might be because we retargeted the stream to the download
// handler or similar. Do we need to attach a stream filter to that?
mStreamFilterRequests.Clear();
}
void DocumentLoadListener::RedirectToRealChannelFinished(nsresult aRv) {
@ -858,10 +851,8 @@ void DocumentLoadListener::TriggerCrossProcessSwitch() {
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
DocumentLoadListener::RedirectToRealChannel(
uint32_t aRedirectFlags, uint32_t aLoadFlags,
const Maybe<uint64_t>& aDestinationProcess,
nsTArray<ParentEndpoint>&& aStreamFilterEndpoints) {
const Maybe<uint64_t>& aDestinationProcess) {
LOG(("DocumentLoadListener RedirectToRealChannel [this=%p]", this));
if (aDestinationProcess) {
dom::ContentParent* cp =
dom::ContentProcessManager::GetSingleton()->GetContentProcessById(
@ -879,12 +870,11 @@ DocumentLoadListener::RedirectToRealChannel(
args.timing() = Some(std::move(mTiming));
}
return cp->SendCrossProcessRedirect(args,
std::move(aStreamFilterEndpoints));
return cp->SendCrossProcessRedirect(args);
}
MOZ_ASSERT(mDocumentChannelBridge);
return mDocumentChannelBridge->RedirectToRealChannel(
std::move(aStreamFilterEndpoints), aRedirectFlags, aLoadFlags);
return mDocumentChannelBridge->RedirectToRealChannel(aRedirectFlags,
aLoadFlags);
}
void DocumentLoadListener::TriggerRedirectToRealChannel(
@ -900,32 +890,6 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
// the registrar and copy across any needed state to the replacing
// IPDL parent object.
nsTArray<ParentEndpoint> parentEndpoints(mStreamFilterRequests.Length());
if (!mStreamFilterRequests.IsEmpty()) {
base::ProcessId pid = OtherPid();
if (aDestinationProcess) {
dom::ContentParent* cp =
dom::ContentProcessManager::GetSingleton()->GetContentProcessById(
ContentParentId(*aDestinationProcess));
if (cp) {
pid = cp->OtherPid();
}
}
for (StreamFilterRequest& request : mStreamFilterRequests) {
ParentEndpoint parent;
nsresult rv = extensions::PStreamFilter::CreateEndpoints(
pid, request.mChildProcessId, &parent, &request.mChildEndpoint);
if (NS_FAILED(rv)) {
request.mPromise->Reject(false, __func__);
request.mPromise = nullptr;
} else {
parentEndpoints.AppendElement(std::move(parent));
}
}
}
// If we didn't have any redirects, then we pass the REDIRECT_INTERNAL flag
// for this channel switch so that it isn't recorded in session history etc.
// If there were redirect(s), then we want this switch to be recorded as a
@ -942,19 +906,10 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
}
RefPtr<DocumentLoadListener> self = this;
RedirectToRealChannel(redirectFlags, newLoadFlags, aDestinationProcess,
std::move(parentEndpoints))
RedirectToRealChannel(redirectFlags, newLoadFlags, aDestinationProcess)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[self, requests = std::move(mStreamFilterRequests)](
const nsresult& aResponse) mutable {
for (StreamFilterRequest& request : requests) {
if (request.mPromise) {
request.mPromise->Resolve(std::move(request.mChildEndpoint),
__func__);
request.mPromise = nullptr;
}
}
[self](const nsresult& aResponse) {
self->RedirectToRealChannelFinished(aResponse);
},
[self](const mozilla::ipc::ResponseRejectReason) {
@ -1063,9 +1018,6 @@ DocumentLoadListener::OnStopRequest(nsIRequest* aRequest,
if (!multiPartChannel) {
mIsFinished = true;
}
mStreamFilterRequests.Clear();
return NS_OK;
}
@ -1357,16 +1309,6 @@ DocumentLoadListener::GetCachedCrossOriginOpenerPolicy(
return httpChannel->GetCrossOriginOpenerPolicy(aPolicy);
}
auto DocumentLoadListener::AttachStreamFilter(base::ProcessId aChildProcessId)
-> RefPtr<ChildEndpointPromise> {
LOG(("DocumentLoadListener AttachStreamFilter [this=%p]", this));
StreamFilterRequest* request = mStreamFilterRequests.AppendElement();
request->mPromise = new ChildEndpointPromise::Private(__func__);
request->mChildProcessId = aChildProcessId;
return request->mPromise;
}
} // namespace net
} // namespace mozilla

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

@ -141,12 +141,13 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
return 0;
}
using ChildEndpointPromise =
MozPromise<ipc::Endpoint<extensions::PStreamFilterChild>, bool, true>;
MOZ_MUST_USE RefPtr<ChildEndpointPromise> AttachStreamFilter(
base::ProcessId aChildProcessId);
using ParentEndpoint = ipc::Endpoint<extensions::PStreamFilterParent>;
bool AttachStreamFilter(
ipc::Endpoint<mozilla::extensions::PStreamFilterParent>&& aEndpoint) {
if (mDocumentChannelBridge) {
return mDocumentChannelBridge->AttachStreamFilter(std::move(aEndpoint));
}
return false;
}
// Serializes all data needed to setup the new replacement channel
// in the content process into the RedirectToRealChannelArgs struct.
@ -184,8 +185,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// a single promise to wait on.
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
RedirectToRealChannel(uint32_t aRedirectFlags, uint32_t aLoadFlags,
const Maybe<uint64_t>& aDestinationProcess,
nsTArray<ParentEndpoint>&& aStreamFilterEndpoints);
const Maybe<uint64_t>& aDestinationProcess);
// Construct a LoadInfo object to use for the internal channel.
// TODO: This currently only supports creating top window TYPE_DOCUMENT
@ -314,25 +314,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
nsTArray<DocumentChannelRedirect> mRedirects;
// If we've been asked to attach a stream filter to our channel,
// then we return this promise and defer until we know the final
// content process. At that point we setup Endpoints between
// mStramFilterProcessId and the new content process, and send
// the parent Endpoint to the new process.
// Once we have confirmation of that being bound in the content
// process, we resolve the promise the child Endpoint.
struct StreamFilterRequest {
~StreamFilterRequest() {
if (mPromise) {
mPromise->Reject(false, __func__);
}
}
RefPtr<ChildEndpointPromise::Private> mPromise;
base::ProcessId mChildProcessId;
mozilla::ipc::Endpoint<extensions::PStreamFilterChild> mChildEndpoint;
};
nsTArray<StreamFilterRequest> mStreamFilterRequests;
nsString mSrcdocData;
nsCOMPtr<nsIURI> mBaseURI;

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

@ -38,6 +38,8 @@ child:
// AsyncOpen of nsHttpChannel on the parent.
async FailedAsyncOpen(nsresult status);
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
// request from the loadGroup.
@ -50,7 +52,7 @@ child:
// Triggers replacing this DocumentChannel with a 'real' channel (like PHttpChannel),
// and notifies the listener via a redirect to the new channel.
async RedirectToRealChannel(RedirectToRealChannelArgs args, Endpoint<PStreamFilterParent>[] aEndpoint)
async RedirectToRealChannel(RedirectToRealChannelArgs args)
returns (nsresult rv);
async CSPViolation(CSPInfo aCSP, bool aIsCspToInherit,

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

@ -7022,32 +7022,21 @@ base::ProcessId nsHttpChannel::ProcessId() {
return base::GetCurrentProcId();
}
auto nsHttpChannel::AttachStreamFilter(base::ProcessId aChildProcessId)
-> RefPtr<ChildEndpointPromise> {
bool nsHttpChannel::AttachStreamFilter(
mozilla::ipc::Endpoint<extensions::PStreamFilterParent>&& aEndpoint)
{
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(this, parentChannel);
if (RefPtr<DocumentLoadListener> docParent = do_QueryObject(parentChannel)) {
return docParent->AttachStreamFilter(aChildProcessId);
}
mozilla::ipc::Endpoint<extensions::PStreamFilterParent> parent;
mozilla::ipc::Endpoint<extensions::PStreamFilterChild> child;
nsresult rv = extensions::PStreamFilter::CreateEndpoints(
ProcessId(), aChildProcessId, &parent, &child);
if (NS_FAILED(rv)) {
return ChildEndpointPromise::CreateAndReject(false, __func__);
}
if (RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel)) {
if (httpParent->SendAttachStreamFilter(std::move(parent))) {
return ChildEndpointPromise::CreateAndResolve(std::move(child), __func__);
}
return ChildEndpointPromise::CreateAndReject(false, __func__);
return httpParent->SendAttachStreamFilter(std::move(aEndpoint));
}
if (RefPtr<DocumentLoadListener> docParent = do_QueryObject(parentChannel)) {
return docParent->AttachStreamFilter(std::move(aEndpoint));
}
extensions::StreamFilterParent::Attach(this, std::move(parent));
return ChildEndpointPromise::CreateAndResolve(std::move(child), __func__);
extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
return true;
}
NS_IMETHODIMP

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

@ -264,10 +264,8 @@ class nsHttpChannel final : public HttpBaseChannel,
base::ProcessId ProcessId();
using ChildEndpointPromise =
MozPromise<ipc::Endpoint<extensions::PStreamFilterChild>, bool, true>;
MOZ_MUST_USE RefPtr<ChildEndpointPromise> AttachStreamFilter(
base::ProcessId aChildProcessId);
MOZ_MUST_USE bool AttachStreamFilter(
ipc::Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
private: // used for alternate service validation
RefPtr<TransactionObserver> mTransactionObserver;

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

@ -1 +0,0 @@
Middle

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

@ -23,7 +23,6 @@ support-files =
file_simple_xhr.html
file_simple_xhr_frame.html
file_simple_xhr_frame2.html
file_streamfilter.txt
file_style_bad.css
file_style_good.css
file_style_redirect.css
@ -124,8 +123,6 @@ skip-if = os == 'android' # Bug 1615427
[test_ext_sendmessage_reply2.html]
[test_ext_storage_manager_capabilities.html]
scheme=https
[test_ext_streamfilter_multiple.html]
[test_ext_streamfilter_processswitch.html]
[test_ext_subframes_privileges.html]
skip-if = os == 'android' || verify # bug 1489771
[test_ext_test.html]

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

@ -1,91 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test for multiple extensions trying to filterResponseData on the same request</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
const TEST_URL =
"http://example.org/tests/toolkit/components/extensions/test/mochitest/file_streamfilter.txt";
add_task(async () => {
const firstExtension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
},
background() {
browser.webRequest.onBeforeRequest.addListener(
({ requestId }) => {
const filter = browser.webRequest.filterResponseData(requestId);
filter.ondata = event => {
filter.write(new TextEncoder().encode("Start "));
filter.write(event.data);
filter.disconnect();
};
},
{
urls: [
"http://example.org/*/file_streamfilter.txt",
],
},
["blocking"]
);
},
});
const secondExtension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
},
background() {
browser.webRequest.onBeforeRequest.addListener(
({ requestId }) => {
const filter = browser.webRequest.filterResponseData(requestId);
filter.ondata = event => {
filter.write(event.data);
};
filter.onstop = event => {
filter.write(new TextEncoder().encode(" End"));
filter.close();
};
},
{
urls: [
"http://example.org/tests/toolkit/components/extensions/test/mochitest/file_streamfilter.txt",
],
},
["blocking"]
);
},
});
await firstExtension.startup();
await secondExtension.startup();
let iframe = document.createElement("iframe");
iframe.src = TEST_URL;
document.body.appendChild(iframe);
await new Promise(resolve => iframe.addEventListener("load", () => resolve(), {once: true}));
let content = await SpecialPowers.spawn(iframe, [], async () => {
return this.content.document.body.textContent;
});
SimpleTest.is(content, "Start Middle\n End", "Correctly intercepted page content");
await firstExtension.unload();
await secondExtension.unload();
});
</script>
</body>
</html>

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

@ -1,73 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test for using filterResponseData to intercept a cross-origin navigation that will involve a process switch with fission</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
const TEST_HOST = "http://example.com/";
const CROSS_ORIGIN_HOST = "http://example.org/";
const TEST_PATH =
"tests/toolkit/components/extensions/test/mochitest/file_streamfilter.txt";
const TEST_URL = TEST_HOST + TEST_PATH;
const CROSS_ORIGIN_URL = CROSS_ORIGIN_HOST + TEST_PATH;
add_task(async () => {
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
},
background() {
browser.webRequest.onBeforeRequest.addListener(
({ requestId }) => {
const filter = browser.webRequest.filterResponseData(requestId);
filter.ondata = event => {
filter.write(event.data);
};
filter.onstop = event => {
filter.write(new TextEncoder().encode(" End"));
filter.close();
};
},
{
urls: [
"http://example.org/*/file_streamfilter.txt",
],
},
["blocking"]
);
},
});
await extension.startup();
let iframe = document.createElement("iframe");
iframe.src = TEST_URL;
document.body.appendChild(iframe);
await new Promise(resolve => iframe.addEventListener("load", () => resolve(), {once: true}));
iframe.src = CROSS_ORIGIN_URL;
await new Promise(resolve => iframe.addEventListener("load", () => resolve(), {once: true}));
let content = await SpecialPowers.spawn(iframe, [], async () => {
return this.content.document.body.textContent;
});
SimpleTest.is(content, "Middle\n End", "Correctly intercepted page content");
await extension.unload();
});
</script>
</body>
</html>

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

@ -74,25 +74,29 @@ void StreamFilter::Connect() {
mAddonId->ToString(addonId);
ContentChild* cc = ContentChild::GetSingleton();
RefPtr<StreamFilter> self(this);
if (cc) {
RefPtr<StreamFilter> self(this);
cc->SendInitStreamFilter(mChannelId, addonId)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[self](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
[=](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
self->FinishConnect(std::move(aEndpoint));
},
[self](mozilla::ipc::ResponseRejectReason&& aReason) {
[=](mozilla::ipc::ResponseRejectReason&& aReason) {
self->mActor->RecvInitialized(false);
});
} else {
StreamFilterParent::Create(nullptr, mChannelId, addonId)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[self](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
self->FinishConnect(std::move(aEndpoint));
},
[self](bool aDummy) { self->mActor->RecvInitialized(false); });
mozilla::ipc::Endpoint<PStreamFilterChild> endpoint;
Unused << StreamFilterParent::Create(nullptr, mChannelId, addonId,
&endpoint);
// Always dispatch asynchronously so JS callers have a chance to attach
// event listeners before we dispatch events.
NS_DispatchToCurrentThread(
NewRunnableMethod<mozilla::ipc::Endpoint<PStreamFilterChild>&&>(
"StreamFilter::FinishConnect", this, &StreamFilter::FinishConnect,
std::move(endpoint)));
}
}

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

@ -108,9 +108,9 @@ StreamFilterParent::~StreamFilterParent() {
NS_ReleaseOnMainThread("StreamFilterParent::mContext", mContext.forget());
}
auto StreamFilterParent::Create(dom::ContentParent* aContentParent,
uint64_t aChannelId, const nsAString& aAddonId)
-> RefPtr<ChildEndpointPromise> {
bool StreamFilterParent::Create(dom::ContentParent* aContentParent,
uint64_t aChannelId, const nsAString& aAddonId,
Endpoint<PStreamFilterChild>* aEndpoint) {
AssertIsMainThread();
auto& webreq = WebRequestService::GetSingleton();
@ -120,12 +120,25 @@ auto StreamFilterParent::Create(dom::ContentParent* aContentParent,
webreq.GetTraceableChannel(aChannelId, addonId, aContentParent);
RefPtr<mozilla::net::nsHttpChannel> chan = do_QueryObject(channel);
if (!chan) {
return ChildEndpointPromise::CreateAndReject(false, __func__);
NS_ENSURE_TRUE(chan, false);
auto channelPid = chan->ProcessId();
NS_ENSURE_TRUE(channelPid, false);
Endpoint<PStreamFilterParent> parent;
Endpoint<PStreamFilterChild> child;
nsresult rv = PStreamFilter::CreateEndpoints(
channelPid,
aContentParent ? aContentParent->OtherPid() : base::GetCurrentProcId(),
&parent, &child);
NS_ENSURE_SUCCESS(rv, false);
if (!chan->AttachStreamFilter(std::move(parent))) {
return false;
}
return chan->AttachStreamFilter(aContentParent ? aContentParent->OtherPid()
: base::GetCurrentProcId());
*aEndpoint = std::move(child);
return true;
}
/* static */
@ -537,12 +550,6 @@ StreamFilterParent::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) {
RunOnActorThread(FUNC, [=] {
if (self->IPCActive()) {
self->CheckResult(self->SendStopRequest(aStatusCode));
} else {
RunOnMainThread(FUNC, [=] {
if (!self->mSentStop) {
self->EmitStopRequest(aStatusCode);
}
});
}
});
return NS_OK;

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

@ -55,13 +55,10 @@ class StreamFilterParent final : public PStreamFilterParent,
StreamFilterParent();
using ParentEndpoint = mozilla::ipc::Endpoint<PStreamFilterParent>;
using ChildEndpoint = mozilla::ipc::Endpoint<PStreamFilterChild>;
using ChildEndpointPromise = MozPromise<ChildEndpoint, bool, true>;
static MOZ_MUST_USE RefPtr<ChildEndpointPromise> Create(
ContentParent* aContentParent, uint64_t aChannelId,
const nsAString& aAddonId);
static bool Create(ContentParent* aContentParent, uint64_t aChannelId,
const nsAString& aAddonId,
mozilla::ipc::Endpoint<PStreamFilterChild>* aEndpoint);
static void Attach(nsIChannel* aChannel, ParentEndpoint&& aEndpoint);