Skip to content

Commit

Permalink
Bug 1525319 - Removing context from OnDataAvailable r=valentin
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D20881

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Jonathan Kingston committed Feb 24, 2019
1 parent 147e351 commit 63ab2bd
Show file tree
Hide file tree
Showing 189 changed files with 270 additions and 315 deletions.
4 changes: 2 additions & 2 deletions browser/base/content/nsContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,10 +1148,10 @@ nsContextMenu.prototype = {
this.extListener.onStopRequest(aRequest, aStatusCode);
},

onDataAvailable: function saveLinkAs_onDataAvailable(aRequest, aContext,
onDataAvailable: function saveLinkAs_onDataAvailable(aRequest,
aInputStream,
aOffset, aCount) {
this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
this.extListener.onDataAvailable(aRequest, aInputStream,
aOffset, aCount);
},
};
Expand Down
10 changes: 5 additions & 5 deletions browser/extensions/pdfjs/content/PdfStreamConverter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ class ChromeActions {
sendResponse(false);
}
},
onDataAvailable(aRequest, aContext, aDataInputStream, aOffset, aCount) {
this.extListener.onDataAvailable(aRequest, aContext, aDataInputStream,
onDataAvailable(aRequest, aDataInputStream, aOffset, aCount) {
this.extListener.onDataAvailable(aRequest, aDataInputStream,
aOffset, aCount);
},
};
Expand Down Expand Up @@ -847,7 +847,7 @@ PdfStreamConverter.prototype = {
},

// nsIStreamListener::onDataAvailable
onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
onDataAvailable(aRequest, aInputStream, aOffset, aCount) {
if (!this.dataListener) {
return;
}
Expand Down Expand Up @@ -942,8 +942,8 @@ PdfStreamConverter.prototype = {
onStartRequest(request) {
listener.onStartRequest(aRequest);
},
onDataAvailable(request, context, inputStream, offset, count) {
listener.onDataAvailable(aRequest, null, inputStream,
onDataAvailable(request, inputStream, offset, count) {
listener.onDataAvailable(aRequest, inputStream,
offset, count);
},
onStopRequest(request, statusCode) {
Expand Down
2 changes: 1 addition & 1 deletion browser/modules/FaviconLoader.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class FaviconLoad {
onStartRequest(request) {
}

onDataAvailable(request, context, inputStream, offset, count) {
onDataAvailable(request, inputStream, offset, count) {
this.stream.writeFrom(inputStream, count);
}

Expand Down
4 changes: 2 additions & 2 deletions devtools/client/jsonview/converter-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Converter.prototype = {
this.listener = listener;
},

onDataAvailable: function(request, context, inputStream, offset, count) {
onDataAvailable: function(request, inputStream, offset, count) {
// Decode and insert data.
const buffer = new ArrayBuffer(count);
new BinaryInput(inputStream).readArrayBuffer(count, buffer);
Expand Down Expand Up @@ -117,7 +117,7 @@ Converter.prototype = {
// Send the initial HTML code.
const buffer = new TextEncoder().encode(initialHTML(win.document)).buffer;
const stream = new BufferStream(buffer, 0, buffer.byteLength);
this.listener.onDataAvailable(request, null, stream, 0, stream.available());
this.listener.onDataAvailable(request, stream, 0, stream.available());
},

onStopRequest: function(request, statusCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function gzipCompressString(string, obs) {
.createInstance(Ci.nsIStringInputStream);
stringStream.data = string;
converter.onStartRequest(null);
converter.onDataAvailable(null, null, stringStream, 0, string.length);
converter.onDataAvailable(null, stringStream, 0, string.length);
converter.onStopRequest(null, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ NetworkResponseListener.prototype = {
* @param unsigned long offset
* @param unsigned long count
*/
onDataAvailable: function(request, context, inputStream, offset, count) {
onDataAvailable: function(request, inputStream, offset, count) {
this._findOpenResponse();
const data = NetUtil.readInputStreamToString(inputStream, count);

Expand Down Expand Up @@ -490,10 +490,10 @@ NetworkResponseListener.prototype = {
if (available != -1) {
if (available != 0) {
if (this.converter) {
this.converter.onDataAvailable(this.request, null, stream,
this.converter.onDataAvailable(this.request, stream,
this.offset, available);
} else {
this.onDataAvailable(this.request, null, stream, this.offset,
this.onDataAvailable(this.request, stream, this.offset,
available);
}
}
Expand Down
4 changes: 2 additions & 2 deletions devtools/shared/webconsole/test/unit/test_throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TestStreamListener.prototype = {
this.setState("stop");
},

onDataAvailable: function(request, context, inputStream, offset, count) {
onDataAvailable: function(request, inputStream, offset, count) {
const sin = Cc["@mozilla.org/scriptableinputstream;1"]
.createInstance(nsIScriptableInputStream);
sin.init(inputStream);
Expand Down Expand Up @@ -125,7 +125,7 @@ add_task(async function() {
);

// onDataAvailable is required to immediately read the data.
listener.onDataAvailable(null, null, testInputStream, 0, 6);
listener.onDataAvailable(null, testInputStream, 0, 6);
equal(testInputStream.available(), 0, "no more data should be available");
equal(testListener.state, "start",
"test listener should not have received data");
Expand Down
8 changes: 4 additions & 4 deletions devtools/shared/webconsole/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ NetworkThrottleListener.prototype = {
/**
* @see nsIStreamListener.onDataAvailable.
*/
onDataAvailable: function(request, context, inputStream, offset, count) {
onDataAvailable: function(request, inputStream, offset, count) {
if (this.pendingException) {
throw this.pendingException;
}
Expand All @@ -87,7 +87,7 @@ NetworkThrottleListener.prototype = {
const stream = new ArrayBufferInputStream();
stream.setData(bytes, 0, count);

this.pendingData.push({request, context, stream, count});
this.pendingData.push({request, stream, count});
this.queue.dataAvailable(this);
},

Expand All @@ -110,7 +110,7 @@ NetworkThrottleListener.prototype = {
return {length: 0, done: true};
}

const {request, context, stream, count, statusCode} = this.pendingData[0];
const {request, stream, count, statusCode} = this.pendingData[0];

if (statusCode !== undefined) {
this.pendingData.shift();
Expand All @@ -123,7 +123,7 @@ NetworkThrottleListener.prototype = {
}

try {
this.originalListener.onDataAvailable(request, context, stream,
this.originalListener.onDataAvailable(request, stream,
this.offset, bytesPermitted);
} catch (e) {
this.pendingException = e;
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/nsPingListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ nsPingListener::OnStartRequest(nsIRequest* aRequest) {
}

NS_IMETHODIMP
nsPingListener::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
nsPingListener::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aStream, uint64_t aOffset,
uint32_t aCount) {
uint32_t result;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/DOMParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ already_AddRefed<Document> DOMParser::ParseFromStream(nsIInputStream* aStream,
parserChannel->GetStatus(&status);

if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
rv = listener->OnDataAvailable(parserChannel, nullptr, stream, 0,
rv = listener->OnDataAvailable(parserChannel, stream, 0,
aContentLength);
if (NS_FAILED(rv)) parserChannel->Cancel(rv);
parserChannel->GetStatus(&status);
Expand Down
3 changes: 1 addition & 2 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ nsresult ExternalResourceMap::PendingLoad::SetupViewer(

NS_IMETHODIMP
ExternalResourceMap::PendingLoad::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aStream,
uint64_t aOffset,
uint32_t aCount) {
Expand All @@ -990,7 +989,7 @@ ExternalResourceMap::PendingLoad::OnDataAvailable(nsIRequest* aRequest,
if (mDisplayDocument->ExternalResourceMap().HaveShutDown()) {
return NS_BINDING_ABORTED;
}
return mTargetListener->OnDataAvailable(aRequest, aContext, aStream, aOffset,
return mTargetListener->OnDataAvailable(aRequest, aStream, aOffset,
aCount);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/base/EventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void EventSourceImpl::ParseSegment(const char* aBuffer, uint32_t aLength) {
}

NS_IMETHODIMP
EventSourceImpl::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
EventSourceImpl::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aInputStream, uint64_t aOffset,
uint32_t aCount) {
AssertIsOnTargetThread();
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ BeaconStreamListener::OnStopRequest(nsIRequest* aRequest,
}

NS_IMETHODIMP
BeaconStreamListener::OnDataAvailable(nsIRequest* aRequest, nsISupports* ctxt,
BeaconStreamListener::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* inStr,
uint64_t sourceOffset, uint32_t count) {
MOZ_ASSERT(false);
Expand Down
3 changes: 1 addition & 2 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,6 @@ nsObjectLoadingContent::OnStopRequest(nsIRequest* aRequest,
// nsIStreamListener
NS_IMETHODIMP
nsObjectLoadingContent::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aInputStream,
uint64_t aOffset, uint32_t aCount) {
if (aRequest != mChannel) {
Expand All @@ -1057,7 +1056,7 @@ nsObjectLoadingContent::OnDataAvailable(nsIRequest* aRequest,
if (mFinalListener) {
// This may re-enter in the case of plugin listeners
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
return listenerGrip->OnDataAvailable(aRequest, aContext, aInputStream,
return listenerGrip->OnDataAvailable(aRequest, aInputStream,
aOffset, aCount);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsSyncLoadService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ nsresult nsSyncLoadService::PushSyncStreamToListener(
if (readCount > UINT32_MAX) readCount = UINT32_MAX;

rv = aListener->OnDataAvailable(
aChannel, nullptr, in,
aChannel, in,
(uint32_t)std::min(sourceOffset, (uint64_t)UINT32_MAX),
(uint32_t)readCount);
if (NS_FAILED(rv)) {
Expand Down
3 changes: 1 addition & 2 deletions dom/base/test/chrome/test_bug682305.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@
// throws an error if security checks fail
var outListener = contentSecManager.performSecurityCheck(this, listener);
let stream = this.open();
let context = null;
try {
outListener.onStartRequest(this);
} catch (e) {}
try {
outListener.onDataAvailable(this, context, stream, 0, stream.available());
outListener.onDataAvailable(this, stream, 0, stream.available());
} catch (e) {}
try {
outListener.onStopRequest(this, Cr.NS_OK);
Expand Down
2 changes: 1 addition & 1 deletion dom/base/test/send_gzip_content.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function gzipCompressString(string, obs) {
.createInstance(Ci.nsIStringInputStream);
stringStream.data = string;
converter.onStartRequest(null, null);
converter.onDataAvailable(null, null, stringStream, 0, string.length);
converter.onDataAvailable(null, stringStream, 0, string.length);
converter.onStopRequest(null, null, null);
}

Expand Down
5 changes: 2 additions & 3 deletions dom/fetch/FetchDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ AlternativeDataStreamListener::OnStartRequest(nsIRequest* aRequest) {

NS_IMETHODIMP
AlternativeDataStreamListener::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aInputStream,
uint64_t aOffset,
uint32_t aCount) {
Expand All @@ -265,7 +264,7 @@ AlternativeDataStreamListener::OnDataAvailable(nsIRequest* aRequest,
}
if (mStatus == AlternativeDataStreamListener::FALLBACK) {
MOZ_ASSERT(mFetchDriver);
return mFetchDriver->OnDataAvailable(aRequest, aContext, aInputStream,
return mFetchDriver->OnDataAvailable(aRequest, aInputStream,
aOffset, aCount);
}
return NS_OK;
Expand Down Expand Up @@ -1130,7 +1129,7 @@ nsresult CopySegmentToStreamAndSRI(nsIInputStream* aInStr, void* aClosure,
} // anonymous namespace

NS_IMETHODIMP
FetchDriver::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
FetchDriver::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aInputStream, uint64_t aOffset,
uint32_t aCount) {
// NB: This can be called on any thread! But we're guaranteed that it is
Expand Down
1 change: 0 additions & 1 deletion dom/file/MutableBlobStreamListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ MutableBlobStreamListener::OnStopRequest(nsIRequest* aRequest,

NS_IMETHODIMP
MutableBlobStreamListener::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aStream,
uint64_t aSourceOffset,
uint32_t aCount) {
Expand Down
3 changes: 1 addition & 2 deletions dom/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ HTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* aRequest,

NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aStream,
uint64_t aOffset,
uint32_t aCount) {
Expand All @@ -718,7 +717,7 @@ HTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest,
"canceled this request");
return NS_BINDING_ABORTED;
}
return mNextListener->OnDataAvailable(aRequest, aContext, aStream, aOffset,
return mNextListener->OnDataAvailable(aRequest, aStream, aOffset,
aCount);
}

Expand Down
3 changes: 1 addition & 2 deletions dom/html/MediaDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ MediaDocumentStreamListener::OnStopRequest(nsIRequest* request,

NS_IMETHODIMP
MediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
nsISupports* ctxt,
nsIInputStream* inStr,
uint64_t sourceOffset,
uint32_t count) {
if (mNextStream) {
return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset,
return mNextStream->OnDataAvailable(request, inStr, sourceOffset,
count);
}

Expand Down
4 changes: 2 additions & 2 deletions dom/jsurl/nsJSProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,12 @@ nsJSChannel::OnStartRequest(nsIRequest* aRequest) {
}

NS_IMETHODIMP
nsJSChannel::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
nsJSChannel::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aInputStream, uint64_t aOffset,
uint32_t aCount) {
NS_ENSURE_TRUE(aRequest == mStreamChannel, NS_ERROR_UNEXPECTED);

return mListener->OnDataAvailable(this, aContext, aInputStream, aOffset,
return mListener->OnDataAvailable(this, aInputStream, aOffset,
aCount);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/ChannelMediaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ nsresult ChannelMediaResource::Listener::OnStopRequest(nsIRequest* aRequest,
}

nsresult ChannelMediaResource::Listener::OnDataAvailable(
nsIRequest* aRequest, nsISupports* aContext, nsIInputStream* aStream,
nsIRequest* aRequest, nsIInputStream* aStream,
uint64_t aOffset, uint32_t aCount) {
// This might happen off the main thread.
RefPtr<ChannelMediaResource> res;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/IdpSandbox.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ResourceLoader.load = function(uri, doc) {
};

ResourceLoader.prototype = {
onDataAvailable(request, context, input, offset, count) {
onDataAvailable(request, input, offset, count) {
let stream = Cc["@mozilla.org/scriptableinputstream;1"]
.createInstance(Ci.nsIScriptableInputStream);
stream.init(input);
Expand Down
2 changes: 1 addition & 1 deletion dom/media/WebVTTListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ nsresult WebVTTListener::ParseChunk(nsIInputStream* aInStream, void* aClosure,
}

NS_IMETHODIMP
WebVTTListener::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
WebVTTListener::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aStream, uint64_t aOffset,
uint32_t aCount) {
VTT_LOG("WebVTTListener::OnDataAvailable\n");
Expand Down
2 changes: 1 addition & 1 deletion dom/network/TCPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ TCPSocket::OnStartRequest(nsIRequest* aRequest) {
}

NS_IMETHODIMP
TCPSocket::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
TCPSocket::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aStream, uint64_t aOffset,
uint32_t aCount) {
if (mUseArrayBuffers) {
Expand Down
6 changes: 3 additions & 3 deletions dom/plugins/base/nsPluginStreamListenerPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ class PluginContextProxy final : public nsIStreamListener {
}

NS_IMETHOD
OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aIStream, uint64_t aSourceOffset,
uint32_t aLength) override {
// Proxy OnDataAvailable using the internal context
return mListener->OnDataAvailable(aRequest, mContext, aIStream,
return mListener->OnDataAvailable(aRequest, aIStream,
aSourceOffset, aLength);
}

Expand Down Expand Up @@ -320,7 +320,7 @@ nsresult nsPluginStreamListenerPeer::SetStreamOffset(int32_t value) {
}

NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(
nsIRequest* request, nsISupports* aContext, nsIInputStream* aIStream,
nsIRequest* request, nsIInputStream* aIStream,
uint64_t sourceOffset, uint32_t aLength) {
if (mRequests.IndexOfObject(request) == -1) {
MOZ_ASSERT(false, "Received OnDataAvailable for untracked request.");
Expand Down
Loading

0 comments on commit 63ab2bd

Please sign in to comment.