Index: chrome/browser/resources/task_manager/metrics.js |
diff --git a/chrome/browser/resources/task_manager/metrics.js b/chrome/browser/resources/task_manager/metrics.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..36ff9dd1b1b45b763745d7e159e0ffb6bb87c766 |
--- /dev/null |
+++ b/chrome/browser/resources/task_manager/metrics.js |
@@ -0,0 +1,52 @@ |
+// 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.metricsPrivate API. |
+ * |
+ * To be included as a first script in main.html |
+ */ |
+ |
+var metrics = {}; |
arv (Not doing code reviews)
2011/12/19 22:57:14
I'm a bit confused. I thought this would do a chro
yoshiki
2011/12/20 15:18:25
You're right. I intended to add recording histogra
|
+ |
+metrics.intervals = {}; |
+ |
+metrics.startInterval = function(name) { |
+ metrics.intervals[name] = Date.now(); |
+}; |
+ |
+metrics.startInterval('Load.Total'); |
+metrics.startInterval('Load.Script'); |
+ |
+metrics.convertName_ = function(name) { |
+ return 'TaskManager.' + name; |
+}; |
+ |
+metrics.decorate = function(name) { |
+ this[name] = function() { |
+ var args = Array.apply(null, arguments); |
arv (Not doing code reviews)
2011/12/19 22:57:14
This is error prone. If argument.length == 1 and a
|
+ args[0] = metrics.convertName_(args[0]); |
+ |
+ // TODO(yoshiki): Enables the recoading metrixes of loading times. |
arv (Not doing code reviews)
2011/12/19 22:57:14
Is "metrixes" a real word?
|
+ // chrome.metricsPrivate[name].apply(chrome.metricsPrivate, args); |
arv (Not doing code reviews)
2011/12/19 22:57:14
Look into chrome.send. We already have a chrome se
|
+ |
+ // Outputs log to Console in inspector if the flag is enabled. |
+ if (localStorage.logMetrics) { |
arv (Not doing code reviews)
2011/12/19 22:57:14
no {} here
|
+ console.log('chrome.metricsPrivate.' + name, args); |
+ } |
+ } |
+}; |
+ |
+metrics.decorate('recordMediumCount'); |
+metrics.decorate('recordSmallCount'); |
+metrics.decorate('recordTime'); |
+metrics.decorate('recordUserAction'); |
+ |
+metrics.recordInterval = function(name) { |
+ if (name in metrics.intervals) { |
James Hawkins
2011/12/19 18:35:56
Remove braces.
|
+ metrics.recordTime(name, Date.now() - metrics.intervals[name]); |
+ } else { |
+ console.error('Unknown interval: ' + name); |
+ } |
+}; |