Bug 1462725 - Uninit study on Firefox shutdown; r=rhelmer, a=RyanVM
authorBianca Danforth <bdanforth@mozilla.com>
Mon, 04 Jun 2018 16:20:54 -0700
changeset 473704 91d7b8c373a527d918d2abc997517a8d30cd23e7
parent 473703 e948d63a5eeda191c29a7f2a5201aa8950953c9f
child 473705 284d16323d515f011dc282e358b227b674d58c75
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer, RyanVM
bugs1462725
milestone61.0
Bug 1462725 - Uninit study on Firefox shutdown; r=rhelmer, a=RyanVM Intended to undo study-related changes that don't need to persist between sessions: clear prefs, remove observers, etc. MozReview-Commit-ID: GsoDhxf6CVJ
browser/components/nsBrowserGlue.js
browser/modules/SavantShieldStudy.jsm
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1073,16 +1073,18 @@ BrowserGlue.prototype = {
     DateTimePickerHelper.uninit();
 
     // Browser errors are only collected on Nightly
     if (AppConstants.NIGHTLY_BUILD && AppConstants.MOZ_DATA_REPORTING) {
       this.browserErrorReporter.uninit();
     }
 
     Normandy.uninit();
+
+    SavantShieldStudy.uninit();
   },
 
   // All initial windows have opened.
   _onWindowsRestored: function BG__onWindowsRestored() {
     if (this._windowsWereRestored) {
       return;
     }
     this._windowsWereRestored = true;
--- a/browser/modules/SavantShieldStudy.jsm
+++ b/browser/modules/SavantShieldStudy.jsm
@@ -32,16 +32,19 @@ class SavantShieldStudyClass {
     this.TelemetryEvents = new TelemetryEvents(this.STUDY_TELEMETRY_CATEGORY);
 
     // TODO: implement eligibility (#13)
     const isEligible = true;
     if (!isEligible) {
       this.endStudy("ineligible");
       return;
     }
+
+    // TODO check expiration, add study duration override pref
+
     // check the pref in case Normandy flipped it on before we could add the pref listener
     this.shouldCollect = Services.prefs.getBoolPref(this.STUDY_PREF);
     if (this.shouldCollect) {
       this.TelemetryEvents.enableCollection();
     }
     Services.prefs.addObserver(this.STUDY_PREF, this);
   }
 
@@ -65,20 +68,17 @@ class SavantShieldStudyClass {
   endStudy(reason) {
     this.TelemetryEvents.disableCollection();
     // Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, "end_study", reason);
     this.uninit();
   }
 
   // Called on every Firefox shutdown and endStudy
   uninit() {
-    // TODO: Make sure uninit() is called on every Firefox shutdown (look inside
-    // nsBrowserGlue.js to see where Normandy uninits)
-    // TODO: See what happens during Normandy's uninit method to ensure nothing
-    // is forgotten.
+    // TODO: clear study expiration override pref and remove its listener
     Services.prefs.removeObserver(this.STUDY_PREF, this);
     Services.prefs.clearUserPref(this.STUDY_PREF);
     Services.prefs.clearUserPref(PREF_LOG_LEVEL);
   }
 }
 
 const SavantShieldStudy = new SavantShieldStudyClass();