fx-compat: Remove 'context' from onStartRequest()/onStopRequest()/etc.

This commit is contained in:
Dan Stillman 2020-07-24 20:53:59 -04:00
parent 3a77abc8d2
commit 94c7e0674d
8 changed files with 47 additions and 48 deletions

View file

@ -758,7 +758,7 @@ ZoteroStandalone.DebugOutput = {
return; return;
} }
req.channel.notificationCallbacks = { req.channel.notificationCallbacks = {
onProgress: function (request, context, progress, progressMax) {}, onProgress: function (request, progress, progressMax) {},
// nsIInterfaceRequestor // nsIInterfaceRequestor
getInterface: function (iid) { getInterface: function (iid) {

View file

@ -431,7 +431,7 @@ Zotero.IPC.Pipe.DeferredOpen = function(file, callback) {
Zotero.IPC.Pipe.DeferredOpen.prototype = { Zotero.IPC.Pipe.DeferredOpen.prototype = {
"onStartRequest":function() {}, "onStartRequest":function() {},
"onStopRequest":function() {}, "onStopRequest":function() {},
"onDataAvailable":function(request, context, inputStream, offset, count) { onDataAvailable: function (request, inputStream, offset, count) {
// read from pipe // read from pipe
var converterInputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] var converterInputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Components.interfaces.nsIConverterInputStream); .createInstance(Components.interfaces.nsIConverterInputStream);

View file

@ -216,14 +216,14 @@ Zotero.MIMETypeHandler = new function () {
/** /**
* Called when the request is started; we ignore this * Called when the request is started; we ignore this
*/ */
_StreamListener.prototype.onStartRequest = function(channel, context) {} _StreamListener.prototype.onStartRequest = function(channel) {}
/** /**
* Called when there's data available; we collect this data and keep it until the request is * Called when there's data available; we collect this data and keep it until the request is
* done * done
*/ */
_StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) { _StreamListener.prototype.onDataAvailable = function(request, inputStream, offset, count) {
Zotero.debug(count + " bytes available"); Zotero.debug(count + " bytes available");
if (!this._storageStream) { if (!this._storageStream) {
@ -244,7 +244,7 @@ Zotero.MIMETypeHandler = new function () {
/** /**
* Called when the request is done * Called when the request is done
*/ */
_StreamListener.prototype.onStopRequest = async function (channel, context, status) { _StreamListener.prototype.onStopRequest = async function (channel, status) {
Zotero.debug("charset is " + channel.contentCharset); Zotero.debug("charset is " + channel.contentCharset);
var inputStream = this._storageStream.newInputStream(0); var inputStream = this._storageStream.newInputStream(0);
@ -289,11 +289,11 @@ Zotero.MIMETypeHandler = new function () {
this._contentType, this._request, frontWindow, null this._contentType, this._request, frontWindow, null
); );
if (streamListener) { if (streamListener) {
streamListener.onStartRequest(channel, context); streamListener.onStartRequest(channel);
streamListener.onDataAvailable( streamListener.onDataAvailable(
this._request, context, inputStream, 0, this._storageStream.length this._request, inputStream, 0, this._storageStream.length
); );
streamListener.onStopRequest(channel, context, status); streamListener.onStopRequest(channel, status);
} }
} }

View file

@ -175,12 +175,12 @@ Zotero.Server.DataListener = function(iStream, oStream) {
* called when a request begins (although the request should have begun before * called when a request begins (although the request should have begun before
* the DataListener was generated) * the DataListener was generated)
*/ */
Zotero.Server.DataListener.prototype.onStartRequest = function(request, context) {} Zotero.Server.DataListener.prototype.onStartRequest = function(request) {}
/* /*
* called when a request stops * called when a request stops
*/ */
Zotero.Server.DataListener.prototype.onStopRequest = function(request, context, status) { Zotero.Server.DataListener.prototype.onStopRequest = function(request, status) {
this.iStream.close(); this.iStream.close();
this.oStream.close(); this.oStream.close();
} }
@ -188,8 +188,7 @@ Zotero.Server.DataListener.prototype.onStopRequest = function(request, context,
/* /*
* called when new data is available * called when new data is available
*/ */
Zotero.Server.DataListener.prototype.onDataAvailable = function(request, context, Zotero.Server.DataListener.prototype.onDataAvailable = function (request, inputStream, offset, count) {
inputStream, offset, count) {
var readData = NetUtil.readInputStreamToString(inputStream, count); var readData = NetUtil.readInputStreamToString(inputStream, count);
if(this.headerFinished) { // reading body if(this.headerFinished) { // reading body

View file

@ -42,25 +42,25 @@ Zotero.Sync.Storage.StreamListener.prototype = {
_channel: null, _channel: null,
// nsIProgressEventSink // nsIProgressEventSink
onProgress: function (request, context, progress, progressMax) { onProgress: function (request, progress, progressMax) {
Zotero.debug("onProgress with " + progress + "/" + progressMax); Zotero.debug("onProgress with " + progress + "/" + progressMax);
this._onProgress(request, progress, progressMax); this._onProgress(request, progress, progressMax);
}, },
onStatus: function (request, context, status, statusArg) { onStatus: function (request, status, statusArg) {
Zotero.debug('onStatus with ' + status); Zotero.debug('onStatus with ' + status);
}, },
// nsIRequestObserver // nsIRequestObserver
// Note: For uploads, this isn't called until data is done uploading // Note: For uploads, this isn't called until data is done uploading
onStartRequest: function (request, context) { onStartRequest: function (request) {
Zotero.debug('onStartRequest'); Zotero.debug('onStartRequest');
this._response = ""; this._response = "";
this._onStart(request); this._onStart(request);
}, },
onStopRequest: function (request, context, status) { onStopRequest: function (request, status) {
Zotero.debug('onStopRequest with ' + status); Zotero.debug('onStopRequest with ' + status);
// Some errors from https://developer.mozilla.org/en-US/docs/Table_Of_Errors // Some errors from https://developer.mozilla.org/en-US/docs/Table_Of_Errors
@ -132,7 +132,7 @@ Zotero.Sync.Storage.StreamListener.prototype = {
}, },
// nsIStreamListener // nsIStreamListener
onDataAvailable: function (request, context, stream, sourceOffset, length) { onDataAvailable: function (request, stream, sourceOffset, length) {
Zotero.debug('onDataAvailable'); Zotero.debug('onDataAvailable');
var scriptableInputStream = var scriptableInputStream =
Components.classes["@mozilla.org/scriptableinputstream;1"] Components.classes["@mozilla.org/scriptableinputstream;1"]

View file

@ -251,16 +251,16 @@ Zotero.Utilities.Internal = {
size: 0, size: 0,
data: '', data: '',
onStartRequest: function (request, context) {}, onStartRequest: function (request) {},
onStopRequest: function (request, context, status) { onStopRequest: function (request, status) {
this.binaryInputStream.close(); this.binaryInputStream.close();
delete this.binaryInputStream; delete this.binaryInputStream;
deferred.resolve(this.data); deferred.resolve(this.data);
}, },
onDataAvailable: function (request, context, inputStream, offset, count) { onDataAvailable: function (request, inputStream, offset, count) {
this.size += count; this.size += count;
this.binaryInputStream = Components.classes["@mozilla.org/binaryinputstream;1"] this.binaryInputStream = Components.classes["@mozilla.org/binaryinputstream;1"]
@ -317,13 +317,13 @@ Zotero.Utilities.Internal = {
{ {
data: '', data: '',
onStartRequest: function (request, context) {}, onStartRequest: function (request) {},
onStopRequest: function (request, context, status) { onStopRequest: function (request, status) {
deferred.resolve(this.data); deferred.resolve(this.data);
}, },
onDataAvailable: function (request, context, inputStream, offset, count) { onDataAvailable: function (request, inputStream, offset, count) {
this.data += NetUtil.readInputStreamToString( this.data += NetUtil.readInputStreamToString(
inputStream, inputStream,
inputStream.available(), inputStream.available(),

View file

@ -971,11 +971,11 @@ function ZoteroProtocolHandler() {
ConnectorChannel.prototype.__defineGetter__("originalURI", function() { return this.URI }); ConnectorChannel.prototype.__defineGetter__("originalURI", function() { return this.URI });
ConnectorChannel.prototype.__defineSetter__("originalURI", function() { }); ConnectorChannel.prototype.__defineSetter__("originalURI", function() { });
ConnectorChannel.prototype.asyncOpen = function(streamListener, context) { ConnectorChannel.prototype.asyncOpen = function(streamListener) {
if(this.loadGroup) this.loadGroup.addRequest(this, null); if(this.loadGroup) this.loadGroup.addRequest(this, null);
streamListener.onStartRequest(this, context); streamListener.onStartRequest(this);
streamListener.onDataAvailable(this, context, this._stream, 0, this.contentLength); streamListener.onDataAvailable(this, this._stream, 0, this.contentLength);
streamListener.onStopRequest(this, context, this.status); streamListener.onStopRequest(this, this.status);
this._isPending = false; this._isPending = false;
if(this.loadGroup) this.loadGroup.removeRequest(this, null, 0); if(this.loadGroup) this.loadGroup.removeRequest(this, null, 0);
} }
@ -1360,7 +1360,7 @@ function AsyncChannel(uri, gen) {
} }
AsyncChannel.prototype = { AsyncChannel.prototype = {
asyncOpen: Zotero.Promise.coroutine(function* (streamListener, context) { asyncOpen: Zotero.Promise.coroutine(function* (streamListener) {
if (this.loadGroup) this.loadGroup.addRequest(this, null); if (this.loadGroup) this.loadGroup.addRequest(this, null);
var channel = this; var channel = this;
@ -1373,17 +1373,17 @@ AsyncChannel.prototype = {
}); });
var listenerWrapper = { var listenerWrapper = {
onStartRequest: function (request, context) { onStartRequest: function (request) {
//Zotero.debug("Starting request"); //Zotero.debug("Starting request");
streamListener.onStartRequest(channel, context); streamListener.onStartRequest(channel);
}, },
onDataAvailable: function (request, context, inputStream, offset, count) { onDataAvailable: function (request, inputStream, offset, count) {
//Zotero.debug("onDataAvailable"); //Zotero.debug("onDataAvailable");
streamListener.onDataAvailable(channel, context, inputStream, offset, count); streamListener.onDataAvailable(channel, inputStream, offset, count);
}, },
onStopRequest: function (request, context, status) { onStopRequest: function (request, status) {
//Zotero.debug("Stopping request"); //Zotero.debug("Stopping request");
streamListener.onStopRequest(channel, context, status); streamListener.onStopRequest(channel, status);
channel._isPending = false; channel._isPending = false;
if (status == 0) { if (status == 0) {
resolve(); resolve();
@ -1405,15 +1405,15 @@ AsyncChannel.prototype = {
if (typeof data == 'string') { if (typeof data == 'string') {
//Zotero.debug("AsyncChannel: Got string from generator"); //Zotero.debug("AsyncChannel: Got string from generator");
listenerWrapper.onStartRequest(this, context); listenerWrapper.onStartRequest(this);
let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"] let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter); .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8"; converter.charset = "UTF-8";
let inputStream = converter.convertToInputStream(data); let inputStream = converter.convertToInputStream(data);
listenerWrapper.onDataAvailable(this, context, inputStream, 0, inputStream.available()); listenerWrapper.onDataAvailable(this, inputStream, 0, inputStream.available());
listenerWrapper.onStopRequest(this, context, this.status); listenerWrapper.onStopRequest(this, this.status);
} }
// If an async input stream is given, pass the data asynchronously to the stream listener // If an async input stream is given, pass the data asynchronously to the stream listener
else if (data instanceof Ci.nsIAsyncInputStream) { else if (data instanceof Ci.nsIAsyncInputStream) {
@ -1426,7 +1426,7 @@ AsyncChannel.prototype = {
catch (e) { catch (e) {
pump.init(data, -1, -1, 0, 0, true); pump.init(data, -1, -1, 0, 0, true);
} }
pump.asyncRead(listenerWrapper, context); pump.asyncRead(listenerWrapper, null);
} }
else if (data instanceof Ci.nsIFile || data instanceof Ci.nsIURI) { else if (data instanceof Ci.nsIFile || data instanceof Ci.nsIURI) {
if (data instanceof Ci.nsIFile) { if (data instanceof Ci.nsIFile) {
@ -1452,14 +1452,14 @@ AsyncChannel.prototype = {
return; return;
} }
listenerWrapper.onStartRequest(channel, context); listenerWrapper.onStartRequest(channel);
try { try {
listenerWrapper.onDataAvailable(channel, context, inputStream, 0, inputStream.available()); listenerWrapper.onDataAvailable(channel, inputStream, 0, inputStream.available());
} }
catch (e) { catch (e) {
reject(e); reject(e);
} }
listenerWrapper.onStopRequest(channel, context, status); listenerWrapper.onStopRequest(channel, status);
}); });
} }
else if (data === undefined) { else if (data === undefined) {
@ -1478,7 +1478,7 @@ AsyncChannel.prototype = {
} catch (e) { } catch (e) {
Zotero.debug(e, 1); Zotero.debug(e, 1);
if (channel._isPending) { if (channel._isPending) {
streamListener.onStopRequest(channel, context, Components.results.NS_ERROR_FAILURE); streamListener.onStopRequest(channel, Components.results.NS_ERROR_FAILURE);
channel._isPending = false; channel._isPending = false;
} }
throw e; throw e;

View file

@ -4081,12 +4081,12 @@ Response.prototype =
var response = this; var response = this;
var copyObserver = var copyObserver =
{ {
onStartRequest: function(request, cx) onStartRequest: function(request)
{ {
dumpn("*** preamble copying started"); dumpn("*** preamble copying started");
}, },
onStopRequest: function(request, cx, statusCode) onStopRequest: function(request, statusCode)
{ {
dumpn("*** preamble copying complete " + dumpn("*** preamble copying complete " +
"[status=0x" + statusCode.toString(16) + "]"); "[status=0x" + statusCode.toString(16) + "]");
@ -4145,12 +4145,12 @@ Response.prototype =
var response = this; var response = this;
var copyObserver = var copyObserver =
{ {
onStartRequest: function(request, context) onStartRequest: function(request)
{ {
dumpn("*** onStartRequest"); dumpn("*** onStartRequest");
}, },
onStopRequest: function(request, cx, statusCode) onStopRequest: function(request, statusCode)
{ {
dumpn("*** onStopRequest [status=0x" + statusCode.toString(16) + "]"); dumpn("*** onStopRequest [status=0x" + statusCode.toString(16) + "]");
@ -4275,7 +4275,7 @@ function WriteThroughCopier(source, sink, observer, context)
// start copying // start copying
try try
{ {
observer.onStartRequest(this, context); observer.onStartRequest(this);
this._waitToReadData(); this._waitToReadData();
this._waitForSinkClosure(); this._waitForSinkClosure();
} }
@ -4688,7 +4688,7 @@ WriteThroughCopier.prototype =
self._completed = true; self._completed = true;
try try
{ {
self._observer.onStopRequest(self, self._context, self.status); self._observer.onStopRequest(self, self.status);
} }
catch (e) catch (e)
{ {