mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1452551 - Initialize the Telemetry core in GeckoView. r=esawin,gfritzsche,jchen
This additionally introduces a new pref (toolkit.telemetry.isGeckoViewMode) to discriminate, at runtime, between Fennec and GV in JavaScript code. Moreover, this disables TelemetryController initialization from content processes, which was left enabled. MozReview-Commit-ID: 7VoDorxAhvD --HG-- extra : rebase_source : b16a5c870c073f62175a5f9c2bf8db30032c55bd
This commit is contained in:
parent
b9e99a5b72
commit
4121e64310
@ -9,4 +9,7 @@
|
||||
pref("privacy.trackingprotection.pbmode.enabled", false);
|
||||
pref("dom.ipc.processCount", 1);
|
||||
pref("dom.ipc.keepProcessesAlive.web", 1);
|
||||
pref("dom.ipc.processPrelaunch.enabled", false);
|
||||
pref("dom.ipc.processPrelaunch.enabled", false);
|
||||
|
||||
// Tell Telemetry that we're in GeckoView mode.
|
||||
pref("toolkit.telemetry.isGeckoViewMode", true);
|
||||
|
@ -5,6 +5,7 @@
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
GeckoViewTelemetryController: "resource://gre/modules/GeckoViewTelemetryController.jsm",
|
||||
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
@ -69,6 +70,11 @@ GeckoViewStartup.prototype = {
|
||||
"ContentPrefs:RemoveObserverForName",
|
||||
],
|
||||
});
|
||||
|
||||
// This initializes Telemetry for GeckoView only in the parent process.
|
||||
// The Telemetry initialization for the content process is performed in
|
||||
// ContentProcessSingleton.js for consistency with Desktop Telemetry.
|
||||
GeckoViewTelemetryController.setup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,10 @@
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "TelemetryController",
|
||||
"resource://gre/modules/TelemetryController.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
GeckoViewTelemetryController: "resource://gre/modules/GeckoViewTelemetryController.jsm",
|
||||
TelemetryController: "resource://gre/modules/TelemetryController.jsm",
|
||||
});
|
||||
|
||||
function ContentProcessSingleton() {}
|
||||
ContentProcessSingleton.prototype = {
|
||||
@ -20,6 +22,13 @@ ContentProcessSingleton.prototype = {
|
||||
switch (topic) {
|
||||
case "app-startup": {
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
// Initialize Telemetry in the content process: use a different
|
||||
// controller depending on the platform.
|
||||
if (Services.prefs.getBoolPref("toolkit.telemetry.isGeckoViewMode", false)) {
|
||||
GeckoViewTelemetryController.setup();
|
||||
return;
|
||||
}
|
||||
// Initialize Firefox Desktop Telemetry.
|
||||
TelemetryController.observe(null, topic, null);
|
||||
break;
|
||||
}
|
||||
|
@ -575,22 +575,7 @@ var Impl = {
|
||||
// Unified Telemetry makes it opt-out. If extended Telemetry is enabled, base recording
|
||||
// is always on as well.
|
||||
if (IS_UNIFIED_TELEMETRY) {
|
||||
// Enable extended Telemetry on pre-release channels and disable it
|
||||
// on Release/ESR.
|
||||
let prereleaseChannels = ["nightly", "aurora", "beta"];
|
||||
if (!AppConstants.MOZILLA_OFFICIAL) {
|
||||
// Turn extended telemetry for local developer builds.
|
||||
prereleaseChannels.push("default");
|
||||
}
|
||||
const isPrereleaseChannel =
|
||||
prereleaseChannels.includes(AppConstants.MOZ_UPDATE_CHANNEL);
|
||||
const isReleaseCandidateOnBeta =
|
||||
AppConstants.MOZ_UPDATE_CHANNEL === "release" &&
|
||||
Services.prefs.getCharPref("app.update.channel", null) === "beta";
|
||||
Telemetry.canRecordBase = true;
|
||||
Telemetry.canRecordExtended = isPrereleaseChannel ||
|
||||
isReleaseCandidateOnBeta ||
|
||||
Services.prefs.getBoolPref(TelemetryUtils.Preferences.OverridePreRelease, false);
|
||||
TelemetryUtils.setTelemetryRecordingFlags();
|
||||
} else {
|
||||
// We're not on unified Telemetry, stick to the old behaviour for
|
||||
// supporting Fennec.
|
||||
|
@ -9,6 +9,8 @@ var EXPORTED_SYMBOLS = [
|
||||
];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm", this);
|
||||
ChromeUtils.defineModuleGetter(this, "AppConstants",
|
||||
"resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
|
||||
|
||||
@ -201,5 +203,27 @@ var TelemetryUtils = {
|
||||
} catch (ex) {
|
||||
return Date.now();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the Telemetry core recording flag for Unified Telemetry.
|
||||
*/
|
||||
setTelemetryRecordingFlags() {
|
||||
// Enable extended Telemetry on pre-release channels and disable it
|
||||
// on Release/ESR.
|
||||
let prereleaseChannels = ["nightly", "aurora", "beta"];
|
||||
if (!AppConstants.MOZILLA_OFFICIAL) {
|
||||
// Turn extended telemetry for local developer builds.
|
||||
prereleaseChannels.push("default");
|
||||
}
|
||||
const isPrereleaseChannel =
|
||||
prereleaseChannels.includes(AppConstants.MOZ_UPDATE_CHANNEL);
|
||||
const isReleaseCandidateOnBeta =
|
||||
AppConstants.MOZ_UPDATE_CHANNEL === "release" &&
|
||||
Services.prefs.getCharPref("app.update.channel", null) === "beta";
|
||||
Services.telemetry.canRecordBase = true;
|
||||
Services.telemetry.canRecordExtended = isPrereleaseChannel ||
|
||||
isReleaseCandidateOnBeta ||
|
||||
Services.prefs.getBoolPref(this.Preferences.OverridePreRelease, false);
|
||||
},
|
||||
};
|
||||
|
@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
TelemetryUtils: "resource://gre/modules/TelemetryUtils.jsm",
|
||||
});
|
||||
|
||||
GeckoViewUtils.initLogging("GeckoView.TelemetryController", this);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["GeckoViewTelemetryController"];
|
||||
|
||||
let GeckoViewTelemetryController = {
|
||||
/**
|
||||
* Setup the Telemetry recording flags. This must be called
|
||||
* in all the processes that need to collect Telemetry.
|
||||
*/
|
||||
setup() {
|
||||
debug `setup`;
|
||||
|
||||
TelemetryUtils.setTelemetryRecordingFlags();
|
||||
|
||||
debug `setup - canRecordPrereleaseData ${Services.telemetry.canRecordPrereleaseData
|
||||
}, canRecordReleaseData ${Services.telemetry.canRecordReleaseData}`;
|
||||
},
|
||||
};
|
@ -193,5 +193,14 @@ processes_data = GENERATED_FILES['TelemetryProcessData.h']
|
||||
processes_data.script = 'gen_process_data.py'
|
||||
processes_data.inputs = processes_files
|
||||
|
||||
# Add support for GeckoView: please note that building GeckoView
|
||||
# implies having an Android build. The packaging step decides
|
||||
# which files to include. As a consequence, we can simply only
|
||||
# include the GeckoView files on all Android builds.
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
EXTRA_JS_MODULES += [
|
||||
'geckoview/GeckoViewTelemetryController.jsm',
|
||||
]
|
||||
|
||||
with Files('**'):
|
||||
BUG_COMPONENT = ('Toolkit', 'Telemetry')
|
||||
|
Loading…
Reference in New Issue
Block a user