Commit cf87bb1c authored by oka's avatar oka Committed by Commit bot

Files App: Add metrics for background performance.

FileBrowser.Load.BackgroundScript:
  Time to initialize backend script to wait for events.
FileBrowser.Load.BackgroundLaunch:
  Time from onLaunched event is called to the window is created.
FileBrowser.Load.BackgroundRestart:
  Time to create a window on restart.

BUG=675536
TEST=manually confirmed on Linux that sane values are exported in
chrome://histograms

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2585193002
Cr-Commit-Position: refs/heads/master@{#439755}
parent 2d46b12d
......@@ -110095,6 +110095,11 @@ value.
label="Total load time from the moment the Javascript started parsing
till the moment the empty file list is displayed."/>
<suffix name="Script" label="Time to parse Javascript and CSS."/>
<suffix name="BackgroundScript"
label="Time to initialize backend script to wait for events."/>
<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."/>
<affected-histogram name="FileBrowser.Load"/>
</histogram_suffixes>
......@@ -462,6 +462,7 @@ FileBrowserBackground.prototype.onExecute_ = function(action, details) {
* @override
*/
FileBrowserBackground.prototype.onLaunched_ = function() {
metrics.startInterval('Load.BackgroundLaunch');
this.initializationPromise_.then(function() {
if (nextFileManagerWindowID == 0) {
// The app just launched. Remove window state records that are not needed
......@@ -475,7 +476,9 @@ FileBrowserBackground.prototype.onLaunched_ = function() {
}
});
}
launchFileManager(null, undefined, LaunchType.FOCUS_ANY_OR_CREATE);
launchFileManager(
null, undefined, LaunchType.FOCUS_ANY_OR_CREATE,
function() { metrics.recordInterval('Load.BackgroundLaunch'); });
});
};
......@@ -507,10 +510,13 @@ FileBrowserBackground.prototype.onRestarted_ = function() {
if (items.hasOwnProperty(key)) {
var match = key.match(FILES_ID_PATTERN);
if (match) {
metrics.startInterval('Load.BackgroundRestart');
var id = Number(match[1]);
try {
var appState = /** @type {Object} */ (JSON.parse(items[key]));
launchFileManager(appState, id);
launchFileManager(appState, id, undefined, function() {
metrics.recordInterval('Load.BackgroundRestart');
});
} catch (e) {
console.error('Corrupt launch data for ' + id);
}
......@@ -626,3 +632,4 @@ FileBrowserBackground.prototype.initContextMenu_ = function() {
* @type {FileBrowserBackground}
*/
window.background = new FileBrowserBackground();
metrics.recordInterval('Load.BackgroundScript');
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<include src="metrics_start.js">
<include src="../../common/js/lru_cache.js">
<include src="../../common/js/progress_center_common.js">
<include src="../../common/js/importer_common.js">
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Metrics calls to start measurement of script loading. Include
* this as the first script in background_scripts.js (i.e. after the common
* scripts that define the metrics namespace).
*/
metrics.startInterval('Load.BackgroundScript');
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