1/* 2 * Copyright (C) 2013 University of Washington. All rights reserved. 3 * Copyright (C) 2014 Apple Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 15 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27WebInspector.ProbeSetDataFrame = function(index) 28{ 29 this._count = 0; 30 this._index = index; 31 this._separator = false; 32}; 33 34WebInspector.ProbeSetDataFrame.compare = function(a, b) { 35 console.assert(a instanceof WebInspector.ProbeSetDataFrame, a); 36 console.assert(b instanceof WebInspector.ProbeSetDataFrame, b); 37 38 return a.index - b.index; 39} 40 41WebInspector.ProbeSetDataFrame.MissingValue = "?"; 42 43WebInspector.ProbeSetDataFrame.prototype = { 44 constructor: WebInspector.ProbeSetDataFrame, 45 46 // Public 47 48 get key() 49 { 50 return String(this._index); 51 }, 52 53 get count() 54 { 55 return this._count; 56 }, 57 58 get index() 59 { 60 return this._index; 61 }, 62 63 get isSeparator() 64 { 65 return this._separator; 66 }, 67 68 // The last data frame before a main frame navigation is marked as a "separator" frame. 69 set isSeparator(value) 70 { 71 this._separator = !!value; 72 }, 73 74 addSampleForProbe: function(probe, sample) 75 { 76 this[probe.id] = sample; 77 this._count++; 78 }, 79 80 missingKeys: function(probeSet) 81 { 82 return probeSet.probes.filter(function(probe) { 83 return !this.hasOwnProperty(probe.id); 84 }, this); 85 }, 86 87 isComplete: function(probeSet) 88 { 89 return !this.missingKeys(probeSet).length; 90 }, 91 92 fillMissingValues: function(probeSet) 93 { 94 for (var key of this.missingKeys(probeSet)) 95 this[key] = WebInspector.ProbeSetDataFrame.MissingValue; 96 } 97}; 98