зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1646592) for xpcshell failures on test_ext_webRequest_filterResponseData.js CLOSED TREE
Backed out changeset cc60e258290e (bug 1646592) Backed out changeset 3a514b227127 (bug 1646592) Backed out changeset de9ba1eaded1 (bug 1646592) Backed out changeset 31aab78792d8 (bug 1646592)
This commit is contained in:
Родитель
e6f3141f9a
Коммит
b75fb2d3e0
|
@ -44,6 +44,30 @@ class MainThreadChannelEvent : public ChannelEvent {
|
|||
}
|
||||
};
|
||||
|
||||
// This event is designed to be only used for e10s child channels.
|
||||
// The goal is to force the child channel to implement GetNeckoTarget()
|
||||
// which should return a labeled main thread event target so that this
|
||||
// channel event can be dispatched correctly.
|
||||
template <typename T>
|
||||
class NeckoTargetChannelEvent : public ChannelEvent {
|
||||
public:
|
||||
explicit NeckoTargetChannelEvent(T* aChild) : mChild(aChild) {
|
||||
MOZ_COUNT_CTOR(NeckoTargetChannelEvent);
|
||||
}
|
||||
virtual ~NeckoTargetChannelEvent() {
|
||||
MOZ_COUNT_DTOR(NeckoTargetChannelEvent);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget> GetEventTarget() override {
|
||||
MOZ_ASSERT(mChild);
|
||||
|
||||
return mChild->GetNeckoTarget();
|
||||
}
|
||||
|
||||
protected:
|
||||
T* mChild;
|
||||
};
|
||||
|
||||
class ChannelFunctionEvent : public ChannelEvent {
|
||||
public:
|
||||
ChannelFunctionEvent(
|
||||
|
|
|
@ -415,20 +415,6 @@ IPCResult HttpBackgroundChannelChild::RecvSetClassifierMatchedTrackingInfo(
|
|||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult HttpBackgroundChannelChild::RecvAttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
|
||||
LOG(("HttpBackgroundChannelChild::RecvAttachStreamFilter [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
|
||||
if (NS_WARN_IF(!mChannelChild)) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mChannelChild->ProcessAttachStreamFilter(std::move(aEndpoint));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void HttpBackgroundChannelChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
LOG(("HttpBackgroundChannelChild::ActorDestroy[this=%p]\n", this));
|
||||
// This function might be called during shutdown phase, so OnSocketThread()
|
||||
|
|
|
@ -90,9 +90,6 @@ class HttpBackgroundChannelChild final : public PHttpBackgroundChannelChild {
|
|||
|
||||
IPCResult RecvSetClassifierMatchedTrackingInfo(const ClassifierInfo& info);
|
||||
|
||||
IPCResult RecvAttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
void CreateDataBridge();
|
||||
|
|
|
@ -472,28 +472,6 @@ bool HttpBackgroundChannelParent::OnSetClassifierMatchedTrackingInfo(
|
|||
|
||||
return SendSetClassifierMatchedTrackingInfo(info);
|
||||
}
|
||||
|
||||
nsISerialEventTarget* HttpBackgroundChannelParent::GetBackgroundTarget() {
|
||||
MOZ_ASSERT(mBackgroundThread);
|
||||
return mBackgroundThread.get();
|
||||
}
|
||||
|
||||
auto HttpBackgroundChannelParent::AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aParentEndpoint,
|
||||
Endpoint<extensions::PStreamFilterChild>&& aChildEndpoint)
|
||||
-> RefPtr<ChildEndpointPromise> {
|
||||
LOG(("HttpBackgroundChannelParent::AttachStreamFilter [this=%p]\n", this));
|
||||
MOZ_ASSERT(IsOnBackgroundThread());
|
||||
|
||||
if (NS_WARN_IF(!mIPCOpened) ||
|
||||
!SendAttachStreamFilter(std::move(aParentEndpoint))) {
|
||||
return ChildEndpointPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
return ChildEndpointPromise::CreateAndResolve(std::move(aChildEndpoint),
|
||||
__func__);
|
||||
}
|
||||
|
||||
void HttpBackgroundChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
LOG(("HttpBackgroundChannelParent::ActorDestroy [this=%p]\n", this));
|
||||
AssertIsInMainProcess();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "nsID.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
class nsISerialEventTarget;
|
||||
class nsIEventTarget;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
@ -86,14 +86,6 @@ class HttpBackgroundChannelParent final : public PHttpBackgroundChannelParent {
|
|||
bool OnSetClassifierMatchedTrackingInfo(const nsACString& aLists,
|
||||
const nsACString& aFullHashes);
|
||||
|
||||
nsISerialEventTarget* GetBackgroundTarget();
|
||||
|
||||
using ChildEndpointPromise =
|
||||
MozPromise<ipc::Endpoint<extensions::PStreamFilterChild>, bool, true>;
|
||||
[[nodiscard]] RefPtr<ChildEndpointPromise> AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aParentEndpoint,
|
||||
Endpoint<extensions::PStreamFilterChild>&& aChildEndpoint);
|
||||
|
||||
protected:
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
|
@ -105,7 +97,7 @@ class HttpBackgroundChannelParent final : public PHttpBackgroundChannelParent {
|
|||
// Used to ensure atomicity of mBackgroundThread
|
||||
Mutex mBgThreadMutex;
|
||||
|
||||
nsCOMPtr<nsISerialEventTarget> mBackgroundThread;
|
||||
nsCOMPtr<nsIEventTarget> mBackgroundThread;
|
||||
|
||||
// associated HttpChannelParent for generating the channel events
|
||||
RefPtr<HttpChannelParent> mChannelParent;
|
||||
|
|
|
@ -194,7 +194,7 @@ HttpChannelChild::HttpChannelChild()
|
|||
mIsLastPartOfMultiPart(false),
|
||||
mSuspendForWaitCompleteRedirectSetup(false),
|
||||
mRecvOnStartRequestSentCalled(false),
|
||||
mSuspendedByWaitingForPermissionCookie(false) {
|
||||
mSuspendedByWaitingForPermissionCookieStreamFilter(false) {
|
||||
LOG(("Creating HttpChannelChild @%p\n", this));
|
||||
|
||||
mChannelCreationTime = PR_Now();
|
||||
|
@ -406,8 +406,8 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequestSent() {
|
|||
|
||||
mRecvOnStartRequestSentCalled = true;
|
||||
|
||||
if (mSuspendedByWaitingForPermissionCookie) {
|
||||
mSuspendedByWaitingForPermissionCookie = false;
|
||||
if (mSuspendedByWaitingForPermissionCookieStreamFilter) {
|
||||
mSuspendedByWaitingForPermissionCookieStreamFilter = false;
|
||||
mEventQ->Resume();
|
||||
}
|
||||
return IPC_OK();
|
||||
|
@ -551,7 +551,7 @@ void HttpChannelChild::OnStartRequest(
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mEventQ->Suspend();
|
||||
mSuspendedByWaitingForPermissionCookie = true;
|
||||
mSuspendedByWaitingForPermissionCookieStreamFilter = true;
|
||||
mEventQ->PrependEvent(MakeUnique<NeckoTargetChannelFunctionEvent>(
|
||||
this, [self = UnsafePtr<HttpChannelChild>(this)]() {
|
||||
self->DoOnStartRequest(self, nullptr);
|
||||
|
@ -3873,39 +3873,10 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvSetPriority(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
// We don't have a copyable Endpoint and NeckoTargetChannelFunctionEvent takes
|
||||
// std::function<void()>. It's not possible to avoid the copy from the type of
|
||||
// lambda to std::function, so does the capture list. Hence, we're forced to
|
||||
// use the old-fashioned channel event inheritance.
|
||||
class AttachStreamFilterEvent : public ChannelEvent {
|
||||
public:
|
||||
AttachStreamFilterEvent(HttpChannelChild* aChild,
|
||||
already_AddRefed<nsIEventTarget> aTarget,
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint)
|
||||
: mChild(aChild), mTarget(aTarget), mEndpoint(std::move(aEndpoint)) {}
|
||||
|
||||
already_AddRefed<nsIEventTarget> GetEventTarget() override {
|
||||
nsCOMPtr<nsIEventTarget> target = mTarget;
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
void Run() override {
|
||||
extensions::StreamFilterParent::Attach(mChild, std::move(mEndpoint));
|
||||
}
|
||||
|
||||
private:
|
||||
HttpChannelChild* mChild;
|
||||
nsCOMPtr<nsIEventTarget> mTarget;
|
||||
Endpoint<extensions::PStreamFilterParent> mEndpoint;
|
||||
};
|
||||
|
||||
void HttpChannelChild::ProcessAttachStreamFilter(
|
||||
mozilla::ipc::IPCResult HttpChannelChild::RecvAttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
|
||||
LOG(("HttpChannelChild::ProcessAttachStreamFilter [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
|
||||
mEventQ->RunOrEnqueue(new AttachStreamFilterEvent(this, GetNeckoTarget(),
|
||||
std::move(aEndpoint)));
|
||||
extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult HttpChannelChild::RecvCancelDiversion() {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/extensions/StreamFilterParent.h"
|
||||
#include "mozilla/net/HttpBaseChannel.h"
|
||||
#include "mozilla/net/NeckoTargetHolder.h"
|
||||
#include "mozilla/net/PHttpChannelChild.h"
|
||||
|
@ -155,6 +154,9 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
|
||||
mozilla::ipc::IPCResult RecvSetPriority(const int16_t& aPriority) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvAttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvCancelDiversion() override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvOriginalCacheInputStreamAvailable(
|
||||
|
@ -265,9 +267,6 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
|
||||
void ProcessOnStatus(const nsresult& aStatus);
|
||||
|
||||
void ProcessAttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
|
||||
|
||||
// Return true if we need to tell the parent the size of unreported received
|
||||
// data
|
||||
bool NeedToReportBytesRead();
|
||||
|
@ -474,9 +473,9 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
// True if RecvOnStartRequestSent was received.
|
||||
uint8_t mRecvOnStartRequestSentCalled : 1;
|
||||
|
||||
// True if this channel is suspened by waiting for permission or cookie.
|
||||
// That is, RecvOnStartRequestSent is received.
|
||||
uint8_t mSuspendedByWaitingForPermissionCookie : 1;
|
||||
// True if this channel is suspened by waiting for permission, cookie or
|
||||
// stream filter. That is, RecvOnStartRequestSent is received.
|
||||
uint8_t mSuspendedByWaitingForPermissionCookieStreamFilter : 1;
|
||||
|
||||
void FinishInterceptedRedirect();
|
||||
void CleanupRedirectingChannel(nsresult rv);
|
||||
|
|
|
@ -83,7 +83,8 @@ HttpChannelParent::HttpChannelParent(dom::BrowserParent* iframeEmbedding,
|
|||
mCacheNeedFlowControlInitialized(false),
|
||||
mNeedFlowControl(true),
|
||||
mSuspendedForFlowControl(false),
|
||||
mAfterOnStartRequestBegun(false) {
|
||||
mAfterOnStartRequestBegun(false),
|
||||
mStreamFilterAttached(false) {
|
||||
LOG(("Creating HttpChannelParent [this=%p]\n", this));
|
||||
|
||||
// Ensure gHttpHandler is initialized: we need the atom table up and running.
|
||||
|
@ -1541,7 +1542,8 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
|
|||
// Bug 1645901: Currently Set-Cookie is passed to child process on main
|
||||
// thread, which is racy with PBackground. We should have a way to set cookie
|
||||
// in child for Set-Cookie response header.
|
||||
args.shouldWaitForOnStartRequestSent() = isDocument || hasSetCookie;
|
||||
args.shouldWaitForOnStartRequestSent() =
|
||||
isDocument || hasSetCookie || mStreamFilterAttached;
|
||||
|
||||
rv = NS_OK;
|
||||
|
||||
|
@ -2663,23 +2665,11 @@ void HttpChannelParent::OverrideReferrerInfoDuringBeginConnect(
|
|||
mOverrideReferrerInfo = aReferrerInfo;
|
||||
}
|
||||
|
||||
auto HttpChannelParent::AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aParentEndpoint,
|
||||
Endpoint<extensions::PStreamFilterChild>&& aChildEndpoint)
|
||||
-> RefPtr<ChildEndpointPromise> {
|
||||
LOG(("HttpChannelParent::AttachStreamFilter [this=%p]", this));
|
||||
bool HttpChannelParent::AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
|
||||
MOZ_ASSERT(!mAfterOnStartRequestBegun);
|
||||
|
||||
if (mIPCClosed) {
|
||||
return ChildEndpointPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
// If IPC channel is open, background channel should be ready to send
|
||||
// SendAttachStreamFilter.
|
||||
MOZ_ASSERT(mBgParent);
|
||||
return InvokeAsync(mBgParent->GetBackgroundTarget(), mBgParent.get(),
|
||||
__func__, &HttpBackgroundChannelParent::AttachStreamFilter,
|
||||
std::move(aParentEndpoint), std::move(aChildEndpoint));
|
||||
mStreamFilterAttached = true;
|
||||
return SendAttachStreamFilter(std::move(aEndpoint));
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -134,11 +134,8 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
|
|||
// BeginConnect.
|
||||
void OverrideReferrerInfoDuringBeginConnect(nsIReferrerInfo* aReferrerInfo);
|
||||
|
||||
using ChildEndpointPromise =
|
||||
MozPromise<ipc::Endpoint<extensions::PStreamFilterChild>, bool, true>;
|
||||
[[nodiscard]] RefPtr<ChildEndpointPromise> AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aParentEndpoint,
|
||||
Endpoint<extensions::PStreamFilterChild>&& aChildEndpoint);
|
||||
bool AttachStreamFilter(
|
||||
Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
|
||||
|
||||
protected:
|
||||
// used to connect redirected-to channel in parent with just created
|
||||
|
@ -362,6 +359,12 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
|
|||
// Used to ensure methods can't be called before OnStartRequest.
|
||||
uint8_t mAfterOnStartRequestBegun : 1;
|
||||
|
||||
// Set if the channel is attached with a stream filter and will send
|
||||
// OnStartRequestSent to keep the order with OnStartRequest.
|
||||
// AttachStreamFilter should be handled before OnStartRequest goes to the
|
||||
// listener in child process, which could be racy with OnStartRequest.
|
||||
uint8_t mStreamFilterAttached : 1;
|
||||
|
||||
// Number of events to wait before actually invoking AsyncOpen on the main
|
||||
// channel. For each asynchronous step required before InvokeAsyncOpen, should
|
||||
// increase 1 to mAsyncOpenBarrier and invoke TryInvokeAsyncOpen after
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PBackground;
|
||||
include protocol PStreamFilter;
|
||||
include NeckoChannelParams;
|
||||
include HttpChannelParams;
|
||||
include PURLClassifierInfo;
|
||||
|
@ -74,8 +73,6 @@ child:
|
|||
// Tell the child information of matched URL againts SafeBrowsing tracking list
|
||||
async SetClassifierMatchedTrackingInfo(ClassifierInfo info);
|
||||
|
||||
async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
|
||||
|
||||
async __delete__();
|
||||
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PNecko;
|
||||
include protocol PStreamFilter;
|
||||
include InputStreamParams;
|
||||
include URIParams;
|
||||
include PBackgroundSharedTypes;
|
||||
|
@ -147,6 +148,8 @@ child:
|
|||
nsString url,
|
||||
nsString contentType);
|
||||
|
||||
async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
|
||||
|
||||
// See ADivertableParentChannel::CancelDiversion
|
||||
async CancelDiversion();
|
||||
|
||||
|
|
|
@ -7094,7 +7094,10 @@ auto nsHttpChannel::AttachStreamFilter(base::ProcessId aChildProcessId)
|
|||
}
|
||||
|
||||
if (RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel)) {
|
||||
return httpParent->AttachStreamFilter(std::move(parent), std::move(child));
|
||||
if (httpParent->AttachStreamFilter(std::move(parent))) {
|
||||
return ChildEndpointPromise::CreateAndResolve(std::move(child), __func__);
|
||||
}
|
||||
return ChildEndpointPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
extensions::StreamFilterParent::Attach(this, std::move(parent));
|
||||
|
|
Загрузка…
Ссылка в новой задаче