summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 10:36:02 +0000
committerkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 10:36:02 +0000
commit1b4a9e4f41a93bbcd32ba72e26cfa23f23219a3b (patch)
tree4d7e19166c40d9a12b8f6e922fddb65fc1625e6c
parent442b7c62831111e3224ee1005686c435b464536b (diff)
downloadchromium_src-1b4a9e4f41a93bbcd32ba72e26cfa23f23219a3b.zip
chromium_src-1b4a9e4f41a93bbcd32ba72e26cfa23f23219a3b.tar.gz
chromium_src-1b4a9e4f41a93bbcd32ba72e26cfa23f23219a3b.tar.bz2
Merge 109017 - [filebrowser] Histogram for the file browser's open time.
BUG=chromium-os:20553 TEST= Review URL: http://codereview.chromium.org/8490014 TBR=kaznacheev@chromium.org Review URL: http://codereview.chromium.org/8478026 git-svn-id: svn://svn.chromium.org/chrome/branches/912/src@109410 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/file_manager/js/file_manager.js8
-rw-r--r--chrome/browser/resources/file_manager/js/main.js11
-rw-r--r--chrome/browser/resources/file_manager/js/metrics.js39
-rw-r--r--chrome/browser/resources/file_manager/js/mock_chrome.js7
-rw-r--r--chrome/browser/resources/file_manager/main.html10
-rw-r--r--chrome/browser/resources/file_manager/manifest.json1
6 files changed, 74 insertions, 2 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 9b27624..2f694a2 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -56,6 +56,8 @@ function FileManager(dialogDom, filesystem, rootEntries) {
this.document_ = dialogDom.ownerDocument;
this.dialogType_ = this.params_.type || FileManager.DialogType.FULL_PAGE;
+ metrics.recordAction('Create.' + this.dialogType_);
+
this.alert = new cr.ui.dialogs.AlertDialog(this.dialogDom_);
this.confirm = new cr.ui.dialogs.ConfirmDialog(this.dialogDom_);
this.prompt = new cr.ui.dialogs.PromptDialog(this.dialogDom_);
@@ -2990,8 +2992,11 @@ FileManager.prototype = {
var self = this;
var reader;
+ metrics.startInterval('ScanDirectory');
+
function onReadSome(entries) {
if (entries.length == 0) {
+ metrics.recordTime('ScanDirectory');
if (opt_callback)
opt_callback();
return;
@@ -3042,6 +3047,7 @@ FileManager.prototype = {
spliceArgs.unshift(0, 0); // index, deleteCount
self.dataModel_.splice.apply(self.dataModel_, spliceArgs);
+ metrics.recordTime('ScanDirectory');
if (opt_callback)
opt_callback();
};
@@ -3289,6 +3295,8 @@ FileManager.prototype = {
};
FileManager.prototype.createNewFolder = function(name, opt_callback) {
+ metrics.recordAction('CreateNewFolder');
+
var self = this;
function onSuccess(dirEntry) {
diff --git a/chrome/browser/resources/file_manager/js/main.js b/chrome/browser/resources/file_manager/js/main.js
index dffad2a..3e0f1bf 100644
--- a/chrome/browser/resources/file_manager/js/main.js
+++ b/chrome/browser/resources/file_manager/js/main.js
@@ -16,8 +16,12 @@ function init() {
var rootPaths = ['Downloads', 'removable', 'archive', 'tmp'];
function onEntriesFound(filesystem, entries) {
+ metrics.recordTime('EnumerateRoots');
FileManager.initStrings(function () {
+ metrics.startInterval('Construct');
fileManager = new FileManager(document.body, filesystem, entries);
+ metrics.recordTime('Construct');
+ metrics.recordTime('TotalLoad');
// We're ready to run. Tests can monitor for this state with
// ExtensionTestMessageListener listener("ready");
// ASSERT_TRUE(listener.WaitUntilSatisfied());
@@ -26,6 +30,7 @@ function init() {
}
function onFileSystemFound(filesystem) {
+ metrics.recordTime('RequestLocalFileSystem');
console.log('Found filesystem: ' + filesystem.name, filesystem);
var entries = [];
@@ -42,6 +47,7 @@ function init() {
}
}
+ metrics.startInterval('EnumerateRoots');
if (filesystem.name.match(/^chrome-extension_\S+:external/i)) {
// We've been handed the local filesystem, whose root directory
// cannot be enumerated.
@@ -54,6 +60,7 @@ function init() {
util.installFileErrorToString();
- console.log('Requesting filesystem.');
- chrome.fileBrowserPrivate.requestLocalFileSystem(onFileSystemFound);
+ console.log('Requesting filesystem.');
+ metrics.startInterval('RequestLocalFileSystem');
+ chrome.fileBrowserPrivate.requestLocalFileSystem(onFileSystemFound);
}
diff --git a/chrome/browser/resources/file_manager/js/metrics.js b/chrome/browser/resources/file_manager/js/metrics.js
new file mode 100644
index 0000000..8d52f17
--- /dev/null
+++ b/chrome/browser/resources/file_manager/js/metrics.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2011 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 Utility methods for accessing chrome.experimental.metrics API.
+ *
+ * To be included as a first script in main.html
+ */
+
+var metrics = {};
+
+metrics.intervals = {};
+
+metrics.startInterval = function(name) {
+ metrics.intervals[name] = Date.now();
+};
+
+metrics.startInterval('TotalLoad');
+metrics.startInterval('ScriptParse');
+
+metrics.convertName_ = function(name) {
+ // chrome.experimental.metrics will append extension ID after the last dot.
+ return 'FileBrowser.' + name + '.';
+};
+
+metrics.recordTime = function(name) {
+ if (name in metrics.intervals) {
+ var elapsed = Date.now() - metrics.intervals[name];
+ console.log(name + ': ' + elapsed + 'ms');
+ chrome.experimental.metrics.recordTime(metrics.convertName_(name), elapsed);
+ } else {
+ console.error('Unknown interval: ' + name);
+ }
+};
+
+metrics.recordAction = function(name) {
+ chrome.experimental.metrics.recordUserAction(metrics.convertName_(name));
+}; \ No newline at end of file
diff --git a/chrome/browser/resources/file_manager/js/mock_chrome.js b/chrome/browser/resources/file_manager/js/mock_chrome.js
index 43f62d7..df396ec 100644
--- a/chrome/browser/resources/file_manager/js/mock_chrome.js
+++ b/chrome/browser/resources/file_manager/js/mock_chrome.js
@@ -388,3 +388,10 @@ chrome.tabs = {
window.open(createOptions.url);
}
};
+
+chrome.experimental = {
+ metrics: {
+ recordTime: function() {},
+ recordUserAction: function() {}
+ }
+};
diff --git a/chrome/browser/resources/file_manager/main.html b/chrome/browser/resources/file_manager/main.html
index c22aad8..17d6eed 100644
--- a/chrome/browser/resources/file_manager/main.html
+++ b/chrome/browser/resources/file_manager/main.html
@@ -6,6 +6,10 @@
-->
<html>
<head>
+ <!-- metrics.js initiates load performance tracking
+ so we want to parse it as early as possible -->
+ <script src="js/metrics.js"></script>
+
<script>
// Resources from shared locations are loaded dynamically, so we can
// get them from file:// when running as a normal web page, and from
@@ -83,6 +87,12 @@
<script src="js/main.js"></script>
<script src="js/metadata_provider.js"></script>
+ <!-- For accurate load performance tracking
+ place all scripts above this line -->
+ <script>
+ metrics.recordTime('ScriptParse');
+ </script>
+
<!-- We have to set some default title, or chrome will use the page
-- name. As soon as we init and change to a directory, we'll use
-- the directory as the page title. Until then, have a unicode glyph
diff --git a/chrome/browser/resources/file_manager/manifest.json b/chrome/browser/resources/file_manager/manifest.json
index e05e4b5..a881300 100644
--- a/chrome/browser/resources/file_manager/manifest.json
+++ b/chrome/browser/resources/file_manager/manifest.json
@@ -16,6 +16,7 @@
"unlimitedStorage",
"chrome://extension-icon/",
"chrome://resources/",
+ "experimental",
"tabs"
],
"app": {