| Index: tracing/tracing/metrics/metric_registry.html
|
| diff --git a/tracing/tracing/metrics/metric_registry.html b/tracing/tracing/metrics/metric_registry.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ea840e4ba5f8456a601e1118c4576251b6d0ba5a
|
| --- /dev/null
|
| +++ b/tracing/tracing/metrics/metric_registry.html
|
| @@ -0,0 +1,38 @@
|
| +<!DOCTYPE html>
|
| +<!--
|
| +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.
|
| +-->
|
| +<link rel="import" href="/tracing/base/iteration_helpers.html">
|
| +
|
| +<script>
|
| +'use strict';
|
| +
|
| +tr.exportTo('tr.metrics', function() {
|
| +
|
| + var MetricRegistry = {
|
| + metricsByName_: {},
|
| + get metrics() { return tr.b.dictionaryValues(this.metricsByName_); }
|
| + };
|
| +
|
| + /**
|
| + * @param {Function} metric A metric, which takes a ValueList and Model and
|
| + * adds values to the ValueList.
|
| + */
|
| + MetricRegistry.register = function(metric) {
|
| + if (typeof(metric) !== 'function')
|
| + throw new Error('Tried to register a non-function as metric.');
|
| + if (metric.name === '')
|
| + throw new Error('Registered metrics must not be anonymous');
|
| + if (this.metricsByName_[metric.name] !== undefined)
|
| + throw new Error('Metric named ' + metric.name +
|
| + ' is already registered.');
|
| + this.metricsByName_[metric.name] = metric;
|
| + };
|
| +
|
| + return {
|
| + MetricRegistry: MetricRegistry
|
| + };
|
| +});
|
| +</script>
|
|
|