Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: chrome/browser/resources/file_manager/js/metrics.js

Issue 8548013: Moving experimental.metrics API to metricsPrivate (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Utility methods for accessing chrome.experimental.metrics API. 6 * @fileoverview Utility methods for accessing chrome.metricsPrivate API.
7 * 7 *
8 * To be included as a first script in main.html 8 * To be included as a first script in main.html
9 */ 9 */
10 10
11 var metrics = {}; 11 var metrics = {};
12 12
13 metrics.intervals = {}; 13 metrics.intervals = {};
14 14
15 metrics.startInterval = function(name) { 15 metrics.startInterval = function(name) {
16 metrics.intervals[name] = Date.now(); 16 metrics.intervals[name] = Date.now();
17 }; 17 };
18 18
19 metrics.startInterval('TotalLoad'); 19 metrics.startInterval('TotalLoad');
20 metrics.startInterval('ScriptParse'); 20 metrics.startInterval('ScriptParse');
21 21
22 metrics.convertName_ = function(name) { 22 metrics.convertName_ = function(name) {
23 // chrome.experimental.metrics will append extension ID after the last dot. 23 return 'FileBrowser.' + name;
24 return 'FileBrowser.' + name + '.';
25 }; 24 };
26 25
27 metrics.recordTime = function(name) { 26 metrics.recordTime = function(name) {
28 if (name in metrics.intervals) { 27 if (name in metrics.intervals) {
29 var elapsed = Date.now() - metrics.intervals[name]; 28 var elapsed = Date.now() - metrics.intervals[name];
30 console.log(name + ': ' + elapsed + 'ms'); 29 console.log(name + ': ' + elapsed + 'ms');
31 chrome.experimental.metrics.recordTime(metrics.convertName_(name), elapsed); 30 chrome.metricsPrivate.recordTime(metrics.convertName_(name), elapsed);
32 } else { 31 } else {
33 console.error('Unknown interval: ' + name); 32 console.error('Unknown interval: ' + name);
34 } 33 }
35 }; 34 };
36 35
37 metrics.recordAction = function(name) { 36 metrics.recordAction = function(name) {
38 chrome.experimental.metrics.recordUserAction(metrics.convertName_(name)); 37 chrome.metricsPrivate.recordUserAction(metrics.convertName_(name));
39 }; 38 };
40 39
41 metrics.reportCount = function(name, value) { 40 metrics.reportCount = function(name, value) {
42 chrome.experimental.metrics. 41 chrome.metricsPrivate.recordMediumCount(metrics.convertName_(name), value);
43 recordMediumCount(metrics.convertName_(name), value);
44 }; 42 };
45 43
46 metrics.recordEnum = function(name, value, validValues) { 44 metrics.recordEnum = function(name, value, validValues) {
47 var index = validValues.indexOf(value); 45 var index = validValues.indexOf(value);
48 46
49 // Collect invalid values in the extra bucket at the end. 47 // Collect invalid values in the extra bucket at the end.
50 if (index < 0) index = validValues.length; 48 if (index < 0) index = validValues.length;
51 49
52 chrome.experimental.metrics.recordValue({ 50 chrome.metricsPrivate.recordValue({
53 'metricName': metrics.convertName_(name), 51 'metricName': metrics.convertName_(name),
54 'type': 'histogram-linear', 52 'type': 'histogram-linear',
55 'min': 0, 53 'min': 0,
56 'max': validValues.length, 54 'max': validValues.length,
57 'buckets': validValues.length + 1 55 'buckets': validValues.length + 1
58 }, 56 },
59 index); 57 index);
60 }; 58 };
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_metrics_module.cc ('k') | chrome/browser/resources/file_manager/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698