// Copyright (c) 2012 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.

[
  {
    "namespace": "metricsPrivate",
    "description": "none",
    "types": [
      {
        "id": "MetricType",
        "type":  "object",
        "description": "Describes the type of metric that is to be collected.",
        "properties": {
          "metricName": {"type": "string", "description": "A unique name within the extension for the metric."},
          "type": {
            "type": "string",
            "enum": ["histogram-log", "histogram-linear"],
            "description": "The type of metric, such as 'histogram-log' or 'histogram-linear'."
          },
          "min": {"type": "integer", "description": "The minimum sample value to be recoded.  Must be greater than zero."},
          "max": {"type": "integer", "description": "The maximum sample value to be recoded."},
          "buckets": {"type": "integer", "description": "The number of buckets to use when separating the recorded values."}
        }
      }
    ],
    "functions": [
      {
        "name": "getIsCrashReportingEnabled",
        "description": "Returns true if the user opted in to sending crash reports.",
        "type": "function",
        "parameters": [
          {
            "name": "callback",
            "type": "function",
            "optional": "false",
            "parameters": [
              { "name": "is_enabled", "type": "boolean" }
            ]
          }
        ]
      },
      {
        "name": "getFieldTrial",
        "description": "Returns the group name chosen for the named trial, or the empty string if the trial does not exist or is not enabled.",
        "type": "function",
        "parameters": [
          {"name": "name", "type": "string"},
          {
            "name": "callback",
            "type": "function",
            "optional": "false",
            "parameters": [
              { "name": "group", "type": "string" }
            ]
          }
        ]
      },
      {
        "name": "getVariationParams",
        "description": "Returns variation parameters for the named trial if available, or undefined otherwise.",
        "type": "function",
        "parameters": [
          {"name": "name", "type": "string"},
          {
            "name": "callback",
            "type": "function",
            "optional": "false",
            "parameters": [
              {
                "name": "params",
                "type": "object",
                "additionalProperties": { "type": "string" }
              }
            ]
          }
        ]
      },
      {
        "name": "recordUserAction",
        "type": "function",
        "description": "Records an action performed by the user.",
        "parameters": [
          {"name": "name", "type": "string"}
        ]
      },
      {
        "name": "recordPercentage",
        "type": "function",
        "description": "Records a percentage value from 1 to 100.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 1,000,000.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordSmallCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 100.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordMediumCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 10,000.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 10 seconds.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordMediumTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 3 minutes.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordLongTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 1 hour.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordValue",
        "type": "function",
        "description": "Adds a value to the given metric.",
        "parameters": [
          {"name": "metric", "$ref": "MetricType"},
          {"name": "value", "type": "integer"}
        ]
      }
    ],
    "events": []
  }
]