Backed out changeset d91e4acdd63c (bug 1551306) for causing bustages in request::InitBitsRequest

CLOSED TREE
This commit is contained in:
Mihai Alexandru Michis 2020-03-27 16:12:47 +02:00
Родитель 247c78b71a
Коммит c1256a18a6
25 изменённых файлов: 101 добавлений и 57 удалений

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

@ -435,12 +435,12 @@ appUpdater.prototype = {
/**
* See nsIProgressEventSink.idl
*/
onStatus(aRequest, aStatus, aStatusArg) {},
onStatus(aRequest, aContext, aStatus, aStatusArg) {},
/**
* See nsIProgressEventSink.idl
*/
onProgress(aRequest, aProgress, aProgressMax) {
onProgress(aRequest, aContext, aProgress, aProgressMax) {
this.downloadStatus.textContent = DownloadUtils.getTransferTotal(
aProgress,
aProgressMax

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

@ -339,12 +339,12 @@ class AppUpdater {
/**
* See nsIProgressEventSink.idl
*/
onStatus(aRequest, aStatus, aStatusArg) {}
onStatus(aRequest, aContext, aStatus, aStatusArg) {}
/**
* See nsIProgressEventSink.idl
*/
onProgress(aRequest, aProgress, aProgressMax) {
onProgress(aRequest, aContext, aProgress, aProgressMax) {
this._setStatus(AppUpdater.STATUS.DOWNLOADING, aProgress, aProgressMax);
}

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

@ -379,7 +379,7 @@ NetworkResponseListener.prototype = {
* Handle progress event as data is transferred. This is used to record the
* size on the wire, which may be compressed / encoded.
*/
onProgress: function(request, progress, progressMax) {
onProgress: function(request, context, progress, progressMax) {
this.transferredSize = progress;
// Need to forward as well to keep things like Download Manager's progress
// bar working properly.

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

@ -226,6 +226,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest* request) {
}
NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest* request,
nsISupports* aContext,
int64_t aProgress,
int64_t aProgressMax) {
nsresult rv = NS_OK;
@ -233,6 +234,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest* request,
}
NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest* request,
nsISupports* aContext,
nsresult aStatus,
const char16_t* aStatusArg) {
return NS_OK;

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

@ -976,6 +976,7 @@ nsWebBrowserPersist::OnDataAvailable(nsIRequest* request,
//*****************************************************************************
NS_IMETHODIMP nsWebBrowserPersist::OnProgress(nsIRequest* request,
nsISupports* ctxt,
int64_t aProgress,
int64_t aProgressMax) {
if (!mProgressListener) {
@ -1012,14 +1013,14 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(nsIRequest* request,
// If our progress listener implements nsIProgressEventSink,
// forward the notification
if (mEventSink) {
mEventSink->OnProgress(request, aProgress, aProgressMax);
mEventSink->OnProgress(request, ctxt, aProgress, aProgressMax);
}
return NS_OK;
}
NS_IMETHODIMP nsWebBrowserPersist::OnStatus(nsIRequest* request,
nsresult status,
nsISupports* ctxt, nsresult status,
const char16_t* statusArg) {
if (mProgressListener) {
// We need to filter out non-error error codes.
@ -1050,7 +1051,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnStatus(nsIRequest* request,
// If our progress listener implements nsIProgressEventSink,
// forward the notification
if (mEventSink) {
mEventSink->OnStatus(request, status, statusArg);
mEventSink->OnStatus(request, ctxt, status, statusArg);
}
return NS_OK;

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

@ -3277,7 +3277,8 @@ nsresult XMLHttpRequestMainThread::OnRedirectVerifyCallback(nsresult result) {
//
NS_IMETHODIMP
XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest, int64_t aProgress,
XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest,
nsISupports* aContext, int64_t aProgress,
int64_t aProgressMax) {
// When uploading, OnProgress reports also headers in aProgress and
// aProgressMax. So, try to remove the headers, if possible.
@ -3302,17 +3303,18 @@ XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest, int64_t aProgress,
}
if (mProgressEventSink) {
mProgressEventSink->OnProgress(aRequest, aProgress, aProgressMax);
mProgressEventSink->OnProgress(aRequest, aContext, aProgress, aProgressMax);
}
return NS_OK;
}
NS_IMETHODIMP
XMLHttpRequestMainThread::OnStatus(nsIRequest* aRequest, nsresult aStatus,
XMLHttpRequestMainThread::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult aStatus,
const char16_t* aStatusArg) {
if (mProgressEventSink) {
mProgressEventSink->OnStatus(aRequest, aStatus, aStatusArg);
mProgressEventSink->OnStatus(aRequest, aContext, aStatus, aStatusArg);
}
return NS_OK;

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

@ -549,8 +549,8 @@ NS_IMPL_ISUPPORTS(nsProgressNotificationProxy, nsIProgressEventSink,
nsIChannelEventSink, nsIInterfaceRequestor)
NS_IMETHODIMP
nsProgressNotificationProxy::OnProgress(nsIRequest* request, int64_t progress,
int64_t progressMax) {
nsProgressNotificationProxy::OnProgress(nsIRequest* request, nsISupports* ctxt,
int64_t progress, int64_t progressMax) {
nsCOMPtr<nsILoadGroup> loadGroup;
request->GetLoadGroup(getter_AddRefs(loadGroup));
@ -561,11 +561,12 @@ nsProgressNotificationProxy::OnProgress(nsIRequest* request, int64_t progress,
if (!target) {
return NS_OK;
}
return target->OnProgress(mImageRequest, progress, progressMax);
return target->OnProgress(mImageRequest, ctxt, progress, progressMax);
}
NS_IMETHODIMP
nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsresult status,
nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsISupports* ctxt,
nsresult status,
const char16_t* statusArg) {
nsCOMPtr<nsILoadGroup> loadGroup;
request->GetLoadGroup(getter_AddRefs(loadGroup));
@ -577,7 +578,7 @@ nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsresult status,
if (!target) {
return NS_OK;
}
return target->OnStatus(mImageRequest, status, statusArg);
return target->OnStatus(mImageRequest, ctxt, status, statusArg);
}
NS_IMETHODIMP

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

@ -532,7 +532,7 @@ void nsJARChannel::FireOnProgress(uint64_t aProgress) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mProgressSink);
mProgressSink->OnProgress(this, aProgress, mContentLength);
mProgressSink->OnProgress(this, nullptr, aProgress, mContentLength);
}
//-----------------------------------------------------------------------------

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

@ -757,12 +757,12 @@ nsBaseChannel::OnTransportStatus(nsITransport* transport, nsresult status,
if (!HasLoadFlag(LOAD_BACKGROUND)) {
nsAutoString statusArg;
if (GetStatusArg(status, statusArg)) {
mProgressSink->OnStatus(this, status, statusArg.get());
mProgressSink->OnStatus(this, nullptr, status, statusArg.get());
}
}
if (progress) {
mProgressSink->OnProgress(this, progress, progressMax);
mProgressSink->OnProgress(this, nullptr, progress, progressMax);
}
return NS_OK;

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

@ -36,6 +36,9 @@ interface nsIProgressEventSink : nsISupports
*
* @param aRequest
* the request being observed (may QI to nsIChannel).
* @param aContext
* if aRequest is a channel, then this parameter is the listener
* context passed to nsIChannel::asyncOpen.
* @param aProgress
* numeric value in the range 0 to aProgressMax indicating the
* number of bytes transfered thus far.
@ -44,6 +47,7 @@ interface nsIProgressEventSink : nsISupports
* transfered (or -1 if total is unknown).
*/
void onProgress(in nsIRequest aRequest,
in nsISupports aContext,
in long long aProgress,
in long long aProgressMax);
@ -53,6 +57,9 @@ interface nsIProgressEventSink : nsISupports
*
* @param aRequest
* the request being observed (may QI to nsIChannel).
* @param aContext
* if aRequest is a channel, then this parameter is the listener
* context passed to nsIChannel::asyncOpen.
* @param aStatus
* status code (not necessarily an error code) indicating the
* state of the channel (usually the state of the underlying
@ -66,6 +73,7 @@ interface nsIProgressEventSink : nsISupports
* indicates the host:port associated with the status code.
*/
void onStatus(in nsIRequest aRequest,
in nsISupports aContext,
in nsresult aStatus,
in wstring aStatusArg);

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

@ -115,6 +115,7 @@ class nsIncrementalDownload final : public nsIIncrementalDownload,
nsresult ClearRequestHeader(nsIHttpChannel* channel);
nsCOMPtr<nsIRequestObserver> mObserver;
nsCOMPtr<nsISupports> mObserverContext;
nsCOMPtr<nsIProgressEventSink> mProgressSink;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mFinalURI;
@ -173,7 +174,8 @@ void nsIncrementalDownload::UpdateProgress() {
mLastProgressUpdate = PR_Now();
if (mProgressSink)
mProgressSink->OnProgress(this, mCurrentSize + mChunkLen, mTotalSize);
mProgressSink->OnProgress(this, mObserverContext, mCurrentSize + mChunkLen,
mTotalSize);
}
nsresult nsIncrementalDownload::CallOnStartRequest() {
@ -194,6 +196,7 @@ void nsIncrementalDownload::CallOnStopRequest() {
mObserver->OnStopRequest(this, mStatus);
mObserver = nullptr;
mObserverContext = nullptr;
}
nsresult nsIncrementalDownload::StartTimer(int32_t interval) {
@ -465,6 +468,7 @@ nsIncrementalDownload::Start(nsIRequestObserver* observer,
if (NS_FAILED(rv)) return rv;
mObserver = observer;
mObserverContext = context;
mProgressSink = do_QueryInterface(observer); // ok if null
mIsPending = true;

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

@ -89,8 +89,8 @@ InterceptStreamListener::OnStartRequest(nsIRequest* aRequest) {
}
NS_IMETHODIMP
InterceptStreamListener::OnStatus(nsIRequest* aRequest, nsresult status,
const char16_t* aStatusArg) {
InterceptStreamListener::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult status, const char16_t* aStatusArg) {
if (mOwner) {
mOwner->DoOnStatus(mOwner, status);
}
@ -98,8 +98,8 @@ InterceptStreamListener::OnStatus(nsIRequest* aRequest, nsresult status,
}
NS_IMETHODIMP
InterceptStreamListener::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
InterceptStreamListener::OnProgress(nsIRequest* aRequest, nsISupports* aContext,
int64_t aProgress, int64_t aProgressMax) {
if (mOwner) {
mOwner->DoOnProgress(mOwner, aProgress, aProgressMax);
}
@ -124,10 +124,11 @@ InterceptStreamListener::OnDataAvailable(nsIRequest* aRequest,
nsAutoCString host;
uri->GetHost(host);
OnStatus(mOwner, NS_NET_STATUS_READING, NS_ConvertUTF8toUTF16(host).get());
OnStatus(mOwner, nullptr, NS_NET_STATUS_READING,
NS_ConvertUTF8toUTF16(host).get());
int64_t progress = aOffset + aCount;
OnProgress(mOwner, progress, mOwner->mSynthesizedStreamLength);
OnProgress(mOwner, nullptr, progress, mOwner->mSynthesizedStreamLength);
}
mOwner->DoOnDataAvailable(mOwner, nullptr, aInputStream, aOffset, aCount);
@ -929,7 +930,7 @@ void HttpChannelChild::DoOnStatus(nsIRequest* aRequest, nsresult status) {
!(mLoadFlags & LOAD_BACKGROUND)) {
nsAutoCString host;
mURI->GetHost(host);
mProgressSink->OnStatus(aRequest, status,
mProgressSink->OnStatus(aRequest, nullptr, status,
NS_ConvertUTF8toUTF16(host).get());
}
}
@ -950,7 +951,7 @@ void HttpChannelChild::DoOnProgress(nsIRequest* aRequest, int64_t progress,
// OnProgress
//
if (progress > 0) {
mProgressSink->OnProgress(aRequest, progress, progressMax);
mProgressSink->OnProgress(aRequest, nullptr, progress, progressMax);
}
}
}

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

@ -1835,8 +1835,8 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvOpenAltDataCacheInputStream(
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpChannelParent::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
HttpChannelParent::OnProgress(nsIRequest* aRequest, nsISupports* aContext,
int64_t aProgress, int64_t aProgressMax) {
LOG(("HttpChannelParent::OnProgress [this=%p progress=%" PRId64 "max=%" PRId64
"]\n",
this, aProgress, aProgressMax));
@ -1865,8 +1865,8 @@ HttpChannelParent::OnProgress(nsIRequest* aRequest, int64_t aProgress,
}
NS_IMETHODIMP
HttpChannelParent::OnStatus(nsIRequest* aRequest, nsresult aStatus,
const char16_t* aStatusArg) {
HttpChannelParent::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult aStatus, const char16_t* aStatusArg) {
LOG(("HttpChannelParent::OnStatus [this=%p status=%" PRIx32 "]\n", this,
static_cast<uint32_t>(aStatus)));
MOZ_ASSERT(NS_IsMainThread());

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

@ -414,9 +414,10 @@ void InterceptedHttpChannel::MaybeCallStatusAndProgress() {
CopyUTF8toUTF16(host, mStatusHost);
}
mProgressSink->OnStatus(this, NS_NET_STATUS_READING, mStatusHost.get());
mProgressSink->OnStatus(this, nullptr, NS_NET_STATUS_READING,
mStatusHost.get());
mProgressSink->OnProgress(this, progress, mSynthesizedStreamLength);
mProgressSink->OnProgress(this, nullptr, progress, mSynthesizedStreamLength);
mProgressReported = progress;
}

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

@ -8659,7 +8659,8 @@ nsHttpChannel::OnTransportStatus(nsITransport* trans, nsresult status,
nsAutoCString host;
mURI->GetHost(host);
if (!(mLoadFlags & LOAD_BACKGROUND)) {
mProgressSink->OnStatus(this, status, NS_ConvertUTF8toUTF16(host).get());
mProgressSink->OnStatus(this, nullptr, status,
NS_ConvertUTF8toUTF16(host).get());
} else {
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(this, parentChannel);
@ -8670,7 +8671,7 @@ nsHttpChannel::OnTransportStatus(nsITransport* trans, nsresult status,
// LOAD_BACKGROUND is checked again in |HttpChannelChild|, so the final
// consumer won't get this event.
if (SameCOMIdentity(parentChannel, mProgressSink)) {
mProgressSink->OnStatus(this, status,
mProgressSink->OnStatus(this, nullptr, status,
NS_ConvertUTF8toUTF16(host).get());
}
}
@ -8685,7 +8686,7 @@ nsHttpChannel::OnTransportStatus(nsITransport* trans, nsresult status,
GetCallback(mProgressSink);
}
if (mProgressSink) {
mProgressSink->OnProgress(this, progress, progressMax);
mProgressSink->OnProgress(this, nullptr, progress, progressMax);
}
}
}

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

@ -45,14 +45,14 @@ var listenerCallback = {
throw Cr.NS_ERROR_NO_INTERFACE;
},
onProgress(request, progress, progressMax) {
onProgress(request, context, progress, progressMax) {
// this works because the response is 0 bytes and does not trigger onprogress
if (progress === progressMax) {
correctOnProgress = true;
}
},
onStatus(request, status, statusArg) {},
onStatus(request, context, status, statusArg) {},
};
function run_test() {

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

@ -68,7 +68,7 @@ var progressCallback = {
delete this._listener;
},
onProgress(request, progress, progressMax) {
onProgress(request, context, progress, progressMax) {
Assert.equal(this._last_callback_handled, TYPE_ONSTATUS);
this._last_callback_handled = TYPE_ONPROGRESS;
@ -77,7 +77,7 @@ var progressCallback = {
max = progressMax;
},
onStatus(request, status, statusArg) {
onStatus(request, context, status, statusArg) {
if (!this._got_onstartrequest) {
// Ensure that all messages before onStartRequest are onStatus
if (this._last_callback_handled) {

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

@ -51,10 +51,10 @@ function make_channel(url, body, cb) {
getInterface(iid) {
return this.QueryInterface(iid);
},
onProgress(request, progress, progressMax) {
onProgress(request, context, progress, progressMax) {
gotOnProgress = true;
},
onStatus(request, status, statusArg) {
onStatus(request, context, status, statusArg) {
gotOnStatus = true;
},
shouldPrepareForIntercept() {

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

@ -648,6 +648,7 @@ async function servicePromise(errorAction, observer, actionFn) {
},
onProgress: function wrappedObserver_onProgress(
request,
context,
progress,
progressMax
) {
@ -655,15 +656,20 @@ async function servicePromise(errorAction, observer, actionFn) {
if (!wrappedRequest) {
wrappedRequest = new BitsRequest(request);
}
observer.onProgress(wrappedRequest, progress, progressMax);
observer.onProgress(wrappedRequest, context, progress, progressMax);
}
},
onStatus: function wrappedObserver_onStatus(request, status, statusArg) {
onStatus: function wrappedObserver_onStatus(
request,
context,
status,
statusArg
) {
if (isProgressEventSink) {
if (!wrappedRequest) {
wrappedRequest = new BitsRequest(request);
}
observer.onStatus(wrappedRequest, status, statusArg);
observer.onStatus(wrappedRequest, context, status, statusArg);
}
},
QueryInterface: ChromeUtils.generateQI([

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

@ -104,6 +104,7 @@ pub struct InitBitsRequest {
monitor_thread: Cell<Option<RefPtr<nsIThread>>>,
monitor_timeout_ms: u32,
observer: RefPtr<nsIRequestObserver>,
context: Option<RefPtr<nsISupports>>,
// started indicates whether or not OnStartRequest has been fired.
started: Cell<bool>,
// finished indicates whether or not we have called
@ -241,9 +242,14 @@ impl BitsRequest {
pub fn on_progress(&self, transferred_bytes: i64, total_bytes: i64) {
if let Some(progress_event_sink) = self.observer.query_interface::<nsIProgressEventSink>() {
let context: *const nsISupports = match self.context.as_ref() {
Some(context) => &**context,
None => ptr::null(),
};
unsafe {
progress_event_sink.OnProgress(
self.coerce(),
context,
transferred_bytes,
total_bytes,
);

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

@ -2052,6 +2052,7 @@ DownloadCopySaver.prototype = {
getInterface: ChromeUtils.generateQI([Ci.nsIProgressEventSink]),
onProgress: function DCSE_onProgress(
aRequest,
aContext,
aProgress,
aProgressMax
) {

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

@ -190,8 +190,8 @@ loadListener.prototype = {
},
// nsIProgressEventSink
onProgress(request, progress, progressMax) {},
onStatus(request, status, statusArg) {},
onProgress(request, context, progress, progressMax) {},
onStatus(request, context, status, statusArg) {},
};
/**

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

@ -4838,12 +4838,19 @@ Downloader.prototype = {
* When new data has been downloaded
* @param request
* The nsIRequest object for the transfer
* @param context
* Additional data
* @param progress
* The current number of bytes transferred
* @param maxProgress
* The total number of bytes that must be transferred
*/
onProgress: function Downloader_onProgress(request, progress, maxProgress) {
onProgress: function Downloader_onProgress(
request,
context,
progress,
maxProgress
) {
LOG("Downloader:onProgress - progress: " + progress + "/" + maxProgress);
if (progress > this._patch.size) {
@ -4885,7 +4892,7 @@ Downloader.prototype = {
for (var i = 0; i < listenerCount; ++i) {
var listener = listeners[i];
if (listener instanceof Ci.nsIProgressEventSink) {
listener.onProgress(request, progress, maxProgress);
listener.onProgress(request, context, progress, maxProgress);
}
}
this.updateService._consecutiveSocketErrors = 0;
@ -4895,12 +4902,14 @@ Downloader.prototype = {
* When we have new status text
* @param request
* The nsIRequest object for the transfer
* @param context
* Additional data
* @param status
* A status code
* @param statusText
* Human readable version of |status|
*/
onStatus: function Downloader_onStatus(request, status, statusText) {
onStatus: function Downloader_onStatus(request, context, status, statusText) {
LOG(
"Downloader:onStatus - status: " + status + ", statusText: " + statusText
);
@ -4911,7 +4920,7 @@ Downloader.prototype = {
for (var i = 0; i < listenerCount; ++i) {
var listener = listeners[i];
if (listener instanceof Ci.nsIProgressEventSink) {
listener.onStatus(request, status, statusText);
listener.onStatus(request, context, status, statusText);
}
}
},

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

@ -4064,7 +4064,7 @@ function waitForUpdateDownload(aUpdates, aExpectedStatus) {
gAUS.addDownloadListener({
onStartRequest: aRequest => {},
onProgress: (aRequest, aContext, aProgress, aMaxProgress) => {},
onStatus: (aRequest, aStatus, aStatusText) => {},
onStatus: (aRequest, aContext, aStatus, aStatusText) => {},
onStopRequest: (request, status) => {
gAUS.removeDownloadListener(this);
Assert.equal(

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

@ -1071,8 +1071,8 @@ int64_t nsDocLoader::GetMaxTotalProgress() {
// on this information.
////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest* aRequest, nsISupports* ctxt,
int64_t aProgress, int64_t aProgressMax) {
int64_t progressDelta = 0;
//
@ -1167,7 +1167,8 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest* aRequest, int64_t aProgress,
return NS_OK;
}
NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsresult aStatus,
NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt,
nsresult aStatus,
const char16_t* aStatusArg) {
//
// Fire progress notifications out to any registered nsIWebProgressListeners