Skip to content

Commit

Permalink
Bug 1525319 - Changing js to remove context from onStartRequest and o…
Browse files Browse the repository at this point in the history
…nStopRequest r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D20771

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Jonathan Kingston committed Feb 27, 2019
1 parent c485331 commit dd4c731
Show file tree
Hide file tree
Showing 134 changed files with 420 additions and 428 deletions.
4 changes: 2 additions & 2 deletions browser/base/content/aboutDialog-appUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,13 @@ appUpdater.prototype =
/**
* See nsIRequestObserver.idl
*/
onStartRequest(aRequest, aContext) {
onStartRequest(aRequest) {
},

/**
* See nsIRequestObserver.idl
*/
onStopRequest(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aStatusCode) {
switch (aStatusCode) {
case Cr.NS_ERROR_UNEXPECTED:
if (this.update.selectedPatch.state == "download-failed" &&
Expand Down
8 changes: 4 additions & 4 deletions browser/base/content/nsContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ nsContextMenu.prototype = {
saveAsListener.prototype = {
extListener: null,

onStartRequest: function saveLinkAs_onStartRequest(aRequest, aContext) {
onStartRequest: function saveLinkAs_onStartRequest(aRequest) {
// if the timer fired, the error status will have been caused by that,
// and we'll be restarting in onStopRequest, so no reason to notify
// the user
Expand Down Expand Up @@ -1137,10 +1137,10 @@ nsContextMenu.prototype = {
this.extListener =
extHelperAppSvc.doContent(channel.contentType, aRequest,
null, true, window);
this.extListener.onStartRequest(aRequest, aContext);
this.extListener.onStartRequest(aRequest);
},

onStopRequest: function saveLinkAs_onStopRequest(aRequest, aContext,
onStopRequest: function saveLinkAs_onStopRequest(aRequest,
aStatusCode) {
if (aStatusCode == NS_ERROR_SAVE_LINK_AS_TIMEOUT) {
// do it the old fashioned way, which will pick the best filename
Expand All @@ -1149,7 +1149,7 @@ nsContextMenu.prototype = {
doc, isContentWindowPrivate);
}
if (this.extListener)
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
this.extListener.onStopRequest(aRequest, aStatusCode);
},

onDataAvailable: function saveLinkAs_onDataAvailable(aRequest, aContext,
Expand Down
24 changes: 12 additions & 12 deletions browser/extensions/pdfjs/content/PdfStreamConverter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,18 @@ class ChromeActions {

var listener = {
extListener: null,
onStartRequest(aRequest, aContext) {
onStartRequest(aRequest) {
var loadContext = self.domWindow.docShell
.QueryInterface(Ci.nsILoadContext);
this.extListener = extHelperAppSvc.doContent(
(data.isAttachment ? "application/octet-stream" :
"application/pdf"),
aRequest, loadContext, false);
this.extListener.onStartRequest(aRequest, aContext);
this.extListener.onStartRequest(aRequest);
},
onStopRequest(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aStatusCode) {
if (this.extListener) {
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
this.extListener.onStopRequest(aRequest, aStatusCode);
}
// Notify the content code we're done downloading.
if (sendResponse) {
Expand Down Expand Up @@ -860,7 +860,7 @@ PdfStreamConverter.prototype = {
},

// nsIRequestObserver::onStartRequest
onStartRequest(aRequest, aContext) {
onStartRequest(aRequest) {
// Setup the request so we can use it below.
var isHttpRequest = false;
try {
Expand Down Expand Up @@ -939,19 +939,19 @@ PdfStreamConverter.prototype = {
// request(aRequest) below so we don't overwrite the original channel and
// trigger an assertion.
var proxy = {
onStartRequest(request, context) {
listener.onStartRequest(aRequest, aContext);
onStartRequest(request) {
listener.onStartRequest(aRequest);
},
onDataAvailable(request, context, inputStream, offset, count) {
listener.onDataAvailable(aRequest, aContext, inputStream,
listener.onDataAvailable(aRequest, null, inputStream,
offset, count);
},
onStopRequest(request, context, statusCode) {
onStopRequest(request, statusCode) {
var domWindow = getDOMWindow(channel, resourcePrincipal);
if (!Components.isSuccessCode(statusCode) || !domWindow) {
// The request may have been aborted and the document may have been
// replaced with something that is not PDF.js, abort attaching.
listener.onStopRequest(aRequest, context, statusCode);
listener.onStopRequest(aRequest, statusCode);
return;
}
var actions;
Expand All @@ -971,7 +971,7 @@ PdfStreamConverter.prototype = {
var findEventManager = new FindEventManager(domWindow);
findEventManager.bind();
}
listener.onStopRequest(aRequest, aContext, statusCode);
listener.onStopRequest(aRequest, statusCode);

if (domWindow.frameElement) {
var isObjectEmbed = domWindow.frameElement.tagName !== "IFRAME" ||
Expand Down Expand Up @@ -999,7 +999,7 @@ PdfStreamConverter.prototype = {
},

// nsIRequestObserver::onStopRequest
onStopRequest(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aStatusCode) {
if (!this.dataListener) {
// Do nothing
return;
Expand Down
4 changes: 2 additions & 2 deletions browser/modules/FaviconLoader.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class FaviconLoad {
this.channel.cancel(Cr.NS_BINDING_ABORTED);
}

onStartRequest(request, context) {
onStartRequest(request) {
}

onDataAvailable(request, context, inputStream, offset, count) {
Expand All @@ -175,7 +175,7 @@ class FaviconLoad {
callback.onRedirectVerifyCallback(Cr.NS_OK);
}

async onStopRequest(request, context, statusCode) {
async onStopRequest(request, statusCode) {
if (request != this.channel) {
// Indicates that a redirect has occurred. We don't care about the result
// of the original channel.
Expand Down
10 changes: 5 additions & 5 deletions devtools/client/jsonview/converter-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Converter.prototype = {
this.decodeAndInsertBuffer(buffer);
},

onStartRequest: function(request, context) {
onStartRequest: function(request) {
// Set the content type to HTML in order to parse the doctype, styles
// and scripts. The JSON will be manually inserted as text.
request.QueryInterface(Ci.nsIChannel);
Expand Down Expand Up @@ -105,7 +105,7 @@ Converter.prototype = {
request.loadInfo.resetPrincipalToInheritToNullPrincipal();

// Start the request.
this.listener.onStartRequest(request, context);
this.listener.onStartRequest(request);

// Initialize stuff.
const win = NetworkHelper.getWindowForRequest(request);
Expand All @@ -117,15 +117,15 @@ 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, context, stream, 0, stream.available());
this.listener.onDataAvailable(request, null, stream, 0, stream.available());
},

onStopRequest: function(request, context, statusCode) {
onStopRequest: function(request, statusCode) {
// Flush data.
this.decodeAndInsertBuffer(new ArrayBuffer(0), true);

// Stop the request.
this.listener.onStopRequest(request, context, statusCode);
this.listener.onStopRequest(request, statusCode);
this.listener = null;
this.decoder = null;
this.data = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ function gzipCompressString(string, obs) {
let stringStream = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
stringStream.data = string;
converter.onStartRequest(null, null);
converter.onStartRequest(null);
converter.onDataAvailable(null, null, stringStream, 0, string.length);
converter.onStopRequest(null, null, null);
converter.onStopRequest(null, null);
}

function doubleGzipCompressString(string, observer) {
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 @@ -98,7 +98,7 @@ add_task(async function() {
equal(testListener.state, "initial", "test listener in initial state");

// This method must be passed through immediately.
listener.onStartRequest(null, null);
listener.onStartRequest(null);
equal(testListener.state, "start", "test listener started");

const TEST_INPUT = "hi bob";
Expand Down Expand Up @@ -137,7 +137,7 @@ add_task(async function() {
equal(activitySeen, true, "activity has been distributed");

const onChange = testListener.onStateChanged();
listener.onStopRequest(null, null, null);
listener.onStopRequest(null, null);
newState = await onChange;
equal(newState, "stop", "onStateChanged reported");
});
10 changes: 5 additions & 5 deletions devtools/shared/webconsole/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ NetworkThrottleListener.prototype = {
/**
* @see nsIStreamListener.onStartRequest.
*/
onStartRequest: function(request, context) {
this.originalListener.onStartRequest(request, context);
onStartRequest: function(request) {
this.originalListener.onStartRequest(request);
this.queue.start(this);
},

/**
* @see nsIStreamListener.onStopRequest.
*/
onStopRequest: function(request, context, statusCode) {
this.pendingData.push({request, context, statusCode});
onStopRequest: function(request, statusCode) {
this.pendingData.push({request, statusCode});
this.queue.dataAvailable(this);
},

Expand Down Expand Up @@ -114,7 +114,7 @@ NetworkThrottleListener.prototype = {

if (statusCode !== undefined) {
this.pendingData.shift();
this.originalListener.onStopRequest(request, context, statusCode);
this.originalListener.onStopRequest(request, statusCode);
return {length: 0, done: true};
}

Expand Down
4 changes: 2 additions & 2 deletions dom/base/test/chrome/test_bug682305.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
let stream = this.open();
let context = null;
try {
outListener.onStartRequest(this, context);
outListener.onStartRequest(this);
} catch (e) {}
try {
outListener.onDataAvailable(this, context, stream, 0, stream.available());
} catch (e) {}
try {
outListener.onStopRequest(this, context, Cr.NS_OK);
outListener.onStopRequest(this, Cr.NS_OK);
} catch (e) {}
},
open() {
Expand Down
4 changes: 2 additions & 2 deletions dom/media/IdpSandbox.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ResourceLoader.prototype = {
this.data += stream.read(count);
},

onStartRequest(request, context) {},
onStartRequest(request) {},

onStopRequest(request, context, status) {
onStopRequest(request, status) {
if (Components.isSuccessCode(status)) {
var statusCode = request.QueryInterface(Ci.nsIHttpChannel).responseStatus;
if (statusCode === 200) {
Expand Down
16 changes: 8 additions & 8 deletions dom/push/PushServiceHttp2.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ PushSubscriptionListener.prototype = {
return this.QueryInterface(aIID);
},

onStartRequest: function(aRequest, aContext) {
onStartRequest: function(aRequest) {
console.debug("PushSubscriptionListener: onStartRequest()");
// We do not do anything here.
},
Expand All @@ -76,7 +76,7 @@ PushSubscriptionListener.prototype = {
var data = inputStream.read(aCount);
},

onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest: function(aRequest, aStatusCode) {
console.debug("PushSubscriptionListener: onStopRequest()");
if (!this._pushService) {
return;
Expand Down Expand Up @@ -111,7 +111,7 @@ var PushChannelListener = function(pushSubscriptionListener) {

PushChannelListener.prototype = {

onStartRequest: function(aRequest, aContext) {
onStartRequest: function(aRequest) {
this._ackUri = aRequest.URI.spec;
},

Expand All @@ -131,7 +131,7 @@ PushChannelListener.prototype = {
this._message.push(chunk);
},

onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest: function(aRequest, aStatusCode) {
console.debug("PushChannelListener: onStopRequest()", "status code",
aStatusCode);
if (Components.isSuccessCode(aStatusCode) &&
Expand Down Expand Up @@ -169,7 +169,7 @@ var PushServiceDelete = function(resolve, reject) {

PushServiceDelete.prototype = {

onStartRequest: function(aRequest, aContext) {},
onStartRequest: function(aRequest) {},

onDataAvailable: function(aRequest, aContext, aStream, aOffset, aCount) {
// Nobody should send data, but just to be sure, otherwise necko will
Expand All @@ -185,7 +185,7 @@ PushServiceDelete.prototype = {
var data = inputStream.read(aCount);
},

onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest: function(aRequest, aStatusCode) {

if (Components.isSuccessCode(aStatusCode)) {
this._resolve();
Expand All @@ -210,7 +210,7 @@ var SubscriptionListener = function(aSubInfo, aResolve, aReject,

SubscriptionListener.prototype = {

onStartRequest: function(aRequest, aContext) {},
onStartRequest: function(aRequest) {},

onDataAvailable: function(aRequest, aContext, aStream, aOffset, aCount) {
console.debug("SubscriptionListener: onDataAvailable()");
Expand All @@ -228,7 +228,7 @@ SubscriptionListener.prototype = {
this._data.concat(inputStream.read(aCount));
},

onStopRequest: function(aRequest, aContext, aStatus) {
onStopRequest: function(aRequest, aStatus) {
console.debug("SubscriptionListener: onStopRequest()");

// Check if pushService is still active.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ function ChannelListener() {
}

ChannelListener.prototype = {
onStartRequest(request, context) { },
onStartRequest(request) { },
onDataAvailable(request, context, stream, offset, count) {
do_throw("Should not get any data!");
},
onStopRequest(request, context, status) {
onStopRequest(request, status) {
var upgrade_insecure_header = false;
try {
if (request.getRequestHeader("Upgrade-Insecure-Requests")) {
Expand Down
8 changes: 4 additions & 4 deletions image/test/unit/image_load_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function NS_FAILED(val)

function ChannelListener()
{
this.onStartRequest = function onStartRequest(aRequest, aContext)
this.onStartRequest = function onStartRequest(aRequest)
{
if (this.outputListener)
this.outputListener.onStartRequest(aRequest, aContext);
this.outputListener.onStartRequest(aRequest);

this.requestStatus |= START_REQUEST;
}
Expand All @@ -99,10 +99,10 @@ function ChannelListener()
this.requestStatus |= DATA_AVAILABLE;
}

this.onStopRequest = function onStopRequest(aRequest, aContext, aStatusCode)
this.onStopRequest = function onStopRequest(aRequest, aStatusCode)
{
if (this.outputListener)
this.outputListener.onStopRequest(aRequest, aContext, aStatusCode);
this.outputListener.onStopRequest(aRequest, aStatusCode);

// If we failed (or were canceled - failure is implied if canceled),
// there's no use tracking our state, since it's meaningless.
Expand Down
4 changes: 2 additions & 2 deletions mobile/android/chrome/content/CastingApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ var CastingApps = {
}

let listener = {
onStartRequest: function(request, context) {
onStartRequest: function(request) {
switch (channel.responseStatus) {
case 301:
case 302:
Expand All @@ -357,7 +357,7 @@ var CastingApps = {
break;
}
},
onStopRequest: function(request, context, statusCode) {},
onStopRequest: function(request, statusCode) {},
onDataAvailable: function(request, context, stream, offset, count) {},
};

Expand Down
Loading

0 comments on commit dd4c731

Please sign in to comment.