OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.metricsPrivate 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 (function() { | 11 (function() { |
12 // Switch to the 'test harness' mode when loading from a file or http url. | 12 // Switch to the 'test harness' mode when loading from a file or http url. |
13 // Do this as early as possible because the metrics code depends on | 13 // Do this as early as possible because the metrics code depends on |
14 // chrome private APIs. | 14 // chrome private APIs. |
15 if (document.location.protocol == 'file:' || | 15 if (document.location.protocol == 'file:' || |
16 document.location.protocol == 'http:') { | 16 document.location.protocol == 'http:') { |
17 console.log('created mock script'); | 17 console.log('created mock script'); |
18 document.write('<script src="js/mock_chrome.js"><\57script>'); | 18 document.write('<script src="js/mock_chrome.js"><\57script>'); |
| 19 document.write('<script src="js/file_copy_manager.js"><\57script>'); |
19 } | 20 } |
20 })(); | 21 })(); |
21 | 22 |
22 var metrics = {}; | 23 var metrics = {}; |
23 | 24 |
24 /** | 25 /** |
25 * A map from interval name to interval start timestamp. | 26 * A map from interval name to interval start timestamp. |
26 */ | 27 */ |
27 metrics.intervals = {}; | 28 metrics.intervals = {}; |
28 | 29 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 'min': 1, | 120 'min': 1, |
120 'max': boundaryValue, | 121 'max': boundaryValue, |
121 'buckets': boundaryValue + 1 | 122 'buckets': boundaryValue + 1 |
122 }; | 123 }; |
123 chrome.metricsPrivate.recordValue(metricDescr, index); | 124 chrome.metricsPrivate.recordValue(metricDescr, index); |
124 if (localStorage.logMetrics) { | 125 if (localStorage.logMetrics) { |
125 console.log('chrome.metricsPrivate.recordValue', | 126 console.log('chrome.metricsPrivate.recordValue', |
126 [metricDescr.metricName, index, value]); | 127 [metricDescr.metricName, index, value]); |
127 } | 128 } |
128 }; | 129 }; |
OLD | NEW |