Add performance warnings to Deprecated module.

Adds a dedicated handler for performance warnings to be logged to
consoles if known performance-impacting methods are called.
Search service init is changed from a deprecation warning to a
performance warning for synchronous init.
This also re-enables the warning for the Basilisk & Co. search service
initialization which was previously removed in [a930a79]

See also the discussion on #916.
This commit is contained in:
wolfbeast 2018-12-24 05:06:54 +01:00 committed by Roy Tam
commit 69919870c1
4 changed files with 60 additions and 7 deletions

View file

@ -21,6 +21,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SearchStaticData",
"resource://gre/modules/SearchStaticData.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
@ -2691,6 +2693,13 @@ SearchService.prototype = {
return;
}
let performanceWarning =
"Search service falling back to synchronous initialization. " +
"This is generally the consequence of an add-on using a deprecated " +
"search service API.";
Deprecated.perfWarning(performanceWarning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
LOG(performanceWarning);
this._syncInit();
if (!Components.isSuccessCode(this._initRV)) {
throw this._initRV;

View file

@ -2917,12 +2917,12 @@ SearchService.prototype = {
return;
}
let warning =
let performanceWarning =
"Search service falling back to synchronous initialization. " +
"This is generally the consequence of an add-on using a deprecated " +
"search service API.";
Deprecated.warning(warning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
LOG(warning);
Deprecated.perfWarning(performanceWarning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
LOG(performanceWarning);
engineMetadataService.syncInit();
this._syncInit();