Commit 527ef366 authored by michaelpg's avatar michaelpg Committed by Commit bot

Update chrome.metricsPrivate externs and make closure fixes

In preparation for moving metricsPrivate to //extensions, re-generate the
externs file and fix outdated types.

BUG=647397
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2346683004
Cr-Commit-Position: refs/heads/master@{#419120}
parent a0d87418
...@@ -277,7 +277,7 @@ var GoogleNowEvent = { ...@@ -277,7 +277,7 @@ var GoogleNowEvent = {
function recordEvent(event) { function recordEvent(event) {
var metricDescription = { var metricDescription = {
metricName: 'GoogleNow.Event', metricName: 'GoogleNow.Event',
type: 'histogram-linear', type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
min: 1, min: 1,
max: GoogleNowEvent.EVENTS_TOTAL, max: GoogleNowEvent.EVENTS_TOTAL,
buckets: GoogleNowEvent.EVENTS_TOTAL + 1 buckets: GoogleNowEvent.EVENTS_TOTAL + 1
......
...@@ -14,7 +14,7 @@ cr.define('hotword.metrics', function() { ...@@ -14,7 +14,7 @@ cr.define('hotword.metrics', function() {
function recordEnum(name, value, maxValue) { function recordEnum(name, value, maxValue) {
var metricDesc = { var metricDesc = {
'metricName': name, 'metricName': name,
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1, 'min': 1,
'max': maxValue, 'max': maxValue,
'buckets': maxValue + 1 'buckets': maxValue + 1
......
...@@ -23,7 +23,7 @@ chrome.test.runTests([ ...@@ -23,7 +23,7 @@ chrome.test.runTests([
function recordValue() { function recordValue() {
chrome.metricsPrivate.recordValue({ chrome.metricsPrivate.recordValue({
'metricName': 'test.h.1', 'metricName': 'test.h.1',
'type': 'histogram-log', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 1, 'min': 1,
'max': 100, 'max': 100,
'buckets': 50 'buckets': 50
...@@ -31,7 +31,7 @@ chrome.test.runTests([ ...@@ -31,7 +31,7 @@ chrome.test.runTests([
chrome.metricsPrivate.recordValue({ chrome.metricsPrivate.recordValue({
'metricName': 'test.h.2', 'metricName': 'test.h.2',
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1, 'min': 1,
'max': 200, 'max': 200,
'buckets': 50 'buckets': 50
...@@ -108,28 +108,28 @@ chrome.test.runTests([ ...@@ -108,28 +108,28 @@ chrome.test.runTests([
function testBucketSizeChanges() { function testBucketSizeChanges() {
var linear1 = { var linear1 = {
'metricName': 'test.bucketchange.linear', 'metricName': 'test.bucketchange.linear',
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 0, 'min': 0,
'max': 100, 'max': 100,
'buckets': 10 'buckets': 10
}; };
var linear2 = { var linear2 = {
'metricName': 'test.bucketchange.linear', 'metricName': 'test.bucketchange.linear',
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 0, 'min': 0,
'max': 100, 'max': 100,
'buckets': 20 'buckets': 20
}; };
var log1 = { var log1 = {
'metricName': 'test.bucketchange.log', 'metricName': 'test.bucketchange.log',
'type': 'histogram-log', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 0, 'min': 0,
'max': 100, 'max': 100,
'buckets': 10 'buckets': 10
}; };
var log2 = { var log2 = {
'metricName': 'test.bucketchange.log', 'metricName': 'test.bucketchange.log',
'type': 'histogram-log', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 0, 'min': 0,
'max': 100, 'max': 100,
'buckets': 20 'buckets': 20
......
...@@ -82,7 +82,7 @@ function createPlatformDelegate(strings) { ...@@ -82,7 +82,7 @@ function createPlatformDelegate(strings) {
var index = (value >= 0 && value < enumSize) ? value : enumSize; var index = (value >= 0 && value < enumSize) ? value : enumSize;
chrome.metricsPrivate.recordValue({ chrome.metricsPrivate.recordValue({
'metricName': 'WebstoreWidgetApp.' + enumName, 'metricName': 'WebstoreWidgetApp.' + enumName,
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1, 'min': 1,
'max': enumSize, 'max': enumSize,
'buckets': enumSize + 1 'buckets': enumSize + 1
......
...@@ -603,7 +603,7 @@ function recordState(state) { ...@@ -603,7 +603,7 @@ function recordState(state) {
var metricDescription = { var metricDescription = {
metricName: 'Chromoting.Connections', metricName: 'Chromoting.Connections',
type: 'histogram-linear', type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
// According to histogram.h, minimum should be 1. Values less than minimum // According to histogram.h, minimum should be 1. Values less than minimum
// end up in the 0th bucket. // end up in the 0th bucket.
min: 1, min: 1,
......
...@@ -249,6 +249,11 @@ chromeMocks.identity; ...@@ -249,6 +249,11 @@ chromeMocks.identity;
/** @constructor */ /** @constructor */
chromeMocks.MetricsPrivate = function() {}; chromeMocks.MetricsPrivate = function() {};
chromeMocks.MetricsPrivate.prototype.MetricTypeType = {
HISTOGRAM_LOG: 'histogram-log',
HISTOGRAM_LINEAR: 'histogram-linear',
};
chromeMocks.MetricsPrivate.prototype.recordValue = function() {}; chromeMocks.MetricsPrivate.prototype.recordValue = function() {};
/** @type {chromeMocks.MetricsPrivate} */ /** @type {chromeMocks.MetricsPrivate} */
......
// Copyright 2014 The Chromium Authors. All rights reserved. // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This file was generated by:
// tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
// 'chrome.metricsPrivate.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
/** @fileoverview Externs generated from namespace: metricsPrivate */ /** @fileoverview Externs generated from namespace: metricsPrivate */
/**
* @const
*/
chrome.metricsPrivate = {};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/metricsPrivate#type-MetricTypeType
*/
chrome.metricsPrivate.MetricTypeType = {
HISTOGRAM_LOG: 'histogram-log',
HISTOGRAM_LINEAR: 'histogram-linear',
};
/** /**
* Describes the type of metric that is to be collected. * Describes the type of metric that is to be collected.
* @typedef {{ * @typedef {{
* metricName: string, * metricName: string,
* type: string, * type: !chrome.metricsPrivate.MetricTypeType,
* min: number, * min: number,
* max: number, * max: number,
* buckets: number * buckets: number
* }} * }}
* @see https://developer.chrome.com/extensions/metricsPrivate#type-MetricType
*/ */
var MetricType; chrome.metricsPrivate.MetricType;
/**
* @const
*/
chrome.metricsPrivate = {};
/** /**
* Returns true if the user opted in to sending crash reports. * Returns true if the user opted in to sending crash reports.
* @param {Function} callback * @param {function(boolean):void} callback
* @see https://developer.chrome.com/extensions/metricsPrivate#method-getIsCrashReportingEnabled
*/ */
chrome.metricsPrivate.getIsCrashReportingEnabled = function(callback) {}; chrome.metricsPrivate.getIsCrashReportingEnabled = function(callback) {};
/** /**
* Returns the group name chosen for the named trial, or the empty string if * Returns the group name chosen for the named trial, or the empty string if the
* the trial does not exist or is not enabled. * trial does not exist or is not enabled.
* @param {string} name * @param {string} name
* @param {Function} callback * @param {function(string):void} callback
* @see https://developer.chrome.com/extensions/metricsPrivate#method-getFieldTrial
*/ */
chrome.metricsPrivate.getFieldTrial = function(name, callback) {}; chrome.metricsPrivate.getFieldTrial = function(name, callback) {};
...@@ -39,13 +58,15 @@ chrome.metricsPrivate.getFieldTrial = function(name, callback) {}; ...@@ -39,13 +58,15 @@ chrome.metricsPrivate.getFieldTrial = function(name, callback) {};
* Returns variation parameters for the named trial if available, or undefined * Returns variation parameters for the named trial if available, or undefined
* otherwise. * otherwise.
* @param {string} name * @param {string} name
* @param {Function} callback * @param {function(Object):void} callback
* @see https://developer.chrome.com/extensions/metricsPrivate#method-getVariationParams
*/ */
chrome.metricsPrivate.getVariationParams = function(name, callback) {}; chrome.metricsPrivate.getVariationParams = function(name, callback) {};
/** /**
* Records an action performed by the user. * Records an action performed by the user.
* @param {string} name * @param {string} name
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordUserAction
*/ */
chrome.metricsPrivate.recordUserAction = function(name) {}; chrome.metricsPrivate.recordUserAction = function(name) {};
...@@ -53,6 +74,7 @@ chrome.metricsPrivate.recordUserAction = function(name) {}; ...@@ -53,6 +74,7 @@ chrome.metricsPrivate.recordUserAction = function(name) {};
* Records a percentage value from 1 to 100. * Records a percentage value from 1 to 100.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordPercentage
*/ */
chrome.metricsPrivate.recordPercentage = function(metricName, value) {}; chrome.metricsPrivate.recordPercentage = function(metricName, value) {};
...@@ -60,6 +82,7 @@ chrome.metricsPrivate.recordPercentage = function(metricName, value) {}; ...@@ -60,6 +82,7 @@ chrome.metricsPrivate.recordPercentage = function(metricName, value) {};
* Records a value than can range from 1 to 1,000,000. * Records a value than can range from 1 to 1,000,000.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordCount
*/ */
chrome.metricsPrivate.recordCount = function(metricName, value) {}; chrome.metricsPrivate.recordCount = function(metricName, value) {};
...@@ -67,6 +90,7 @@ chrome.metricsPrivate.recordCount = function(metricName, value) {}; ...@@ -67,6 +90,7 @@ chrome.metricsPrivate.recordCount = function(metricName, value) {};
* Records a value than can range from 1 to 100. * Records a value than can range from 1 to 100.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordSmallCount
*/ */
chrome.metricsPrivate.recordSmallCount = function(metricName, value) {}; chrome.metricsPrivate.recordSmallCount = function(metricName, value) {};
...@@ -74,6 +98,7 @@ chrome.metricsPrivate.recordSmallCount = function(metricName, value) {}; ...@@ -74,6 +98,7 @@ chrome.metricsPrivate.recordSmallCount = function(metricName, value) {};
* Records a value than can range from 1 to 10,000. * Records a value than can range from 1 to 10,000.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordMediumCount
*/ */
chrome.metricsPrivate.recordMediumCount = function(metricName, value) {}; chrome.metricsPrivate.recordMediumCount = function(metricName, value) {};
...@@ -82,6 +107,7 @@ chrome.metricsPrivate.recordMediumCount = function(metricName, value) {}; ...@@ -82,6 +107,7 @@ chrome.metricsPrivate.recordMediumCount = function(metricName, value) {};
* specified in milliseconds. * specified in milliseconds.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordTime
*/ */
chrome.metricsPrivate.recordTime = function(metricName, value) {}; chrome.metricsPrivate.recordTime = function(metricName, value) {};
...@@ -90,6 +116,7 @@ chrome.metricsPrivate.recordTime = function(metricName, value) {}; ...@@ -90,6 +116,7 @@ chrome.metricsPrivate.recordTime = function(metricName, value) {};
* specified in milliseconds. * specified in milliseconds.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordMediumTime
*/ */
chrome.metricsPrivate.recordMediumTime = function(metricName, value) {}; chrome.metricsPrivate.recordMediumTime = function(metricName, value) {};
...@@ -98,6 +125,7 @@ chrome.metricsPrivate.recordMediumTime = function(metricName, value) {}; ...@@ -98,6 +125,7 @@ chrome.metricsPrivate.recordMediumTime = function(metricName, value) {};
* specified in milliseconds. * specified in milliseconds.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordLongTime
*/ */
chrome.metricsPrivate.recordLongTime = function(metricName, value) {}; chrome.metricsPrivate.recordLongTime = function(metricName, value) {};
...@@ -106,12 +134,14 @@ chrome.metricsPrivate.recordLongTime = function(metricName, value) {}; ...@@ -106,12 +134,14 @@ chrome.metricsPrivate.recordLongTime = function(metricName, value) {};
* by the |metricName|. * by the |metricName|.
* @param {string} metricName * @param {string} metricName
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordSparseValue
*/ */
chrome.metricsPrivate.recordSparseValue = function(metricName, value) {}; chrome.metricsPrivate.recordSparseValue = function(metricName, value) {};
/** /**
* Adds a value to the given metric. * Adds a value to the given metric.
* @param {MetricType} metric * @param {!chrome.metricsPrivate.MetricType} metric
* @param {number} value * @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordValue
*/ */
chrome.metricsPrivate.recordValue = function(metric, value) {}; chrome.metricsPrivate.recordValue = function(metric, value) {};
...@@ -161,7 +161,7 @@ metricsBase.recordEnum = function(name, value, opt_validValues) { ...@@ -161,7 +161,7 @@ metricsBase.recordEnum = function(name, value, opt_validValues) {
// (Source: UMA_HISTOGRAM_ENUMERATION definition in base/metrics/histogram.h) // (Source: UMA_HISTOGRAM_ENUMERATION definition in base/metrics/histogram.h)
var metricDescr = { var metricDescr = {
'metricName': metrics.convertName_(name), 'metricName': metrics.convertName_(name),
'type': 'histogram-linear', 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1, 'min': 1,
'max': boundaryValue, 'max': boundaryValue,
'buckets': boundaryValue 'buckets': boundaryValue
......
...@@ -60,7 +60,7 @@ ImageLoaderClient.getInstance = function() { ...@@ -60,7 +60,7 @@ ImageLoaderClient.getInstance = function() {
ImageLoaderClient.recordBinary = function(name, value) { ImageLoaderClient.recordBinary = function(name, value) {
chrome.metricsPrivate.recordValue( chrome.metricsPrivate.recordValue(
{ metricName: 'ImageLoader.Client.' + name, { metricName: 'ImageLoader.Client.' + name,
type: 'histogram-linear', type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
min: 1, // According to histogram.h, this should be 1 for enums. min: 1, // According to histogram.h, this should be 1 for enums.
max: 2, // Maximum should be exclusive. max: 2, // Maximum should be exclusive.
buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2.
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
var chrome = { var chrome = {
metricsPrivate: { metricsPrivate: {
MetricTypeType: {
HISTOGRAM_LOG: 'histogram-log',
HISTOGRAM_LINEAR: 'histogram-linear'
},
recordPercentage: function() {}, recordPercentage: function() {},
recordValue: function() {} recordValue: function() {}
}, },
......
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