Bug 830489 - Delay initializing FHR database on first run; r=rnewman

This commit is contained in:
Gregory Szorc 2013-02-05 20:25:48 -08:00
parent d5ce67a3e1
commit d87359ad63
2 changed files with 22 additions and 3 deletions

View File

@ -17,6 +17,7 @@ const SESSIONS_BRANCH = ROOT_BRANCH + "sessions.";
const HEALTHREPORT_BRANCH = ROOT_BRANCH + "healthreport."; const HEALTHREPORT_BRANCH = ROOT_BRANCH + "healthreport.";
const HEALTHREPORT_LOGGING_BRANCH = HEALTHREPORT_BRANCH + "logging."; const HEALTHREPORT_LOGGING_BRANCH = HEALTHREPORT_BRANCH + "logging.";
const DEFAULT_LOAD_DELAY_MSEC = 10 * 1000; const DEFAULT_LOAD_DELAY_MSEC = 10 * 1000;
const DEFAULT_LOAD_DELAY_FIRST_RUN_MSEC = 60 * 1000;
/** /**
* The Firefox Health Report XPCOM service. * The Firefox Health Report XPCOM service.
@ -44,7 +45,10 @@ const DEFAULT_LOAD_DELAY_MSEC = 10 * 1000;
* In order to not adversely impact application start time, the `HealthReporter` * In order to not adversely impact application start time, the `HealthReporter`
* instance is not initialized until a few seconds after "final-ui-startup." * instance is not initialized until a few seconds after "final-ui-startup."
* The exact delay is configurable via preferences so it can be adjusted with * The exact delay is configurable via preferences so it can be adjusted with
* a hotfix extension if the default value is ever problematic. * a hotfix extension if the default value is ever problematic. Because of the
* overhead with the initial creation of the database, the first run is delayed
* even more than subsequent runs. This does mean that the first moments of
* browser activity may be lost by FHR.
* *
* Shutdown of the `HealthReporter` instance is handled completely within the * Shutdown of the `HealthReporter` instance is handled completely within the
* instance (it registers observers on initialization). See the notes on that * instance (it registers observers on initialization). See the notes on that
@ -136,8 +140,16 @@ DataReportingService.prototype = Object.freeze({
return; return;
} }
let delayInterval = this._prefs.get("service.loadDelayMsec") || let haveFirstRun = this._prefs.get("service.firstRun", false);
DEFAULT_LOAD_DELAY_MSEC; let delayInterval;
if (haveFirstRun) {
delayInterval = this._prefs.get("service.loadDelayMsec") ||
DEFAULT_LOAD_DELAY_MSEC;
} else {
delayInterval = this._prefs.get("service.loadDelayFirstRunMsec") ||
DEFAULT_LOAD_DELAY_FIRST_RUN_MSEC;
}
// Delay service loading a little more so things have an opportunity // Delay service loading a little more so things have an opportunity
// to cool down first. // to cool down first.
@ -239,6 +251,12 @@ DataReportingService.prototype = Object.freeze({
this._healthReporter = new ns.HealthReporter(HEALTHREPORT_BRANCH, this._healthReporter = new ns.HealthReporter(HEALTHREPORT_BRANCH,
this.policy, this.policy,
this.sessionRecorder); this.sessionRecorder);
// Wait for initialization to finish so if a shutdown occurs before init
// has finished we don't adversely affect app startup on next run.
this._healthReporter.onInit().then(function onInit() {
this._prefs.set("service.firstRun", true);
}.bind(this));
}, },
}); });

View File

@ -19,6 +19,7 @@ pref("datareporting.healthreport.uploadEnabled", true);
pref("datareporting.healthreport.service.enabled", true); pref("datareporting.healthreport.service.enabled", true);
pref("datareporting.healthreport.service.loadDelayMsec", 10000); pref("datareporting.healthreport.service.loadDelayMsec", 10000);
pref("datareporting.healthreport.service.loadDelayFirstRunMsec", 60000);
pref("datareporting.healthreport.service.providerCategories", "healthreport-js-provider"); pref("datareporting.healthreport.service.providerCategories", "healthreport-js-provider");
pref("datareporting.healthreport.about.glossaryUrl", "https://services.mozilla.com/healthreport/glossary.html"); pref("datareporting.healthreport.about.glossaryUrl", "https://services.mozilla.com/healthreport/glossary.html");