1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 tvcm.exportTo('tracing.trace_model', function() {
8 function StackFrame(parentFrame, id, category, title, colorId) {
10 throw new Error('id must be given');
11 this.parentFrame_ = parentFrame;
13 this.category = category || '';
15 this.colorId = colorId;
18 if (this.parentFrame_)
19 this.parentFrame_.addChild(this);
22 StackFrame.prototype = {
24 return this.parentFrame_;
27 set parentFrame(parentFrame) {
28 if (this.parentFrame_)
29 this.parentFrame_.removeChild(this);
30 this.parentFrame_ = parentFrame;
31 if (this.parentFrame_)
32 this.parentFrame_.addChild(this);
35 addChild: function(child) {
36 this.children.push(child);
39 removeChild: function(child) {
40 var i = this.children.indexOf(child.id);
42 throw new Error('omg');
43 this.children.splice(i, 1);
46 removeAllChildren: function() {
47 for (var i = 0; i < this.children.length; i++)
48 this.children[i].parentFrame_ = undefined;
49 this.children.splice(0, this.children.length);
58 StackFrame: StackFrame