зеркало из https://github.com/mozilla/pjs.git
Matthew Gregan - Bug 476813 - progress events shouldn't be fired while the network is stalled. r+ doublec sr+ roc
This commit is contained in:
Родитель
07a5871bd9
Коммит
3cdfbb6599
|
@ -343,8 +343,9 @@ protected:
|
|||
PRIntervalTime mProgressTime;
|
||||
|
||||
// Time that data was last read from the media resource. Used for
|
||||
// computing if the download has stalled. A value of 0 indicates that
|
||||
// a stall event has already fired and not to fire another one until
|
||||
// computing if the download has stalled and to rate limit progress events
|
||||
// when data is arriving slower than PROGRESS_MS. A value of 0 indicates
|
||||
// that a stall event has already fired and not to fire another one until
|
||||
// more data is received. Read/Write from the main thread only.
|
||||
PRIntervalTime mDataTime;
|
||||
|
||||
|
|
|
@ -154,24 +154,25 @@ void nsMediaDecoder::Progress(PRBool aTimer)
|
|||
return;
|
||||
|
||||
PRIntervalTime now = PR_IntervalNow();
|
||||
if (mProgressTime == 0 ||
|
||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mProgressTime) >= PROGRESS_MS) {
|
||||
|
||||
if (!aTimer) {
|
||||
mDataTime = now;
|
||||
}
|
||||
|
||||
PRUint32 progressDelta = PR_IntervalToMilliseconds(now - mProgressTime);
|
||||
PRUint32 networkDelta = PR_IntervalToMilliseconds(now - mDataTime);
|
||||
|
||||
// If PROGRESS_MS has passed since the last progress event fired and more
|
||||
// data has arrived since then, fire another progress event.
|
||||
if (progressDelta >= PROGRESS_MS && networkDelta <= PROGRESS_MS) {
|
||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
mProgressTime = now;
|
||||
}
|
||||
|
||||
// The test for aTimer is to ensure that we dispatch 'stalled'
|
||||
// only when we are not receiving data.
|
||||
if (aTimer &&
|
||||
mDataTime != 0 &&
|
||||
PR_IntervalToMilliseconds(now - mDataTime) >= STALL_MS) {
|
||||
if (mDataTime != 0 && networkDelta >= STALL_MS) {
|
||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("stalled"));
|
||||
mDataTime = 0;
|
||||
}
|
||||
|
||||
if (!aTimer) {
|
||||
mDataTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsMediaDecoder::StartProgress()
|
||||
|
|
Загрузка…
Ссылка в новой задаче