1 <!DOCTYPE html> 2 <!-- 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. 4 Use of this source code is governed by a BSD-style license that can be 5 found in the LICENSE file. 6 --> 7 8 <link rel="import" href="/tracing/base/base.html"> 9 10 <script> 11 'use strict'; 12 13 tr.exportTo('tr.ui.tracks', function() { 14 15 /** 16 * ContainerToTrackMap is a class to handle building and accessing a map 17 * between an EventContainer's stableId and its handling track. 18 * 19 * @constructor 20 */ 21 function ContainerToTrackMap() { 22 this.stableIdToTrackMap_ = {}; 23 } 24 25 ContainerToTrackMap.prototype = { 26 addContainer: function(container, track) { 27 if (!track) 28 throw new Error('Must provide a track.'); 29 this.stableIdToTrackMap_[container.stableId] = track; 30 }, 31 32 clear: function() { 33 this.stableIdToTrackMap_ = {}; 34 }, 35 36 getTrackByStableId: function(stableId) { 37 return this.stableIdToTrackMap_[stableId]; 38 } 39 }; 40 41 return { 42 ContainerToTrackMap: ContainerToTrackMap 43 }; 44 }); 45 </script> 46