Backed out changeset b88648a41ed2 (bug 1245891) for talos timeouts

MozReview-Commit-ID: BxDPXC2rA4m
This commit is contained in:
Wes Kocher 2016-02-26 12:29:03 -08:00
parent b10d52b801
commit dfb02515b1
2 changed files with 11 additions and 28 deletions

View File

@ -23,14 +23,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise",
const COLLECT_RESULTS_AFTER_MS = 10000;
const OBSERVED_TOPICS = ["sessionstore-restoring-on-startup", "sessionstore-initiating-manual-restore"];
const TOPICS = ["sessionstore-restoring-on-startup", "sessionstore-initiating-manual-restore"];
this.StartupPerformance = {
/**
* Once we have finished restoring initial tabs, we broadcast on this topic.
*/
RESTORED_TOPIC: "sessionstore-finished-restoring-initial-tabs",
// Instant at which we have started restoration (notification "sessionstore-restoring-on-startup")
_startTimeStamp: null,
@ -55,26 +50,16 @@ this.StartupPerformance = {
_totalNumberOfWindows: 0,
init: function() {
for (let topic of OBSERVED_TOPICS) {
for (let topic of TOPICS) {
Services.obs.addObserver(this, topic, false);
}
},
/**
* Return the timestamp at which we finished restoring the latest tab.
*
* This information is not really interesting until we have finished restoring
* tabs.
*/
get latestRestoredTimeStamp() {
return this._latestRestoredTimeStamp;
},
// Called when restoration starts.
// Record the start timestamp, setup the timer and `this._promiseFinished`.
// Behavior is unspecified if there was already an ongoing measure.
_onRestorationStarts: function(isAutoRestore) {
this._latestRestoredTimeStamp = this._startTimeStamp = Date.now();
this._startTimeStamp = Date.now();
this._totalNumberOfEagerTabs = 0;
this._totalNumberOfTabs = 0;
this._totalNumberOfWindows = 0;
@ -83,7 +68,7 @@ this.StartupPerformance = {
// that's a very unusual case, and not really worth measuring, so let's
// stop listening for further restorations.
for (let topic of OBSERVED_TOPICS) {
for (let topic of TOPICS) {
Services.obs.removeObserver(this, topic);
}
@ -93,9 +78,7 @@ this.StartupPerformance = {
});
this._promiseFinished.then(() => {
try {
Services.obs.notifyObservers(null, this.RESTORED_TOPIC, "");
if (this._latestRestoredTimeStamp == this._startTimeStamp) {
if (!this._latestRestoredTimeStamp) {
// Apparently, we haven't restored any tab.
return;
}
@ -112,6 +95,7 @@ this.StartupPerformance = {
Services.telemetry.getHistogramById("FX_SESSION_RESTORE_NUMBER_OF_TABS_RESTORED").add(this._totalNumberOfTabs);
Services.telemetry.getHistogramById("FX_SESSION_RESTORE_NUMBER_OF_WINDOWS_RESTORED").add(this._totalNumberOfWindows);
// Reset
this._startTimeStamp = null;
} catch (ex) {

View File

@ -16,11 +16,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
"resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "StartupPerformance",
"resource://gre/modules/sessionstore/StartupPerformance.jsm");
// Observer Service topics.
const STARTUP_TOPIC = "profile-after-change";
const RESTORED_TOPIC = "sessionstore-windows-restored";
// Process Message Manager topics.
const MSG_REQUEST = "session-restore-test?duration";
@ -46,7 +45,7 @@ nsSessionRestoreTalosTest.prototype = {
case STARTUP_TOPIC:
this.init();
break;
case StartupPerformance.RESTORED_TOPIC:
case RESTORED_TOPIC:
this.onRestored();
break;
default:
@ -58,7 +57,7 @@ nsSessionRestoreTalosTest.prototype = {
* Perform initialization on profile-after-change.
*/
init: function() {
Services.obs.addObserver(this, StartupPerformance.RESTORED_TOPIC, false);
Services.obs.addObserver(this, RESTORED_TOPIC, false);
},
/**
@ -66,9 +65,9 @@ nsSessionRestoreTalosTest.prototype = {
*/
onRestored: function() {
setTimeout(function() {
// `StartupPerformance.latestRestoredTimeStamp` actually becomes available only on the next tick.
// `sessionRestored` actually becomes available only on the next tick.
let startup_info = Services.startup.getStartupInfo();
let duration = StartupPerformance.latestRestoredTimeStamp - startup_info.sessionRestoreInit;
let duration = startup_info.sessionRestored - startup_info.sessionRestoreInit;
// Broadcast startup duration information immediately, in case the talos
// page is already loaded.