Bug 1413999 - Part3: IPC part, send trailers to child process r=dragana

The aim of this patch is to send trailers to child process via SendOnStopRequest.

--HG--
extra : rebase_source : 1a5e16e140ef20cfe2e723c3800d7feeebd9a5af
This commit is contained in:
Kershaw Chang 2018-01-03 02:05:00 +02:00
Родитель 73d9823e67
Коммит 62a41d6974
8 изменённых файлов: 52 добавлений и 23 удалений

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

@ -179,9 +179,10 @@ HttpBackgroundChannelChild::RecvOnTransportAndData(
IPCResult
HttpBackgroundChannelChild::RecvOnStopRequest(
const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming,
const TimeStamp& aLastActiveTabOptHit)
const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming,
const TimeStamp& aLastActiveTabOptHit,
const nsHttpHeaderArray& aResponseTrailers)
{
LOG(("HttpBackgroundChannelChild::RecvOnStopRequest [this=%p]\n", this));
MOZ_ASSERT(OnSocketThread());
@ -200,18 +201,22 @@ HttpBackgroundChannelChild::RecvOnStopRequest(
static_cast<uint32_t>(aChannelStatus)));
mQueuedRunnables.AppendElement(
NewRunnableMethod<const nsresult, const ResourceTimingStruct, const TimeStamp>(
NewRunnableMethod<const nsresult,
const ResourceTimingStruct,
const TimeStamp,
const nsHttpHeaderArray>(
"HttpBackgroundChannelChild::RecvOnStopRequest",
this,
&HttpBackgroundChannelChild::RecvOnStopRequest,
aChannelStatus,
aTiming,
aLastActiveTabOptHit));
aLastActiveTabOptHit,
aResponseTrailers));
return IPC_OK();
}
mChannelChild->ProcessOnStopRequest(aChannelStatus, aTiming);
mChannelChild->ProcessOnStopRequest(aChannelStatus, aTiming, aResponseTrailers);
return IPC_OK();
}

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

@ -49,7 +49,8 @@ protected:
IPCResult RecvOnStopRequest(const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming,
const TimeStamp& aLastActiveTabOptHit) override;
const TimeStamp& aLastActiveTabOptHit,
const nsHttpHeaderArray& aResponseTrailers) override;
IPCResult RecvOnProgress(const int64_t& aProgress,
const int64_t& aProgressMax) override;

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

