Bug 1134279 - Change Telemetry data producers to use the correct recording flags. r=vladan

This commit is contained in:
Alessio Placitelli 2015-03-23 04:39:00 +01:00
parent 8439bad3f7
commit 2558c3ec2c
13 changed files with 49 additions and 43 deletions

View File

@ -4454,7 +4454,7 @@
<body>
<![CDATA[
// Animation-smoothness telemetry/logging
if (Services.telemetry.canRecord || this._tabAnimationLoggingEnabled) {
if (Services.telemetry.canRecordExtended || this._tabAnimationLoggingEnabled) {
if (aURI == "about:newtab" && (aTab._tPos == 1 || aTab._tPos == 2)) {
// Indicate newtab page animation where other tabs are unaffected
// (for which case, the 2nd or 3rd tabs are good representatives, even if not absolute)

View File

@ -894,8 +894,7 @@ let MozLoopServiceInternal = {
switch(pc.iceConnectionState) {
case "failed":
case "disconnected":
if (Services.telemetry.canSend ||
Services.prefs.getBoolPref("toolkit.telemetry.test")) {
if (Services.telemetry.canRecordExtended) {
this.stageForTelemetryUpload(window, pc);
}
break;

View File

@ -12,10 +12,10 @@ add_task(loadLoopPanel);
* Enable local telemetry recording for the duration of the tests.
*/
add_task(function* test_initialize() {
let oldCanRecord = Services.telemetry.canRecord;
Services.telemetry.canRecord = true;
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(function () {
Services.telemetry.canRecord = oldCanRecord;
Services.telemetry.canRecordExtended = oldCanRecord;
});
});

View File

@ -5,10 +5,10 @@
"use strict";
// So we can test collecting telemetry on the eyedropper
let oldCanRecord = Services.telemetry.canRecord;
Services.telemetry.canRecord = true;
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(function () {
Services.telemetry.canRecord = oldCanRecord;
Services.telemetry.canRecordExtended = oldCanRecord;
});
const HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_BOOLEAN";
const FLAG_HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_PER_USER_FLAG";

View File

@ -96,9 +96,7 @@ PluginContent.prototype = {
return;
}
if (Services.telemetry.canSend) {
this._finishRecordingFlashPluginTelemetry();
}
this._finishRecordingFlashPluginTelemetry();
this.clearPluginDataCache();
},
@ -391,8 +389,7 @@ PluginContent.prototype = {
break;
}
if (Services.telemetry.canSend && this._getPluginInfo(plugin).mimetype ===
"application/x-shockwave-flash") {
if (this._getPluginInfo(plugin).mimetype === "application/x-shockwave-flash") {
this._recordFlashPluginTelemetry(eventType, plugin);
}
@ -426,6 +423,10 @@ PluginContent.prototype = {
},
_recordFlashPluginTelemetry: function (eventType, plugin) {
if (!Services.telemetry.canRecordExtended) {
return;
}
if (!this.flashPluginStats) {
this.flashPluginStats = {
instancesCount: 0,

View File

@ -110,10 +110,10 @@ function testHistogram(histogramId, expectedNonZeroRanges) {
* the test data that will be used by the following tests.
*/
add_task(function test_initialize() {
let oldCanRecord = Services.telemetry.canRecord;
Services.telemetry.canRecord = true;
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
do_register_cleanup(function () {
Services.telemetry.canRecord = oldCanRecord;
Services.telemetry.canRecordExtended = oldCanRecord;
});
let uniqueNumber = 1;

View File

@ -613,13 +613,22 @@ let Impl = {
* Perform telemetry initialization for either chrome or content process.
*/
enableTelemetryRecording: function enableTelemetryRecording(testing) {
// Enable base Telemetry recording, if needed.
#if !defined(MOZ_WIDGET_ANDROID)
Telemetry.canRecordBase =
Preferences.get("datareporting.healthreport.service.enabled", false) ||
Preferences.get("browser.selfsupport.enabled", false);
#else
// FHR recording is always "enabled" on Android (data upload is not).
Telemetry.canRecordBase = true;
#endif
#ifdef MOZILLA_OFFICIAL
if (!Telemetry.canSend && !testing) {
if (!Telemetry.isOfficialTelemetry && !testing) {
// We can't send data; no point in initializing observers etc.
// Only do this for official builds so that e.g. developer builds
// still enable Telemetry based on prefs.
Telemetry.canRecord = false;
Telemetry.canRecordExtended = false;
this._log.config("enableTelemetryRecording - Can't send data, disabling Telemetry recording.");
return false;
}
@ -627,10 +636,10 @@ let Impl = {
let enabled = Preferences.get(PREF_ENABLED, false);
this._server = Preferences.get(PREF_SERVER, undefined);
if (!enabled) {
// Turn off local telemetry if telemetry is disabled.
// This may change once about:telemetry is added.
Telemetry.canRecord = false;
if (!enabled || !Telemetry.canRecordBase) {
// Turn off extended telemetry recording if disabled by preferences or if base/telemetry
// telemetry recording is off.
Telemetry.canRecordExtended = false;
this._log.config("enableTelemetryRecording - Telemetry is disabled, turning off Telemetry recording.");
return false;
}

View File

@ -1378,22 +1378,14 @@ let Impl = {
enableTelemetryRecording: function enableTelemetryRecording(testing) {
#ifdef MOZILLA_OFFICIAL
if (!Telemetry.canSend && !testing) {
// We can't send data; no point in initializing observers etc.
// Only do this for official builds so that e.g. developer builds
// still enable Telemetry based on prefs.
Telemetry.canRecord = false;
if (!Telemetry.isOfficialTelemetry && !testing) {
this._log.config("enableTelemetryRecording - Can't send data, disabling Telemetry recording.");
return false;
}
#endif
let enabled = Preferences.get(PREF_ENABLED, false);
this._server = Preferences.get(PREF_SERVER, undefined);
if (!enabled) {
// Turn off local telemetry if telemetry is disabled.
// This may change once about:telemetry is added.
Telemetry.canRecord = false;
this._log.config("enableTelemetryRecording - Telemetry is disabled, turning off Telemetry recording.");
return false;
}
@ -1709,7 +1701,7 @@ let Impl = {
}
if (aTest) {
return this.send(REASON_TEST_PING);
} else if (Telemetry.canSend) {
} else if (Telemetry.isOfficialTelemetry) {
return this.send(REASON_IDLE_DAILY);
}
},
@ -1740,7 +1732,7 @@ let Impl = {
Services.obs.removeObserver(this, "content-child-shutdown");
this.uninstall();
if (Telemetry.canSend) {
if (Telemetry.isOfficialTelemetry) {
this.sendContentProcessPing(REASON_SAVED_SESSION);
}
break;
@ -1801,7 +1793,7 @@ let Impl = {
// backgrounding), or not (in which case we will delete it on submit, or overwrite
// it on the next backgrounding). Not deleting it is faster, so that's what we do.
case "application-background":
if (Telemetry.canSend) {
if (Telemetry.isOfficialTelemetry) {
let payload = this.getSessionPayload(REASON_SAVED_SESSION, false);
let options = {
retentionDays: RETENTION_DAYS,
@ -1836,7 +1828,7 @@ let Impl = {
this._initialized = false;
};
if (Telemetry.canSend || testing) {
if (Telemetry.isOfficialTelemetry || testing) {
return this.savePendingPings()
.then(() => this._stateSaveSerializer.flushTasks())
#if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)

View File

@ -355,10 +355,10 @@ function test_addons() {
function test_privateMode() {
var h = Telemetry.newHistogram("test::private_mode_boolean", "never", Telemetry.HISTOGRAM_BOOLEAN);
var orig = h.snapshot();
Telemetry.canRecord = false;
Telemetry.canRecordExtended = false;
h.add(1);
do_check_eq(uneval(orig), uneval(h.snapshot()));
Telemetry.canRecord = true;
Telemetry.canRecordExtended = true;
h.add(1);
do_check_neq(uneval(orig), uneval(h.snapshot()));
}

View File

@ -392,7 +392,7 @@ void
nsTerminator::StartWriter()
{
if (!Telemetry::CanRecord()) {
if (!Telemetry::CanRecordExtended()) {
return;
}
nsCOMPtr<nsIFile> profLD;
@ -476,7 +476,7 @@ nsTerminator::UpdateHeartbeat(const char* aTopic)
void
nsTerminator::UpdateTelemetry()
{
if (!Telemetry::CanRecord() || !gWriteReady) {
if (!Telemetry::CanRecordExtended() || !gWriteReady) {
return;
}

View File

@ -194,6 +194,11 @@ function check_telemetry({disabled, metaenabled, metadisabled, upgraded, failed,
}
add_test(function test_setup() {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(function () {
Services.telemetry.canRecordExtended = oldCanRecord;
});
TelemetrySession.setup().then(run_next_test);
});

View File

@ -120,7 +120,7 @@ LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb)
}
// If we have shutdown mode SCM_NOTHING or we can't record then abort
if (gShutdownChecks == SCM_NOTHING || !Telemetry::CanRecord()) {
if (gShutdownChecks == SCM_NOTHING || !Telemetry::CanRecordExtended()) {
return;
}

View File

@ -605,7 +605,7 @@ BackgroundHangMonitor::NotifyActivity()
return;
}
if (Telemetry::CanRecord()) {
if (Telemetry::CanRecordExtended()) {
mThread->NotifyActivity();
}
#endif
@ -622,7 +622,7 @@ BackgroundHangMonitor::NotifyWait()
return;
}
if (Telemetry::CanRecord()) {
if (Telemetry::CanRecordExtended()) {
mThread->NotifyWait();
}
#endif