Bug 1510715 - Backed out changeset d15f0ac561d9 (bug 1260527) a=backout

This commit is contained in:
Valentin Gosu 2018-11-28 21:40:35 +01:00
Родитель 93f488667a
Коммит 8e3e7b2a3e
10 изменённых файлов: 108 добавлений и 150 удалений

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

@ -74,7 +74,9 @@ void NeckoChild::InitNeckoChild()
}
PHttpChannelChild*
NeckoChild::AllocPHttpChannelChild()
NeckoChild::AllocPHttpChannelChild(const PBrowserOrId& browser,
const SerializedLoadContext& loadContext,
const HttpChannelCreationArgs& aOpenArgs)
{
// We don't allocate here: instead we always use IPDL constructor that takes
// an existing HttpChildChannel

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

@ -25,7 +25,9 @@ public:
static void InitNeckoChild();
protected:
virtual PHttpChannelChild* AllocPHttpChannelChild() override;
virtual PHttpChannelChild*
AllocPHttpChannelChild(const PBrowserOrId&, const SerializedLoadContext&,
const HttpChannelCreationArgs& aOpenArgs) override;
virtual bool DeallocPHttpChannelChild(PHttpChannelChild*) override;
virtual PStunAddrsRequestChild* AllocPStunAddrsRequestChild() override;

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

@ -92,9 +92,8 @@ NeckoParent::NeckoParent()
}
}
/* static */ PBOverrideStatus
NeckoParent::PBOverrideStatusFromLoadContext(
const SerializedLoadContext& aSerialized)
static PBOverrideStatus
PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized)
{
if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) {
return (aSerialized.mOriginAttributes.mPrivateBrowsingId > 0) ?
@ -104,9 +103,8 @@ NeckoParent::PBOverrideStatusFromLoadContext(
return kPBOverride_Unset;
}
/* static */ already_AddRefed<nsIPrincipal>
NeckoParent::GetRequestingPrincipal(
const OptionalLoadInfoArgs& aOptionalLoadInfoArgs)
static already_AddRefed<nsIPrincipal>
GetRequestingPrincipal(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs)
{
if (aOptionalLoadInfoArgs.type() != OptionalLoadInfoArgs::TLoadInfoArgs) {
return nullptr;
@ -126,8 +124,8 @@ NeckoParent::GetRequestingPrincipal(
return PrincipalInfoToPrincipal(principalInfo);
}
/* static */ already_AddRefed<nsIPrincipal>
NeckoParent::GetRequestingPrincipal(const HttpChannelCreationArgs& aArgs)
static already_AddRefed<nsIPrincipal>
GetRequestingPrincipal(const HttpChannelCreationArgs& aArgs)
{
if (aArgs.type() != HttpChannelCreationArgs::THttpChannelOpenArgs) {
return nullptr;
@ -137,8 +135,8 @@ NeckoParent::GetRequestingPrincipal(const HttpChannelCreationArgs& aArgs)
return GetRequestingPrincipal(args.loadInfo());
}
/* static */ already_AddRefed<nsIPrincipal>
NeckoParent::GetRequestingPrincipal(const FTPChannelCreationArgs& aArgs)
static already_AddRefed<nsIPrincipal>
GetRequestingPrincipal(const FTPChannelCreationArgs& aArgs)
{
if (aArgs.type() != FTPChannelCreationArgs::TFTPChannelOpenArgs) {
return nullptr;
@ -159,7 +157,7 @@ void CrashWithReason(const char * reason)
#endif
}
/* static */ const char*
const char*
NeckoParent::GetValidatedOriginAttributes(const SerializedLoadContext& aSerialized,
PContentParent* aContent,
nsIPrincipal* aRequestingPrincipal,
@ -235,7 +233,7 @@ NeckoParent::GetValidatedOriginAttributes(const SerializedLoadContext& aSerializ
return "App does not have permission";
}
/* static */ const char *
const char *
NeckoParent::CreateChannelLoadContext(const PBrowserOrId& aBrowser,
PContentParent* aContent,
const SerializedLoadContext& aSerialized,
@ -286,9 +284,25 @@ NeckoParent::ActorDestroy(ActorDestroyReason aWhy)
}
PHttpChannelParent*
NeckoParent::AllocPHttpChannelParent()
NeckoParent::AllocPHttpChannelParent(const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs)
{
HttpChannelParent* p = new HttpChannelParent();
nsCOMPtr<nsIPrincipal> requestingPrincipal =
GetRequestingPrincipal(aOpenArgs);
nsCOMPtr<nsILoadContext> loadContext;
const char *error = CreateChannelLoadContext(aBrowser, Manager(),
aSerialized, requestingPrincipal,
loadContext);
if (error) {
printf_stderr("NeckoParent::AllocPHttpChannelParent: "
"FATAL error: %s: KILLING CHILD PROCESS\n",
error);
return nullptr;
}
PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(aSerialized);
HttpChannelParent *p = new HttpChannelParent(aBrowser, loadContext, overrideStatus);
p->AddRef();
return p;
}
@ -301,6 +315,20 @@ NeckoParent::DeallocPHttpChannelParent(PHttpChannelParent* channel)
return true;
}
mozilla::ipc::IPCResult
NeckoParent::RecvPHttpChannelConstructor(
PHttpChannelParent* aActor,
const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs)
{
HttpChannelParent* p = static_cast<HttpChannelParent*>(aActor);
if (!p->Init(aOpenArgs)) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}
PStunAddrsRequestParent*
NeckoParent::AllocPStunAddrsRequestParent()
{

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

@ -33,15 +33,6 @@ public:
NeckoParent();
virtual ~NeckoParent() = default;
static PBOverrideStatus PBOverrideStatusFromLoadContext(
const SerializedLoadContext& aSerialized);
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
const OptionalLoadInfoArgs& aOptionalLoadInfoArgs);
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
const FTPChannelCreationArgs& aArgs);
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
const HttpChannelCreationArgs& aArgs);
MOZ_MUST_USE
static const char *
GetValidatedOriginAttributes(const SerializedLoadContext& aSerialized,
@ -102,7 +93,15 @@ public:
};
protected:
virtual PHttpChannelParent* AllocPHttpChannelParent() override;
virtual PHttpChannelParent*
AllocPHttpChannelParent(const PBrowserOrId&, const SerializedLoadContext&,
const HttpChannelCreationArgs& aOpenArgs) override;
virtual mozilla::ipc::IPCResult
RecvPHttpChannelConstructor(
PHttpChannelParent* aActor,
const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs) override;
virtual bool DeallocPHttpChannelParent(PHttpChannelParent*) override;
virtual PStunAddrsRequestParent* AllocPStunAddrsRequestParent() override;

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

@ -72,7 +72,9 @@ parent:
async __delete__();
nested(inside_cpow) async PCookieService();
async PHttpChannel();
async PHttpChannel(PBrowserOrId browser,
SerializedLoadContext loadContext,
HttpChannelCreationArgs args);
async PWyciwygChannel();
async PFTPChannel(PBrowserOrId browser, SerializedLoadContext loadContext,
FTPChannelCreationArgs args);

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

@ -193,7 +193,6 @@ HttpChannelChild::HttpChannelChild()
, mSuspendParentAfterSynthesizeResponse(false)
, mCacheNeedToReportBytesReadInitialized(false)
, mNeedToReportBytesRead(true)
, mSentAsyncOpen(false)
{
LOG(("Creating HttpChannelChild @%p\n", this));
@ -267,7 +266,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) HttpChannelChild::Release()
// remote channel for security info IPDL itself holds 1 reference, so we
// Send_delete when refCnt==1. But if !mIPCOpen, then there's nobody to send
// to, so we fall through.
if ((mKeptAlive || !mSentAsyncOpen) && count == 1 && mIPCOpen) {
if (mKeptAlive && count == 1 && mIPCOpen) {
mKeptAlive = false;
// We send a message to the parent, which calls SendDelete, and then the
// child calling Send__delete__() to finally drop the refcount to 0.
@ -1652,8 +1651,7 @@ HttpChannelChild::DeleteSelf()
void HttpChannelChild::FinishInterceptedRedirect()
{
nsresult rv = InitIPCChannel(); // reinitializes IPC channel
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsresult rv;
if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
MOZ_ASSERT(!mInterceptedRedirectContext, "the context should be null!");
rv = AsyncOpen2(mInterceptedRedirectListener);
@ -2210,13 +2208,24 @@ HttpChannelChild::ConnectParent(uint32_t registrarId)
HttpBaseChannel::SetDocshellUserAgentOverride();
// The socket transport in the chrome process now holds a logical ref to us
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
AddIPDLReference();
// This must happen before the constructor message is sent. Otherwise messages
// from the parent could arrive quickly and be delivered to the wrong event
// target.
SetEventTarget();
HttpChannelConnectArgs connectArgs(registrarId, mShouldParentIntercept);
PBrowserOrId browser = static_cast<ContentChild*>(gNeckoChild->Manager())
->GetBrowserOrId(tabChild);
if (!SendAsyncOpen(browser, IPC::SerializedLoadContext(this), connectArgs)) {
if (!gNeckoChild->
SendPHttpChannelConstructor(this, browser,
IPC::SerializedLoadContext(this),
connectArgs)) {
return NS_ERROR_FAILURE;
}
mSentAsyncOpen = true;
{
MutexAutoLock lock(mBgChildMutex);
@ -2723,42 +2732,6 @@ HttpChannelChild::AsyncOpen2(nsIStreamListener *aListener)
return AsyncOpen(listener, nullptr);
}
NS_IMETHODIMP
HttpChannelChild::SetLoadInfo(nsILoadInfo* aLoadInfo)
{
LOG(("HttpChannelChild::SetLoadInfo [this=%p, aLoadInfo=%p]",
this, aLoadInfo));
MOZ_ALWAYS_SUCCEEDS(HttpBaseChannel::SetLoadInfo(aLoadInfo));
// IPC channel already open
if (NS_WARN_IF(mIPCOpen)) {
return NS_OK;
}
return InitIPCChannel();
}
nsresult
HttpChannelChild::InitIPCChannel()
{
MOZ_ASSERT(!mIPCOpen);
// This must happen before the constructor message is sent. Otherwise messages
// from the parent could arrive quickly and be delivered to the wrong event
// target.
SetEventTarget();
LOG((" Calling SendPHttpChannelConstructor"));
if (!gNeckoChild->SendPHttpChannelConstructor(this)) {
return NS_ERROR_FAILURE;
}
// The socket transport in the chrome process now holds a logical ref to us
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
AddIPDLReference();
return NS_OK;
}
// Assigns an nsIEventTarget to our IPDL actor so that IPC messages are sent to
// the correct DocGroup/TabGroup.
void
@ -2972,12 +2945,21 @@ HttpChannelChild::ContinueAsyncOpen()
openArgs.navigationStartTimeStamp() = navigationStartTimeStamp;
LOG(("HttpChannelChild::ContinueAsyncOpen - SendAsyncOpen [this=%p]", this));
// This must happen before the constructor message is sent. Otherwise messages
// from the parent could arrive quickly and be delivered to the wrong event
// target.
SetEventTarget();
// The socket transport in the chrome process now holds a logical ref to us
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
AddIPDLReference();
PBrowserOrId browser = cc->GetBrowserOrId(tabChild);
if (!SendAsyncOpen(browser, IPC::SerializedLoadContext(this), openArgs)) {
if (!gNeckoChild->SendPHttpChannelConstructor(this, browser,
IPC::SerializedLoadContext(this),
openArgs)) {
return NS_ERROR_FAILURE;
}
mSentAsyncOpen = true;
{
MutexAutoLock lock(mBgChildMutex);
@ -3754,14 +3736,6 @@ HttpChannelChild::ResetInterception()
return;
}
if (!mIPCOpen) {
// The IPC channel was closed. See RecvFinishInterceptedRedirect.
// We now want to reuse it, so we call InitIPCChannel again.
DebugOnly<nsresult> rv = InitIPCChannel();
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
MOZ_ASSERT(mLoadInfo && mIPCOpen);
// Continue with the original cross-process request
nsresult rv = ContinueAsyncOpen();
if (NS_WARN_IF(NS_FAILED(rv))) {

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

@ -91,7 +91,6 @@ public:
NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo) override;
NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) override;
NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override;
NS_IMETHOD SetLoadInfo(nsILoadInfo* aLoadInfo) override;
// HttpBaseChannel::nsIHttpChannel
NS_IMETHOD SetReferrerWithPolicy(nsIURI *referrer, uint32_t referrerPolicy) override;
@ -207,7 +206,6 @@ protected:
virtual mozilla::ipc::IPCResult RecvLogBlockedCORSRequest(const nsString& aMessage, const nsCString& aCategory) override;
NS_IMETHOD LogBlockedCORSRequest(const nsAString & aMessage, const nsACString& aCategory) override;
nsresult InitIPCChannel();
private:
nsresult
AsyncCallImpl(void (HttpChannelChild::*funcPtr)(),
@ -434,22 +432,11 @@ private:
// True if we need to tell the parent the size of unreported received data
uint8_t mNeedToReportBytesRead : 1;
// True after SendAsyncOpen is called.
uint8_t mSentAsyncOpen : 1;
void FinishInterceptedRedirect();
void CleanupRedirectingChannel(nsresult rv);
// true after successful AsyncOpen until OnStopRequest completes.
// XXX valentin: technically the channel exists after SetLoadInfo, but it
// used to be created at AsyncOpen, and before that the parent actually
// doesn't have all the info for it to be safe to call any method.
// We should rename it in the future and allow some methods to be called
// before asyncOpen.
bool RemoteChannelExists()
{
return mIPCOpen && !mKeptAlive && mSentAsyncOpen;
}
bool RemoteChannelExists() { return mIPCOpen && !mKeptAlive; }
void AssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID);

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

@ -62,11 +62,13 @@ using namespace mozilla::ipc;
namespace mozilla {
namespace net {
HttpChannelParent::HttpChannelParent()
: mLoadContext(nullptr)
HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus)
: mLoadContext(aLoadContext)
, mNestedFrameId(0)
, mIPCClosed(false)
, mPBOverride(kPBOverride_Unset)
, mPBOverride(aOverrideStatus)
, mStatus(NS_OK)
, mIgnoreProgress(false)
, mSentRedirect1BeginFailed(false)
@ -92,6 +94,14 @@ HttpChannelParent::HttpChannelParent()
MOZ_ASSERT(gHttpHandler);
mHttpHandler = gHttpHandler;
if (iframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
mTabParent = static_cast<dom::TabParent*>(iframeEmbedding.get_PBrowserParent());
} else {
mNestedFrameId = iframeEmbedding.get_TabId();
}
mSendWindowSize = gHttpHandler->SendWindowSize();
mEventQ = new ChannelEventQueue(static_cast<nsIParentRedirectingChannel*>(this));
}
@ -165,43 +175,6 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
}
}
mozilla::ipc::IPCResult
HttpChannelParent::RecvAsyncOpen(const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs)
{
LOG(("HttpChannelParent::RecvAsyncOpen [this=%p]\n", this));
nsCOMPtr<nsIPrincipal> requestingPrincipal =
NeckoParent::GetRequestingPrincipal(aOpenArgs);
nsCOMPtr<nsILoadContext> loadContext;
const char* error =
NeckoParent::CreateChannelLoadContext(aBrowser,
Manager()->Manager(),
aSerialized,
requestingPrincipal,
loadContext);
if (error) {
return IPC_FAIL(this, "Error in NeckoParent::CreateChannelLoadContext");
}
mPBOverride = NeckoParent::PBOverrideStatusFromLoadContext(aSerialized);
mLoadContext = loadContext;
if (aBrowser.type() == PBrowserOrId::TPBrowserParent) {
mTabParent = static_cast<dom::TabParent*>(aBrowser.get_PBrowserParent());
} else {
mNestedFrameId = aBrowser.get_TabId();
}
mSendWindowSize = gHttpHandler->SendWindowSize();
if (!Init(aOpenArgs)) {
return IPC_FAIL(this, "Error in HttpChannelParent::Init");
}
return IPC_OK();
}
void
HttpChannelParent::TryInvokeAsyncOpen(nsresult aRv)
{
@ -505,12 +478,8 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
nsCOMPtr<nsIURI> apiRedirectToUri = DeserializeURI(aAPIRedirectToURI);
nsCOMPtr<nsIURI> topWindowUri = DeserializeURI(aTopWindowURI);
LOG(("HttpChannelParent DoAsyncOpen [this=%p uri=%s, gid=%" PRIu64
" topwinid=%" PRIx64 "]\n",
this,
uri->GetSpecOrDefault().get(),
aChannelId,
aTopLevelOuterContentWindowId));
LOG(("HttpChannelParent RecvAsyncOpen [this=%p uri=%s, gid=%" PRIu64 " topwinid=%" PRIx64 "]\n",
this, uri->GetSpecOrDefault().get(), aChannelId, aTopLevelOuterContentWindowId));
nsresult rv;

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

@ -71,7 +71,9 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(HTTP_CHANNEL_PARENT_IID)
HttpChannelParent();
HttpChannelParent(const dom::PBrowserOrId& iframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aStatus);
MOZ_MUST_USE bool Init(const HttpChannelCreationArgs& aOpenArgs);
@ -231,10 +233,6 @@ protected:
// Called to notify the parent channel to not send any more IPC messages.
virtual mozilla::ipc::IPCResult RecvDeletingChannel() override;
virtual mozilla::ipc::IPCResult RecvFinishInterceptedRedirect() override;
virtual mozilla::ipc::IPCResult RecvAsyncOpen(
const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs) override;
private:
void UpdateAndSerializeSecurityInfo(nsACString& aSerializedSecurityInfoOut);

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

@ -13,14 +13,12 @@ include PBackgroundSharedTypes;
include NeckoChannelParams;
include IPCServiceWorkerDescriptor;
include IPCStream;
include PBrowserOrId;
include "mozilla/net/NeckoMessageUtils.h";
using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
using mozilla::net::NetAddr from "mozilla/net/DNS.h";
using struct mozilla::net::ResourceTimingStruct from "mozilla/net/TimingStruct.h";
using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
namespace mozilla {
namespace net {
@ -31,9 +29,8 @@ protocol PHttpChannel
manager PNecko;
parent:
async AsyncOpen(PBrowserOrId browser,
SerializedLoadContext loadContext,
HttpChannelCreationArgs args);
// Note: channels are opened during construction, so no open method here:
// see PNecko.ipdl
async SetClassOfService(uint32_t cos);