Bug 1363421 - Part 1, lazy load HTTP protocol handler to improve start-up performance. r=mcmanus

system-info might need to be construct while creating nsHttpHandler and it might take up to 30ms.
Lazy loading the DEFAULT_UA can delay the creation of nsHttpHandler after start-up.

MozReview-Commit-ID: FtIpKjcY38r

--HG--
extra : rebase_source : 8061ed3ce6c42955e52f494166958f5b63ab940b
This commit is contained in:
Shih-Chiang Chien 2017-05-10 11:06:05 +08:00
parent ecfde05fec
commit 0381369d6c

View File

@ -14,11 +14,15 @@ Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/UserAgentUpdates.jsm");
const PREF_OVERRIDES_ENABLED = "general.useragent.site_specific_overrides";
const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler)
.userAgent;
const MAX_OVERRIDE_FOR_HOST_CACHE_SIZE = 250;
// lazy load nsHttpHandler to improve startup performance.
XPCOMUtils.defineLazyGetter(this, "DEFAULT_UA", function() {
return Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler)
.userAgent;
});
var gPrefBranch;
var gOverrides = new Map;
var gUpdatedOverrides;