| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 <link rel="import" href="/tracing/base/base.html"> | 7 <link rel="import" href="/tracing/base/base.html"> |
| 8 <link rel="import" href="/tracing/base/extension_registry.html"> | 8 <link rel="import" href="/tracing/base/extension_registry.html"> |
| 9 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 9 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
| 10 | 10 |
| 11 <script> | 11 <script> |
| 12 'use strict'; | 12 'use strict'; |
| 13 | 13 |
| 14 tr.exportTo('tr.metrics', function() { | 14 tr.exportTo('tr.metrics', function() { |
| 15 | 15 |
| 16 function MetricRegistry() {} | 16 function MetricRegistry() {} |
| 17 | 17 |
| 18 var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); | 18 var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); |
| 19 options.defaultMetadata = {}; | 19 options.defaultMetadata = {}; |
| 20 tr.b.decorateExtensionRegistry(MetricRegistry, options); | 20 tr.b.decorateExtensionRegistry(MetricRegistry, options); |
| 21 | 21 |
| 22 MetricRegistry.addEventListener('will-register', function(e) { | 22 MetricRegistry.addEventListener('will-register', function(e) { |
| 23 var metric = e.typeInfo.constructor; | 23 var metric = e.typeInfo.constructor; |
| 24 if (!(metric instanceof Function)) | 24 if (!(metric instanceof Function)) |
| 25 throw new Error('Metrics must be functions'); | 25 throw new Error('Metrics must be functions'); |
| 26 | 26 |
| 27 if (metric.length !== 2) | 27 if (metric.length < 2) { |
| 28 throw new Error('Metrics take a ValueSet and a Model'); | 28 throw new Error('Metrics take a ValueSet and a Model and ' + |
| 29 'optionally an options dictionary'); |
| 30 } |
| 29 }); | 31 }); |
| 30 | 32 |
| 31 return { | 33 return { |
| 32 MetricRegistry: MetricRegistry | 34 MetricRegistry: MetricRegistry |
| 33 }; | 35 }; |
| 34 }); | 36 }); |
| 35 </script> | 37 </script> |
| OLD | NEW |