Bug 1298945 - Only show Slow Startup notification if profile is 3 months old. r=MattN
MozReview-Commit-ID: J0bsvtBoEsv
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -840,26 +840,44 @@ BrowserGlue.prototype = {
} catch (e) { }
let totalTime = (averageTime * samples) + currentTime;
samples++;
averageTime = totalTime / samples;
if (samples >= Services.prefs.getIntPref("browser.slowStartup.maxSamples")) {
if (averageTime > Services.prefs.getIntPref("browser.slowStartup.timeThreshold"))
- this._showSlowStartupNotification();
+ this._calculateProfileAgeInDays().then(this._showSlowStartupNotification, null);
averageTime = 0;
samples = 0;
}
Services.prefs.setIntPref("browser.slowStartup.averageTime", averageTime);
Services.prefs.setIntPref("browser.slowStartup.samples", samples);
},
- _showSlowStartupNotification: function () {
+ _calculateProfileAgeInDays: Task.async(function* () {
+ let ProfileAge = Cu.import("resource://gre/modules/ProfileAge.jsm", {}).ProfileAge;
+ let profileAge = new ProfileAge(null, null);
+
+ let creationDate = yield profileAge.created;
+ let resetDate = yield profileAge.reset;
+
+ // if the profile was reset, consider the
+ // reset date for its age.
+ let profileDate = resetDate || creationDate;
+
+ const ONE_DAY = 24 * 60 * 60 * 1000;
+ return (Date.now() - profileDate) / ONE_DAY;
+ }),
+
+ _showSlowStartupNotification: function (profileAge) {
+ if (profileAge < 90) // 3 months
+ return;
+
let win = RecentWindow.getMostRecentBrowserWindow();
if (!win)
return;
let productName = gBrandBundle.GetStringFromName("brandFullName");
let message = win.gNavigatorBundle.getFormattedString("slowStartup.message", [productName]);
let buttons = [