@ -220,7 +220,8 @@ HttpBackgroundChannelParent::OnTransportAndData(
bool
HttpBackgroundChannelParent::OnStopRequest(const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming)
const ResourceTimingStruct& aTiming,
const nsHttpHeaderArray& aResponseTrailers)
{
LOG(("HttpBackgroundChannelParent::OnStopRequest [this=%p "
"status=%" PRIx32 "]\n", this, static_cast<uint32_t>(aChannelStatus)));
@ -233,12 +234,15 @@ HttpBackgroundChannelParent::OnStopRequest(const nsresult& aChannelStatus,
if (!IsOnBackgroundThread()) {
MutexAutoLock lock(mBgThreadMutex);
nsresult rv = mBackgroundThread->Dispatch(
NewRunnableMethod<const nsresult, const ResourceTimingStruct>(
NewRunnableMethod<const nsresult,
const ResourceTimingStruct,
const nsHttpHeaderArray>(
"net::HttpBackgroundChannelParent::OnStopRequest",
this,
&HttpBackgroundChannelParent::OnStopRequest,
aChannelStatus,
aTiming),
aTiming,
aResponseTrailers),
NS_DISPATCH_NORMAL);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
@ -249,7 +253,7 @@ HttpBackgroundChannelParent::OnStopRequest(const nsresult& aChannelStatus,
// See the child code for why we do this.
TimeStamp lastActTabOpt = nsHttp::GetLastActiveTabLoadOptimizationHit();
return SendOnStopRequest(aChannelStatus, aTiming, lastActTabOpt);
return SendOnStopRequest(aChannelStatus, aTiming, lastActTabOpt, aResponseTrailers);
}
bool

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

@ -52,7 +52,8 @@ public:
// To send OnStopRequest message over background channel.
bool OnStopRequest(const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming);
const ResourceTimingStruct& aTiming,
const nsHttpHeaderArray& aResponseTrailers);
// To send OnProgress message over background channel.
bool OnProgress(const int64_t& aProgress,

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

@ -979,28 +979,33 @@ class StopRequestEvent : public NeckoTargetChannelEvent<HttpChannelChild>
public:
StopRequestEvent(HttpChannelChild* child,
const nsresult& channelStatus,
const ResourceTimingStruct& timing)
const ResourceTimingStruct& timing,
const nsHttpHeaderArray& aResponseTrailers)
: NeckoTargetChannelEvent<HttpChannelChild>(child)
, mChannelStatus(channelStatus)
, mTiming(timing) {}
, mTiming(timing)
, mResponseTrailers(aResponseTrailers) {}
void Run() { mChild->OnStopRequest(mChannelStatus, mTiming); }
void Run() { mChild->OnStopRequest(mChannelStatus, mTiming, mResponseTrailers); }
private:
nsresult mChannelStatus;
ResourceTimingStruct mTiming;
nsHttpHeaderArray mResponseTrailers;
};
void
HttpChannelChild::ProcessOnStopRequest(const nsresult& aChannelStatus,
const ResourceTimingStruct& aTiming)
const ResourceTimingStruct& aTiming,
const nsHttpHeaderArray& aResponseTrailers)
{
LOG(("HttpChannelChild::ProcessOnStopRequest [this=%p]\n", this));
MOZ_ASSERT(OnSocketThread());
MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
"Should not be receiving any more callbacks from parent!");
mEventQ->RunOrEnqueue(new StopRequestEvent(this, aChannelStatus, aTiming),
mEventQ->RunOrEnqueue(new StopRequestEvent(this, aChannelStatus,
aTiming, aResponseTrailers),
mDivertingToParent);
}
@ -1036,7 +1041,8 @@ HttpChannelChild::MaybeDivertOnStop(const nsresult& aChannelStatus)
void
HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
const ResourceTimingStruct& timing)
const ResourceTimingStruct& timing,
const nsHttpHeaderArray& aResponseTrailers)
{
LOG(("HttpChannelChild::OnStopRequest [this=%p status=%" PRIx32 "]\n",
this, static_cast<uint32_t>(channelStatus)));
@ -1089,6 +1095,8 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
mCacheReadStart = timing.cacheReadStart;
mCacheReadEnd = timing.cacheReadEnd;
mResponseTrailers = new nsHttpHeaderArray(aResponseTrailers);
DoPreOnStopRequest(channelStatus);
{ // We must flush the queue before we Send__delete__

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

@ -242,7 +242,8 @@ private:
const uint32_t& aCount,
const nsCString& aData);
void ProcessOnStopRequest(const nsresult& aStatusCode,
const ResourceTimingStruct& aTiming);
const ResourceTimingStruct& aTiming,
const nsHttpHeaderArray& aResponseTrailers);
void ProcessOnProgress(const int64_t& aProgress, const int64_t& aProgressMax);
void ProcessOnStatus(const nsresult& aStatus);
void ProcessFlushedForDiversion();
@ -415,7 +416,9 @@ private:
const uint64_t& offset,
const uint32_t& count,
const nsCString& data);
void OnStopRequest(const nsresult& channelStatus, const ResourceTimingStruct& timing);
void OnStopRequest(const nsresult& channelStatus,
const ResourceTimingStruct& timing,
const nsHttpHeaderArray& aResponseTrailers);
void MaybeDivertOnStop(const nsresult& aChannelStatus);
void OnProgress(const int64_t& progress, const int64_t& progressMax);
void OnStatus(const nsresult& status);

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

@ -1596,12 +1596,16 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
httpChannelImpl->SetWarningReporter(nullptr);
}
nsHttpHeaderArray *responseTrailer = mChannel->GetResponseTrailers();
// Either IPC channel is closed or background channel
// is ready to send OnStopRequest.
MOZ_ASSERT(mIPCClosed || mBgParent);
if (mIPCClosed ||
!mBgParent || !mBgParent->OnStopRequest(aStatusCode, timing)) {
!mBgParent ||
!mBgParent->OnStopRequest(aStatusCode, timing,
responseTrailer ? *responseTrailer : nsHttpHeaderArray())) {
return NS_ERROR_UNEXPECTED;
}

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

@ -11,6 +11,7 @@ include PURLClassifierInfo;
include "mozilla/net/NeckoMessageUtils.h";
using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
using struct mozilla::net::ResourceTimingStruct from "mozilla/net/TimingStruct.h";
namespace mozilla {
@ -36,8 +37,10 @@ child:
uint32_t count,
nsCString data);
async OnStopRequest(nsresult channelStatus, ResourceTimingStruct timing,
TimeStamp lastActiveTabOptimization);
async OnStopRequest(nsresult channelStatus,
ResourceTimingStruct timing,
TimeStamp lastActiveTabOptimization,
nsHttpHeaderArray responseTrailers);
async OnProgress(int64_t progress, int64_t progressMax);