зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325915 - Part 1, derive transportStatus in HttpChannelParent ODA and derive progress/progressMax in child side. r=mayhemer
MozReview-Commit-ID: 41qlyHKMSFm --HG-- extra : rebase_source : da54f269b4b186ad784b2351f39829922f08db89
This commit is contained in:
Родитель
5442d350f3
Коммит
4d6af6c71e
|
@ -591,31 +591,25 @@ class TransportAndDataEvent : public ChannelEvent
|
|||
TransportAndDataEvent(HttpChannelChild* child,
|
||||
const nsresult& channelStatus,
|
||||
const nsresult& transportStatus,
|
||||
const uint64_t& progress,
|
||||
const uint64_t& progressMax,
|
||||
const nsCString& data,
|
||||
const uint64_t& offset,
|
||||
const uint32_t& count)
|
||||
: mChild(child)
|
||||
, mChannelStatus(channelStatus)
|
||||
, mTransportStatus(transportStatus)
|
||||
, mProgress(progress)
|
||||
, mProgressMax(progressMax)
|
||||
, mData(data)
|
||||
, mOffset(offset)
|
||||
, mCount(count) {}
|
||||
|
||||
void Run()
|
||||
{
|
||||
mChild->OnTransportAndData(mChannelStatus, mTransportStatus, mProgress,
|
||||
mProgressMax, mOffset, mCount, mData);
|
||||
mChild->OnTransportAndData(mChannelStatus, mTransportStatus,
|
||||
mOffset, mCount, mData);
|
||||
}
|
||||
private:
|
||||
HttpChannelChild* mChild;
|
||||
nsresult mChannelStatus;
|
||||
nsresult mTransportStatus;
|
||||
uint64_t mProgress;
|
||||
uint64_t mProgressMax;
|
||||
nsCString mData;
|
||||
uint64_t mOffset;
|
||||
uint32_t mCount;
|
||||
|
@ -624,8 +618,6 @@ class TransportAndDataEvent : public ChannelEvent
|
|||
mozilla::ipc::IPCResult
|
||||
HttpChannelChild::RecvOnTransportAndData(const nsresult& channelStatus,
|
||||
const nsresult& transportStatus,
|
||||
const uint64_t& progress,
|
||||
const uint64_t& progressMax,
|
||||
const uint64_t& offset,
|
||||
const uint32_t& count,
|
||||
const nsCString& data)
|
||||
|
@ -635,8 +627,7 @@ HttpChannelChild::RecvOnTransportAndData(const nsresult& channelStatus,
|
|||
"Should not be receiving any more callbacks from parent!");
|
||||
|
||||
mEventQ->RunOrEnqueue(new TransportAndDataEvent(this, channelStatus,
|
||||
transportStatus, progress,
|
||||
progressMax, data, offset,
|
||||
transportStatus, data, offset,
|
||||
count),
|
||||
mDivertingToParent);
|
||||
return IPC_OK();
|
||||
|
@ -681,8 +672,6 @@ HttpChannelChild::MaybeDivertOnData(const nsCString& data,
|
|||
void
|
||||
HttpChannelChild::OnTransportAndData(const nsresult& channelStatus,
|
||||
const nsresult& transportStatus,
|
||||
const uint64_t progress,
|
||||
const uint64_t& progressMax,
|
||||
const uint64_t& offset,
|
||||
const uint32_t& count,
|
||||
const nsCString& data)
|
||||
|
@ -717,6 +706,9 @@ HttpChannelChild::OnTransportAndData(const nsresult& channelStatus,
|
|||
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
|
||||
|
||||
DoOnStatus(this, transportStatus);
|
||||
|
||||
const int64_t progressMax = mResponseHead->ContentLength();
|
||||
const int64_t progress = offset + count;
|
||||
DoOnProgress(this, progress, progressMax);
|
||||
|
||||
// OnDataAvailable
|
||||
|
|
|
@ -126,8 +126,6 @@ protected:
|
|||
const nsCString& altDataType) override;
|
||||
mozilla::ipc::IPCResult RecvOnTransportAndData(const nsresult& channelStatus,
|
||||
const nsresult& status,
|
||||
const uint64_t& progress,
|
||||
const uint64_t& progressMax,
|
||||
const uint64_t& offset,
|
||||
const uint32_t& count,
|
||||
const nsCString& data) override;
|
||||
|
@ -309,8 +307,6 @@ private:
|
|||
const uint32_t& count);
|
||||
void OnTransportAndData(const nsresult& channelStatus,
|
||||
const nsresult& status,
|
||||
const uint64_t progress,
|
||||
const uint64_t& progressMax,
|
||||
const uint64_t& offset,
|
||||
const uint32_t& count,
|
||||
const nsCString& data);
|
||||
|
|
|
@ -52,9 +52,7 @@ HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding,
|
|||
nsILoadContext* aLoadContext,
|
||||
PBOverrideStatus aOverrideStatus)
|
||||
: mIPCClosed(false)
|
||||
, mStoredStatus(NS_OK)
|
||||
, mStoredProgress(0)
|
||||
, mStoredProgressMax(0)
|
||||
, mIgnoreProgress(false)
|
||||
, mSentRedirect1Begin(false)
|
||||
, mSentRedirect1BeginFailed(false)
|
||||
, mReceivedRedirect2Verify(false)
|
||||
|
@ -1257,6 +1255,10 @@ HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
|||
nsresult channelStatus = NS_OK;
|
||||
mChannel->GetStatus(&channelStatus);
|
||||
|
||||
nsresult transportStatus =
|
||||
(mChannel->IsReadingFromCache()) ? NS_NET_STATUS_READING
|
||||
: NS_NET_STATUS_RECEIVING_FROM;
|
||||
|
||||
static uint32_t const kCopyChunkSize = 128 * 1024;
|
||||
uint32_t toRead = std::min<uint32_t>(aCount, kCopyChunkSize);
|
||||
|
||||
|
@ -1272,12 +1274,7 @@ HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// OnDataAvailable is always preceded by OnStatus/OnProgress calls that set
|
||||
// mStoredStatus/mStoredProgress(Max) to appropriate values, unless
|
||||
// LOAD_BACKGROUND set. In that case, they'll have garbage values, but
|
||||
// child doesn't use them.
|
||||
if (mIPCClosed || !SendOnTransportAndData(channelStatus, mStoredStatus,
|
||||
mStoredProgress, mStoredProgressMax,
|
||||
if (mIPCClosed || !SendOnTransportAndData(channelStatus, transportStatus,
|
||||
aOffset, toRead, data)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -1300,19 +1297,17 @@ HttpChannelParent::OnProgress(nsIRequest *aRequest,
|
|||
int64_t aProgress,
|
||||
int64_t aProgressMax)
|
||||
{
|
||||
// OnStatus has always just set mStoredStatus. If it indicates this precedes
|
||||
// OnDataAvailable, store and ODA will send to child.
|
||||
if (mStoredStatus == NS_NET_STATUS_RECEIVING_FROM ||
|
||||
mStoredStatus == NS_NET_STATUS_READING)
|
||||
{
|
||||
mStoredProgress = aProgress;
|
||||
mStoredProgressMax = aProgressMax;
|
||||
} else {
|
||||
// Send OnProgress events to the child for data upload progress notifications
|
||||
// (i.e. status == NS_NET_STATUS_SENDING_TO) or if the channel has
|
||||
// LOAD_BACKGROUND set.
|
||||
if (mIPCClosed || !SendOnProgress(aProgress, aProgressMax))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
// If it indicates this precedes OnDataAvailable, child can derive the value in ODA.
|
||||
if (mIgnoreProgress) {
|
||||
mIgnoreProgress = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Send OnProgress events to the child for data upload progress notifications
|
||||
// (i.e. status == NS_NET_STATUS_SENDING_TO) or if the channel has
|
||||
// LOAD_BACKGROUND set.
|
||||
if (mIPCClosed || !SendOnProgress(aProgress, aProgressMax)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1324,16 +1319,21 @@ HttpChannelParent::OnStatus(nsIRequest *aRequest,
|
|||
nsresult aStatus,
|
||||
const char16_t *aStatusArg)
|
||||
{
|
||||
// If this precedes OnDataAvailable, store and ODA will send to child.
|
||||
// If this precedes OnDataAvailable, transportStatus will be derived in ODA.
|
||||
if (aStatus == NS_NET_STATUS_RECEIVING_FROM ||
|
||||
aStatus == NS_NET_STATUS_READING)
|
||||
{
|
||||
mStoredStatus = aStatus;
|
||||
aStatus == NS_NET_STATUS_READING) {
|
||||
// The transport status and progress generated by ODA will be coalesced
|
||||
// into one IPC message. Therefore, we can ignore the next OnProgress event
|
||||
// since it is generated by ODA as well.
|
||||
mIgnoreProgress = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, send to child now
|
||||
if (mIPCClosed || !SendOnStatus(aStatus))
|
||||
if (mIPCClosed || !SendOnStatus(aStatus)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -221,11 +221,10 @@ private:
|
|||
|
||||
nsAutoPtr<class nsHttpChannel::OfflineCacheEntryAsForeignMarker> mOfflineForeignMarker;
|
||||
|
||||
// state for combining OnStatus/OnProgress with OnDataAvailable
|
||||
// into one IPDL call to child.
|
||||
nsresult mStoredStatus;
|
||||
int64_t mStoredProgress;
|
||||
int64_t mStoredProgressMax;
|
||||
// OnStatus is always called before OnProgress.
|
||||
// Set true in OnStatus if next OnProgress can be ignored
|
||||
// since the information can be recontructed from ODA.
|
||||
bool mIgnoreProgress : 1;
|
||||
|
||||
bool mSentRedirect1Begin : 1;
|
||||
bool mSentRedirect1BeginFailed : 1;
|
||||
|
|
|
@ -113,8 +113,6 @@ child:
|
|||
// OnStatus calls into one IPDL message
|
||||
async OnTransportAndData(nsresult channelStatus,
|
||||
nsresult transportStatus,
|
||||
uint64_t progress,
|
||||
uint64_t progressMax,
|
||||
uint64_t offset,
|
||||
uint32_t count,
|
||||
nsCString data);
|
||||
|
|
|
@ -277,6 +277,7 @@ nsHttpChannel::nsHttpChannel()
|
|||
, mPushedStream(nullptr)
|
||||
, mLocalBlocklist(false)
|
||||
, mWarningReporter(nullptr)
|
||||
, mIsReadingFromCache(false)
|
||||
, mDidReval(false)
|
||||
{
|
||||
LOG(("Creating nsHttpChannel [this=%p]\n", this));
|
||||
|
@ -6943,6 +6944,8 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
|
|||
return input->ReadSegments(NS_DiscardSegment, nullptr, count, &n);
|
||||
}
|
||||
|
||||
mIsReadingFromCache = (request == mCachePump);
|
||||
|
||||
if (mListener) {
|
||||
//
|
||||
// synthesize transport progress event. we do this here since we want
|
||||
|
|
|
@ -267,6 +267,10 @@ public: /* internal necko use only */
|
|||
bool AwaitingCacheCallbacks();
|
||||
void SetCouldBeSynthesized();
|
||||
|
||||
// Return true if the latest ODA is invoked by mCachePump.
|
||||
// Should only be called on the same thread as ODA.
|
||||
bool IsReadingFromCache() const { return mIsReadingFromCache; }
|
||||
|
||||
private: // used for alternate service validation
|
||||
RefPtr<TransactionObserver> mTransactionObserver;
|
||||
public:
|
||||
|
@ -597,6 +601,10 @@ private:
|
|||
HttpChannelSecurityWarningReporter* mWarningReporter;
|
||||
|
||||
RefPtr<ADivertableParentChannel> mParentChannel;
|
||||
|
||||
// True if the channel is reading from cache.
|
||||
Atomic<bool> mIsReadingFromCache;
|
||||
|
||||
protected:
|
||||
virtual void DoNotifyListenerCleanup() override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче