Bug 386473 - Change a few QueryInterface functions in nsSearchService.js to use XPCOMUtils.generateQI. Based on a patch originally by Ryan Flint. r?florian
MozReview-Commit-ID: 2xB9VjjnKW1
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -315,30 +315,25 @@ function loadListener(aChannel, aEngine,
}
loadListener.prototype = {
_callback: null,
_channel: null,
_countRead: 0,
_engine: null,
_stream: null,
- QueryInterface: function SRCH_loadQI(aIID) {
- if (aIID.equals(Ci.nsISupports) ||
- aIID.equals(Ci.nsIRequestObserver) ||
- aIID.equals(Ci.nsIStreamListener) ||
- aIID.equals(Ci.nsIChannelEventSink) ||
- aIID.equals(Ci.nsIInterfaceRequestor) ||
- // See FIXME comment below
- aIID.equals(Ci.nsIHttpEventSink) ||
- aIID.equals(Ci.nsIProgressEventSink) ||
- false)
- return this;
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
+ QueryInterface: XPCOMUtils.generateQI([
+ Ci.nsIRequestObserver,
+ Ci.nsIStreamListener,
+ Ci.nsIChannelEventSink,
+ Ci.nsIInterfaceRequestor,
+ // See FIXME comment below.
+ Ci.nsIHttpEventSink,
+ Ci.nsIProgressEventSink
+ ]),
// nsIRequestObserver
onStartRequest: function SRCH_loadStartR(aRequest, aContext) {
LOG("loadListener: Starting request: " + aRequest.name);
this._stream = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
},
@@ -2527,22 +2522,17 @@ Engine.prototype = {
return {
mainDomain: templateUrl.host,
path: templateUrl.filePath.toLowerCase(),
termsParameterName: termsParameterName,
};
},
// nsISupports
- QueryInterface: function SRCH_ENG_QI(aIID) {
- if (aIID.equals(Ci.nsISearchEngine) ||
- aIID.equals(Ci.nsISupports))
- return this;
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsISearchEngine]),
get wrappedJSObject() {
return this;
},
/**
* Returns a string with the URL to an engine's icon matching both width and
* height. Returns null if icon with specified dimensions is not found.
@@ -2634,22 +2624,17 @@ function Submission(aURI, aPostData = nu
}
Submission.prototype = {
get uri() {
return this._uri;
},
get postData() {
return this._postData;
},
- QueryInterface: function SRCH_SUBM_QI(aIID) {
- if (aIID.equals(Ci.nsISearchSubmission) ||
- aIID.equals(Ci.nsISupports))
- return this;
- throw Cr.NS_ERROR_NO_INTERFACE;
- }
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsISearchSubmission])
}
// nsISearchParseSubmissionResult
function ParseSubmissionResult(aEngine, aTerms, aTermsOffset, aTermsLength) {
this._engine = aEngine;
this._terms = aTerms;
this._termsOffset = aTermsOffset;
this._termsLength = aTermsLength;
@@ -4748,24 +4733,21 @@ SearchService.prototype = {
Services.obs.removeObserver(this, SEARCH_ENGINE_TOPIC);
Services.obs.removeObserver(this, QUIT_APPLICATION_TOPIC);
#ifdef MOZ_FENNEC
Services.prefs.removeObserver(LOCALE_PREF, this);
#endif
},
- QueryInterface: function SRCH_SVC_QI(aIID) {
- if (aIID.equals(Ci.nsIBrowserSearchService) ||
- aIID.equals(Ci.nsIObserver) ||
- aIID.equals(Ci.nsITimerCallback) ||
- aIID.equals(Ci.nsISupports))
- return this;
- throw Cr.NS_ERROR_NO_INTERFACE;
- }
+ QueryInterface: XPCOMUtils.generateQI([
+ Ci.nsIBrowserSearchService,
+ Ci.nsIObserver,
+ Ci.nsITimerCallback
+ ])
};
const SEARCH_UPDATE_LOG_PREFIX = "*** Search update: ";
/**
* Outputs aText to the JavaScript console as well as to stdout, if the search
* logging pref (browser.search.update.log) is set to true.