Bug 1355611 - Don't load TelemetryStartup.js in the content process. r=gfritzsche
Instead, run the telemetry startup in ContentProcessSingleton.js, to
avoid loading a .jsm in every content process.
MozReview-Commit-ID: BnwoZTjFB3i
--- a/toolkit/components/processsingleton/ContentProcessSingleton.js
+++ b/toolkit/components/processsingleton/ContentProcessSingleton.js
@@ -9,16 +9,19 @@ const Ci = Components.interfaces;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
+ "resource://gre/modules/TelemetryController.jsm");
+
/*
* The message manager has an upper limit on message sizes that it can
* reliably forward to the parent so we limit the size of console log event
* messages that we forward here. The web console is local and receives the
* full console message, but addons subscribed to console event messages
* in the parent receive the truncated version. Due to fragmentation,
* messages as small as 1MB have resulted in IPC allocation failures on
* 32-bit platforms. To limit IPC allocation sizes, console.log messages
@@ -42,16 +45,17 @@ ContentProcessSingleton.prototype = {
Ci.nsISupportsWeakReference]),
observe(subject, topic, data) {
switch (topic) {
case "app-startup": {
Services.obs.addObserver(this, "console-api-log-event", false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
cpmm.addMessageListener("DevTools:InitDebuggerServer", this);
+ TelemetryController.observe(null, topic, null);
break;
}
case "console-api-log-event": {
let consoleMsg = subject.wrappedJSObject;
let msgData = {
level: consoleMsg.level,
filename: consoleMsg.filename.substring(0, MSG_MGR_CONSOLE_INFO_MAX),
--- a/toolkit/components/telemetry/TelemetryStartup.js
+++ b/toolkit/components/telemetry/TelemetryStartup.js
@@ -19,17 +19,18 @@ XPCOMUtils.defineLazyModuleGetter(this,
* to TelemetryController.jsm.
*/
function TelemetryStartup() {
}
TelemetryStartup.prototype.classID = Components.ID("{117b219f-92fe-4bd2-a21b-95a342a9d474}");
TelemetryStartup.prototype.QueryInterface = XPCOMUtils.generateQI([Components.interfaces.nsIObserver]);
TelemetryStartup.prototype.observe = function(aSubject, aTopic, aData) {
- if (aTopic == "profile-after-change" || aTopic == "app-startup") {
+ if (aTopic == "profile-after-change") {
+ // In the content process, this is done in ContentProcessSingleton.js.
TelemetryController.observe(null, aTopic, null);
}
if (aTopic == "profile-after-change") {
annotateEnvironment();
TelemetryEnvironment.registerChangeListener("CrashAnnotator", annotateEnvironment);
TelemetryEnvironment.onInitialized().then(() => annotateEnvironment());
}
}
--- a/toolkit/components/telemetry/TelemetryStartup.manifest
+++ b/toolkit/components/telemetry/TelemetryStartup.manifest
@@ -1,4 +1,3 @@
component {117b219f-92fe-4bd2-a21b-95a342a9d474} TelemetryStartup.js
contract @mozilla.org/base/telemetry-startup;1 {117b219f-92fe-4bd2-a21b-95a342a9d474}
category profile-after-change TelemetryStartup @mozilla.org/base/telemetry-startup;1 process=main
-category app-startup TelemetryStartup @mozilla.org/base/telemetry-startup;1 process=content