mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 956138 - [Australis] Have BrowserUITelemetry wait for sessionstore-windows-restored before gathering measurements. r=jaws.
This commit is contained in:
parent
1e0f81d3af
commit
503b756b3f
@ -130,12 +130,18 @@ this.BrowserUITelemetry = {
|
||||
init: function() {
|
||||
UITelemetry.addSimpleMeasureFunction("toolbars",
|
||||
this.getToolbarMeasures.bind(this));
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
|
||||
Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "browser-delayed-startup-finished") {
|
||||
this._registerWindow(aSubject);
|
||||
switch(aTopic) {
|
||||
case "sessionstore-windows-restored":
|
||||
this._gatherFirstWindowMeasurements();
|
||||
break;
|
||||
case "browser-delayed-startup-finished":
|
||||
this._registerWindow(aSubject);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -200,16 +206,23 @@ this.BrowserUITelemetry = {
|
||||
},
|
||||
|
||||
_firstWindowMeasurements: null,
|
||||
_registerWindow: function(aWindow) {
|
||||
// We'll gather measurements on the first non-popup window that opens
|
||||
// after it has painted. We do this here instead of waiting for
|
||||
// UITelemetry to ask for our measurements because at that point
|
||||
// all browser windows have probably been closed, since the vast
|
||||
// majority of saved-session pings are gathered during shutdown.
|
||||
if (!this._firstWindowMeasurements && aWindow.toolbar.visible) {
|
||||
this._firstWindowMeasurements = this._getWindowMeasurements(aWindow);
|
||||
}
|
||||
_gatherFirstWindowMeasurements: function() {
|
||||
// We'll gather measurements as soon as the session has restored.
|
||||
// We do this here instead of waiting for UITelemetry to ask for
|
||||
// our measurements because at that point all browser windows have
|
||||
// probably been closed, since the vast majority of saved-session
|
||||
// pings are gathered during shutdown.
|
||||
let win = RecentWindow.getMostRecentBrowserWindow({
|
||||
private: false,
|
||||
allowPopups: false,
|
||||
});
|
||||
|
||||
// If there are no such windows, we're out of luck. :(
|
||||
this._firstWindowMeasurements = win ? this._getWindowMeasurements(win)
|
||||
: {};
|
||||
},
|
||||
|
||||
_registerWindow: function(aWindow) {
|
||||
aWindow.addEventListener("unload", this);
|
||||
let document = aWindow.document;
|
||||
|
||||
@ -419,4 +432,4 @@ function getIDBasedOnFirstIDedAncestor(aNode) {
|
||||
}
|
||||
|
||||
return aNode.id;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user