1<!DOCTYPE html> 2<!-- 3Copyright 2016 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/value/numeric.html"> 9 10<script> 11'use strict'; 12 13tr.exportTo('tr.metrics', function() { 14 function ValueList(values) { 15 if (values !== undefined) 16 this.values_ = values; 17 else 18 this.values_ = []; 19 } 20 21 ValueList.prototype = { 22 get valueDicts() { 23 return this.values_.map(function(v) { return v.asDict(); }); 24 }, 25 26 getValuesWithName: function(name) { 27 return this.values_.filter(function(value) { 28 return value.name.indexOf(name) > -1; 29 }); 30 }, 31 32 addValue: function(v) { 33 if (!(v instanceof tr.v.NumericValue)) { 34 var err = new Error('Tried to add value ' + v + 35 ' which is non-Numeric'); 36 err.name = 'ValueError'; 37 throw err; 38 } 39 40 this.values_.push(v); 41 } 42 }; 43 44 return { 45 ValueList: ValueList 46 }; 47}); 48</script> 49