Skip to content

Commit

Permalink
Bug 1551306 - Remove context parameter from nsIProgressEventSink.onPr…
Browse files Browse the repository at this point in the history
…ogress() and nsIProgressEventSink.onStatus() r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D68235
  • Loading branch information
sonakshisaxena1 committed Mar 27, 2020
1 parent 5142ec6 commit da81dcd
Show file tree
Hide file tree
Showing 25 changed files with 57 additions and 101 deletions.
4 changes: 2 additions & 2 deletions browser/base/content/aboutDialog-appUpdater-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,12 @@ appUpdater.prototype = {
/**
* See nsIProgressEventSink.idl
*/
onStatus(aRequest, aContext, aStatus, aStatusArg) {},
onStatus(aRequest, aStatus, aStatusArg) {},

/**
* See nsIProgressEventSink.idl
*/
onProgress(aRequest, aContext, aProgress, aProgressMax) {
onProgress(aRequest, aProgress, aProgressMax) {
this.downloadStatus.textContent = DownloadUtils.getTransferTotal(
aProgress,
aProgressMax
Expand Down
4 changes: 2 additions & 2 deletions browser/modules/AppUpdater.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ class AppUpdater {
/**
* See nsIProgressEventSink.idl
*/
onStatus(aRequest, aContext, aStatus, aStatusArg) {}
onStatus(aRequest, aStatus, aStatusArg) {}

/**
* See nsIProgressEventSink.idl
*/
onProgress(aRequest, aContext, aProgress, aProgressMax) {
onProgress(aRequest, aProgress, aProgressMax) {
this._setStatus(AppUpdater.STATUS.DOWNLOADING, aProgress, aProgressMax);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, context, progress, progressMax) {
onProgress: function(request, progress, progressMax) {
this.transferredSize = progress;
// Need to forward as well to keep things like Download Manager's progress
// bar working properly.
Expand Down
2 changes: 0 additions & 2 deletions dom/plugins/base/nsPluginStreamListenerPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,13 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest* request) {
}

NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest* request,
nsISupports* aContext,
int64_t aProgress,
int64_t aProgressMax) {
nsresult rv = NS_OK;
return rv;
}

NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest* request,
nsISupports* aContext,
nsresult aStatus,
const char16_t* aStatusArg) {
return NS_OK;
Expand Down
7 changes: 3 additions & 4 deletions dom/webbrowserpersist/nsWebBrowserPersist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ nsWebBrowserPersist::OnDataAvailable(nsIRequest* request,
//*****************************************************************************

NS_IMETHODIMP nsWebBrowserPersist::OnProgress(nsIRequest* request,
nsISupports* ctxt,
int64_t aProgress,
int64_t aProgressMax) {
if (!mProgressListener) {
Expand Down Expand Up @@ -1013,14 +1012,14 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(nsIRequest* request,
// If our progress listener implements nsIProgressEventSink,
// forward the notification
if (mEventSink) {
mEventSink->OnProgress(request, ctxt, aProgress, aProgressMax);
mEventSink->OnProgress(request, aProgress, aProgressMax);
}

return NS_OK;
}

NS_IMETHODIMP nsWebBrowserPersist::OnStatus(nsIRequest* request,
nsISupports* ctxt, nsresult status,
nsresult status,
const char16_t* statusArg) {
if (mProgressListener) {
// We need to filter out non-error error codes.
Expand Down Expand Up @@ -1051,7 +1050,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnStatus(nsIRequest* request,
// If our progress listener implements nsIProgressEventSink,
// forward the notification
if (mEventSink) {
mEventSink->OnStatus(request, ctxt, status, statusArg);
mEventSink->OnStatus(request, status, statusArg);
}

return NS_OK;
Expand Down
10 changes: 4 additions & 6 deletions dom/xhr/XMLHttpRequestMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3277,8 +3277,7 @@ nsresult XMLHttpRequestMainThread::OnRedirectVerifyCallback(nsresult result) {
//

NS_IMETHODIMP
XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest,
nsISupports* aContext, int64_t aProgress,
XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
// When uploading, OnProgress reports also headers in aProgress and
// aProgressMax. So, try to remove the headers, if possible.
Expand All @@ -3303,18 +3302,17 @@ XMLHttpRequestMainThread::OnProgress(nsIRequest* aRequest,
}

if (mProgressEventSink) {
mProgressEventSink->OnProgress(aRequest, aContext, aProgress, aProgressMax);
mProgressEventSink->OnProgress(aRequest, aProgress, aProgressMax);
}

return NS_OK;
}

NS_IMETHODIMP
XMLHttpRequestMainThread::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult aStatus,
XMLHttpRequestMainThread::OnStatus(nsIRequest* aRequest, nsresult aStatus,
const char16_t* aStatusArg) {
if (mProgressEventSink) {
mProgressEventSink->OnStatus(aRequest, aContext, aStatus, aStatusArg);
mProgressEventSink->OnStatus(aRequest, aStatus, aStatusArg);
}

return NS_OK;
Expand Down
11 changes: 5 additions & 6 deletions image/imgLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ NS_IMPL_ISUPPORTS(nsProgressNotificationProxy, nsIProgressEventSink,
nsIChannelEventSink, nsIInterfaceRequestor)

NS_IMETHODIMP
nsProgressNotificationProxy::OnProgress(nsIRequest* request, nsISupports* ctxt,
int64_t progress, int64_t progressMax) {
nsProgressNotificationProxy::OnProgress(nsIRequest* request, int64_t progress,
int64_t progressMax) {
nsCOMPtr<nsILoadGroup> loadGroup;
request->GetLoadGroup(getter_AddRefs(loadGroup));

Expand All @@ -561,12 +561,11 @@ nsProgressNotificationProxy::OnProgress(nsIRequest* request, nsISupports* ctxt,
if (!target) {
return NS_OK;
}
return target->OnProgress(mImageRequest, ctxt, progress, progressMax);
return target->OnProgress(mImageRequest, progress, progressMax);
}

NS_IMETHODIMP
nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsISupports* ctxt,
nsresult status,
nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsresult status,
const char16_t* statusArg) {
nsCOMPtr<nsILoadGroup> loadGroup;
request->GetLoadGroup(getter_AddRefs(loadGroup));
Expand All @@ -578,7 +577,7 @@ nsProgressNotificationProxy::OnStatus(nsIRequest* request, nsISupports* ctxt,
if (!target) {
return NS_OK;
}
return target->OnStatus(mImageRequest, ctxt, status, statusArg);
return target->OnStatus(mImageRequest, status, statusArg);
}

NS_IMETHODIMP
Expand Down
2 changes: 1 addition & 1 deletion modules/libjar/nsJARChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void nsJARChannel::FireOnProgress(uint64_t aProgress) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mProgressSink);

mProgressSink->OnProgress(this, nullptr, aProgress, mContentLength);
mProgressSink->OnProgress(this, aProgress, mContentLength);
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions netwerk/base/nsBaseChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,12 @@ nsBaseChannel::OnTransportStatus(nsITransport* transport, nsresult status,
if (!HasLoadFlag(LOAD_BACKGROUND)) {
nsAutoString statusArg;
if (GetStatusArg(status, statusArg)) {
mProgressSink->OnStatus(this, nullptr, status, statusArg.get());
mProgressSink->OnStatus(this, status, statusArg.get());
}
}

if (progress) {
mProgressSink->OnProgress(this, nullptr, progress, progressMax);
mProgressSink->OnProgress(this, progress, progressMax);
}

return NS_OK;
Expand Down
8 changes: 0 additions & 8 deletions netwerk/base/nsIProgressEventSink.idl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ 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.
Expand All @@ -47,7 +44,6 @@ 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);

Expand All @@ -57,9 +53,6 @@ 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
Expand All @@ -73,7 +66,6 @@ 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);

Expand Down
6 changes: 1 addition & 5 deletions netwerk/base/nsIncrementalDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class nsIncrementalDownload final : public nsIIncrementalDownload,
nsresult ClearRequestHeader(nsIHttpChannel* channel);

nsCOMPtr<nsIRequestObserver> mObserver;
nsCOMPtr<nsISupports> mObserverContext;
nsCOMPtr<nsIProgressEventSink> mProgressSink;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mFinalURI;
Expand Down Expand Up @@ -174,8 +173,7 @@ void nsIncrementalDownload::UpdateProgress() {
mLastProgressUpdate = PR_Now();

if (mProgressSink)
mProgressSink->OnProgress(this, mObserverContext, mCurrentSize + mChunkLen,
mTotalSize);
mProgressSink->OnProgress(this, mCurrentSize + mChunkLen, mTotalSize);
}

nsresult nsIncrementalDownload::CallOnStartRequest() {
Expand All @@ -196,7 +194,6 @@ void nsIncrementalDownload::CallOnStopRequest() {

mObserver->OnStopRequest(this, mStatus);
mObserver = nullptr;
mObserverContext = nullptr;
}

nsresult nsIncrementalDownload::StartTimer(int32_t interval) {
Expand Down Expand Up @@ -468,7 +465,6 @@ nsIncrementalDownload::Start(nsIRequestObserver* observer,
if (NS_FAILED(rv)) return rv;

mObserver = observer;
mObserverContext = context;
mProgressSink = do_QueryInterface(observer); // ok if null

mIsPending = true;
Expand Down
17 changes: 8 additions & 9 deletions netwerk/protocol/http/HttpChannelChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ InterceptStreamListener::OnStartRequest(nsIRequest* aRequest) {
}

NS_IMETHODIMP
InterceptStreamListener::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult status, const char16_t* aStatusArg) {
InterceptStreamListener::OnStatus(nsIRequest* aRequest, nsresult status,
const char16_t* aStatusArg) {
if (mOwner) {
mOwner->DoOnStatus(mOwner, status);
}
return NS_OK;
}

NS_IMETHODIMP
InterceptStreamListener::OnProgress(nsIRequest* aRequest, nsISupports* aContext,
int64_t aProgress, int64_t aProgressMax) {
InterceptStreamListener::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
if (mOwner) {
mOwner->DoOnProgress(mOwner, aProgress, aProgressMax);
}
Expand All @@ -124,11 +124,10 @@ InterceptStreamListener::OnDataAvailable(nsIRequest* aRequest,
nsAutoCString host;
uri->GetHost(host);

OnStatus(mOwner, nullptr, NS_NET_STATUS_READING,
NS_ConvertUTF8toUTF16(host).get());
OnStatus(mOwner, NS_NET_STATUS_READING, NS_ConvertUTF8toUTF16(host).get());

int64_t progress = aOffset + aCount;
OnProgress(mOwner, nullptr, progress, mOwner->mSynthesizedStreamLength);
OnProgress(mOwner, progress, mOwner->mSynthesizedStreamLength);
}

mOwner->DoOnDataAvailable(mOwner, nullptr, aInputStream, aOffset, aCount);
Expand Down Expand Up @@ -930,7 +929,7 @@ void HttpChannelChild::DoOnStatus(nsIRequest* aRequest, nsresult status) {
!(mLoadFlags & LOAD_BACKGROUND)) {
nsAutoCString host;
mURI->GetHost(host);
mProgressSink->OnStatus(aRequest, nullptr, status,
mProgressSink->OnStatus(aRequest, status,
NS_ConvertUTF8toUTF16(host).get());
}
}
Expand All @@ -951,7 +950,7 @@ void HttpChannelChild::DoOnProgress(nsIRequest* aRequest, int64_t progress,
// OnProgress
//
if (progress > 0) {
mProgressSink->OnProgress(aRequest, nullptr, progress, progressMax);
mProgressSink->OnProgress(aRequest, progress, progressMax);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions netwerk/protocol/http/HttpChannelParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,8 +1835,8 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvOpenAltDataCacheInputStream(
//-----------------------------------------------------------------------------

NS_IMETHODIMP
HttpChannelParent::OnProgress(nsIRequest* aRequest, nsISupports* aContext,
int64_t aProgress, int64_t aProgressMax) {
HttpChannelParent::OnProgress(nsIRequest* aRequest, int64_t aProgress,
int64_t aProgressMax) {
LOG(("HttpChannelParent::OnProgress [this=%p progress=%" PRId64 "max=%" PRId64
"]\n",
this, aProgress, aProgressMax));
Expand Down Expand Up @@ -1865,8 +1865,8 @@ HttpChannelParent::OnProgress(nsIRequest* aRequest, nsISupports* aContext,
}

NS_IMETHODIMP
HttpChannelParent::OnStatus(nsIRequest* aRequest, nsISupports* aContext,
nsresult aStatus, const char16_t* aStatusArg) {
HttpChannelParent::OnStatus(nsIRequest* aRequest, nsresult aStatus,
const char16_t* aStatusArg) {
LOG(("HttpChannelParent::OnStatus [this=%p status=%" PRIx32 "]\n", this,
static_cast<uint32_t>(aStatus)));
MOZ_ASSERT(NS_IsMainThread());
Expand Down
5 changes: 2 additions & 3 deletions netwerk/protocol/http/InterceptedHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,9 @@ void InterceptedHttpChannel::MaybeCallStatusAndProgress() {
CopyUTF8toUTF16(host, mStatusHost);
}

mProgressSink->OnStatus(this, nullptr, NS_NET_STATUS_READING,
mStatusHost.get());
mProgressSink->OnStatus(this, NS_NET_STATUS_READING, mStatusHost.get());

mProgressSink->OnProgress(this, nullptr, progress, mSynthesizedStreamLength);
mProgressSink->OnProgress(this, progress, mSynthesizedStreamLength);

mProgressReported = progress;
}
Expand Down
7 changes: 3 additions & 4 deletions netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8659,8 +8659,7 @@ nsHttpChannel::OnTransportStatus(nsITransport* trans, nsresult status,
nsAutoCString host;
mURI->GetHost(host);
if (!(mLoadFlags & LOAD_BACKGROUND)) {
mProgressSink->OnStatus(this, nullptr, status,
NS_ConvertUTF8toUTF16(host).get());
mProgressSink->OnStatus(this, status, NS_ConvertUTF8toUTF16(host).get());
} else {
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(this, parentChannel);
Expand All @@ -8671,7 +8670,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, nullptr, status,
mProgressSink->OnStatus(this, status,
NS_ConvertUTF8toUTF16(host).get());
}
}
Expand All @@ -8686,7 +8685,7 @@ nsHttpChannel::OnTransportStatus(nsITransport* trans, nsresult status,
GetCallback(mProgressSink);
}
if (mProgressSink) {
mProgressSink->OnProgress(this, nullptr, progress, progressMax);
mProgressSink->OnProgress(this, progress, progressMax);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions netwerk/test/unit/test_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ var listenerCallback = {
throw Cr.NS_ERROR_NO_INTERFACE;
},

onProgress(request, context, progress, progressMax) {
onProgress(request, progress, progressMax) {
// this works because the response is 0 bytes and does not trigger onprogress
if (progress === progressMax) {
correctOnProgress = true;
}
},

onStatus(request, context, status, statusArg) {},
onStatus(request, status, statusArg) {},
};

function run_test() {
Expand Down
Loading

0 comments on commit da81dcd

Please sign in to comment.