1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 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/base/range.html"> 9<link rel="import" href="/tracing/model/thread_time_slice.html"> 10 11<script> 12'use strict'; 13 14/** 15 * @fileoverview Provides the CpuSlice class. 16 */ 17tr.exportTo('tr.model', function() { 18 19 var Slice = tr.model.Slice; 20 21 /** 22 * A CpuSlice represents a slice of time on a CPU. 23 * 24 * @constructor 25 */ 26 function CpuSlice(cat, title, colorId, start, args, opt_duration) { 27 Slice.apply(this, arguments); 28 this.threadThatWasRunning = undefined; 29 this.cpu = undefined; 30 } 31 32 CpuSlice.prototype = { 33 __proto__: Slice.prototype, 34 35 get analysisTypeName() { 36 return 'tr.ui.analysis.CpuSlice'; 37 }, 38 39 getAssociatedTimeslice: function() { 40 if (!this.threadThatWasRunning) 41 return undefined; 42 var timeSlices = this.threadThatWasRunning.timeSlices; 43 for (var i = 0; i < timeSlices.length; i++) { 44 var timeSlice = timeSlices[i]; 45 if (timeSlice.start !== this.start) 46 continue; 47 if (timeSlice.duration !== this.duration) 48 continue; 49 return timeSlice; 50 } 51 return undefined; 52 } 53 }; 54 55 tr.model.EventRegistry.register( 56 CpuSlice, 57 { 58 name: 'cpuSlice', 59 pluralName: 'cpuSlices', 60 singleViewElementName: 'tr-ui-a-single-cpu-slice-sub-view', 61 multiViewElementName: 'tr-ui-a-multi-cpu-slice-sub-view' 62 }); 63 64 return { 65 CpuSlice: CpuSlice 66 }; 67}); 68</script> 69