Commit 574d1b6b authored by oka's avatar oka Committed by Commit bot

Files App: add more performance metrics for foreground initialization.

FileBrowser.Load.ImportElements:
    Time to initialize the polymer elements.
FileBrowser.Load.InitBackgroundPage:
    Time to initialize the background page.
FileBrowser.Load.InitDocuments:
    Time to initialize the background page and the elements.
FileBrowser.Load.InitSettings:
    Time to restore user settings.
FileBrowser.Load.InitUI:
    Time to initialize all UI after all elements are initialized.

BUG=675536
TEST=manually confirmed on Linux that the above values are exported to chrome://histograms.

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2589693002
Cr-Commit-Position: refs/heads/master@{#439769}
parent aaa61214
......@@ -110100,6 +110100,15 @@ value.
<suffix name="BackgroundLaunch"
label="Time from onLaunched event is called to the window is created."/>
<suffix name="BackgroundRestart" label="Time to create a window on restart."/>
<suffix name="ImportElements"
label="Time to initialize the polymer elements."/>
<suffix name="InitBackgroundPage"
label="Time to initialize the background page."/>
<suffix name="InitDocuments"
label="Time to initialize the background page and the elements."/>
<suffix name="InitSettings" label="Time to restore user settings."/>
<suffix name="InitUI"
label="Time to initialize all UI after all elements are initialized."/>
<affected-histogram name="FileBrowser.Load"/>
</histogram_suffixes>
......@@ -10,11 +10,17 @@ window.Polymer.dom = 'shadow';
* elements for file manager UI are loaded.
*/
window.importElementsPromise = new Promise(function(resolve, reject) {
var startTime = Date.now();
var link = document.createElement('link');
link.rel = 'import';
link.href = 'foreground/elements/elements_bundle.html';
link.setAttribute('async', '');
link.onload = resolve;
link.onload = function() {
chrome.metricsPrivate.recordTime(
'FileBrowser.Load.ImportElements', Date.now() - startTime);
resolve();
};
link.onerror = reject;
document.head.appendChild(link);
});
......@@ -466,9 +466,13 @@ FileManager.prototype = /** @struct */ {
* @private
*/
FileManager.prototype.startInitSettings_ = function() {
metrics.startInterval('Load.InitSettings');
this.appStateController_ = new AppStateController(this.dialogType);
return new Promise(function(resolve) {
this.appStateController_.loadInitialViewOptions().then(resolve);
this.appStateController_.loadInitialViewOptions().then(function() {
metrics.recordInterval('Load.InitSettings');
resolve();
});
}.bind(this));
};
......@@ -715,16 +719,20 @@ FileManager.prototype = /** @struct */ {
this.dialogDom_ = dialogDom;
this.document_ = this.dialogDom_.ownerDocument;
metrics.startInterval('Load.InitDocuments');
return Promise.all([
this.initBackgroundPagePromise_,
window.importElementsPromise
]).then(function() {
metrics.recordInterval('Load.InitDocuments');
metrics.startInterval('Load.InitUI');
this.initEssentialUI_();
this.initAdditionalUI_();
return this.initSettingsPromise_;
}.bind(this)).then(function() {
this.initFileSystemUI_();
this.initUIFocus_();
metrics.recordInterval('Load.InitUI');
}.bind(this));
};
......@@ -770,6 +778,7 @@ FileManager.prototype = /** @struct */ {
*/
FileManager.prototype.startInitBackgroundPage_ = function() {
return new Promise(function(resolve) {
metrics.startInterval('Load.InitBackgroundPage');
chrome.runtime.getBackgroundPage(/** @type {function(Window=)} */ (
function(opt_backgroundPage) {
assert(opt_backgroundPage);
......@@ -787,6 +796,7 @@ FileManager.prototype = /** @struct */ {
this.backgroundPage_.background.mediaScanner;
this.historyLoader_ =
this.backgroundPage_.background.historyLoader;
metrics.recordInterval('Load.InitBackgroundPage');
resolve();
}.bind(this));
}.bind(this)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment