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 = {
function recordEvent(event) {
var metricDescription = {
metricName: 'GoogleNow.Event',
type: 'histogram-linear',
type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
min: 1,
max: GoogleNowEvent.EVENTS_TOTAL,
buckets: GoogleNowEvent.EVENTS_TOTAL + 1
......
......@@ -14,7 +14,7 @@ cr.define('hotword.metrics', function() {
function recordEnum(name, value, maxValue) {
var metricDesc = {
'metricName': name,
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1,
'max': maxValue,
'buckets': maxValue + 1
......
......@@ -23,7 +23,7 @@ chrome.test.runTests([
function recordValue() {
chrome.metricsPrivate.recordValue({
'metricName': 'test.h.1',
'type': 'histogram-log',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 1,
'max': 100,
'buckets': 50
......@@ -31,7 +31,7 @@ chrome.test.runTests([
chrome.metricsPrivate.recordValue({
'metricName': 'test.h.2',
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1,
'max': 200,
'buckets': 50
......@@ -108,28 +108,28 @@ chrome.test.runTests([
function testBucketSizeChanges() {
var linear1 = {
'metricName': 'test.bucketchange.linear',
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 0,
'max': 100,
'buckets': 10
};
var linear2 = {
'metricName': 'test.bucketchange.linear',
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 0,
'max': 100,
'buckets': 20
};
var log1 = {
'metricName': 'test.bucketchange.log',
'type': 'histogram-log',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 0,
'max': 100,
'buckets': 10
};
var log2 = {
'metricName': 'test.bucketchange.log',
'type': 'histogram-log',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 0,
'max': 100,
'buckets': 20
......
......@@ -82,7 +82,7 @@ function createPlatformDelegate(strings) {
var index = (value >= 0 && value < enumSize) ? value : enumSize;
chrome.metricsPrivate.recordValue({
'metricName': 'WebstoreWidgetApp.' + enumName,
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1,
'max': enumSize,
'buckets': enumSize + 1
......
......@@ -603,7 +603,7 @@ function recordState(state) {
var metricDescription = {
metricName: 'Chromoting.Connections',
type: 'histogram-linear',
type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
// According to histogram.h, minimum should be 1. Values less than minimum
// end up in the 0th bucket.
min: 1,
......
......@@ -249,6 +249,11 @@ chromeMocks.identity;
/** @constructor */
chromeMocks.MetricsPrivate = function() {};
chromeMocks.MetricsPrivate.prototype.MetricTypeType = {
HISTOGRAM_LOG: 'histogram-log',
HISTOGRAM_LINEAR: 'histogram-linear',
};
chromeMocks.MetricsPrivate.prototype.recordValue = function() {};
/** @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
// 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 */
/**
* @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.
* @typedef {{
* metricName: string,
* type: string,
* type: !chrome.metricsPrivate.MetricTypeType,
* min: number,
* max: number,
* buckets: number
* }}
* @see https://developer.chrome.com/extensions/metricsPrivate#type-MetricType
*/
var MetricType;
/**
* @const
*/
chrome.metricsPrivate = {};
chrome.metricsPrivate.MetricType;
/**
* 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) {};
/**
* Returns the group name chosen for the named trial, or the empty string if
* the trial does not exist or is not enabled.
* Returns the group name chosen for the named trial, or the empty string if the
* trial does not exist or is not enabled.
* @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) {};
......@@ -39,13 +58,15 @@ chrome.metricsPrivate.getFieldTrial = function(name, callback) {};
* Returns variation parameters for the named trial if available, or undefined
* otherwise.
* @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) {};
/**
* Records an action performed by the user.
* @param {string} name
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordUserAction
*/
chrome.metricsPrivate.recordUserAction = function(name) {};
......@@ -53,6 +74,7 @@ chrome.metricsPrivate.recordUserAction = function(name) {};
* Records a percentage value from 1 to 100.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordPercentage
*/
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.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordCount
*/
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.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordSmallCount
*/
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.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordMediumCount
*/
chrome.metricsPrivate.recordMediumCount = function(metricName, value) {};
......@@ -82,6 +107,7 @@ chrome.metricsPrivate.recordMediumCount = function(metricName, value) {};
* specified in milliseconds.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordTime
*/
chrome.metricsPrivate.recordTime = function(metricName, value) {};
......@@ -90,6 +116,7 @@ chrome.metricsPrivate.recordTime = function(metricName, value) {};
* specified in milliseconds.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordMediumTime
*/
chrome.metricsPrivate.recordMediumTime = function(metricName, value) {};
......@@ -98,6 +125,7 @@ chrome.metricsPrivate.recordMediumTime = function(metricName, value) {};
* specified in milliseconds.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordLongTime
*/
chrome.metricsPrivate.recordLongTime = function(metricName, value) {};
......@@ -106,12 +134,14 @@ chrome.metricsPrivate.recordLongTime = function(metricName, value) {};
* by the |metricName|.
* @param {string} metricName
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordSparseValue
*/
chrome.metricsPrivate.recordSparseValue = function(metricName, value) {};
/**
* Adds a value to the given metric.
* @param {MetricType} metric
* @param {!chrome.metricsPrivate.MetricType} metric
* @param {number} value
* @see https://developer.chrome.com/extensions/metricsPrivate#method-recordValue
*/
chrome.metricsPrivate.recordValue = function(metric, value) {};
......@@ -161,7 +161,7 @@ metricsBase.recordEnum = function(name, value, opt_validValues) {
// (Source: UMA_HISTOGRAM_ENUMERATION definition in base/metrics/histogram.h)
var metricDescr = {
'metricName': metrics.convertName_(name),
'type': 'histogram-linear',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR,
'min': 1,
'max': boundaryValue,
'buckets': boundaryValue
......
......@@ -60,7 +60,7 @@ ImageLoaderClient.getInstance = function() {
ImageLoaderClient.recordBinary = function(name, value) {
chrome.metricsPrivate.recordValue(
{ 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.
max: 2, // Maximum should be exclusive.
buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2.
......
......@@ -6,6 +6,10 @@
var chrome = {
metricsPrivate: {
MetricTypeType: {
HISTOGRAM_LOG: 'histogram-log',
HISTOGRAM_LINEAR: 'histogram-linear'
},
recordPercentage: 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