Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / analysis / stub_analysis_results.js
1 // Copyright (c) 2012 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.
4
5 'use strict';
6
7 tvcm.exportTo('tracing.analysis', function() {
8   function StubAnalysisResults() {
9     this.headers = [];
10     this.info = [];
11     this.tables = [];
12   }
13   StubAnalysisResults.prototype = {
14     __proto__: Object.protoype,
15
16     appendTable: function(parent, className) {
17       var table = {
18         className: className,
19         rows: []
20       };
21       table.className = className;
22       table.classList = [];
23       table.classList.push(className);
24       table.classList.add = function(className) {
25         table.classList.push(className);
26       };
27       this.tables.push(table);
28       return table;
29     },
30
31     appendHeader: function(label) {
32       var header = {
33         label: label
34       };
35       this.headers.push(header);
36       return header;
37     },
38
39     appendInfo: function(label, value) {
40       this.info.push({label: label, value: value});
41     },
42
43     appendDetailsRow: function(table, start, duration, selfTime, args,
44                                selectionGenerator, cpuDuration) {
45       table.rows.push({
46         start: start,
47         duration: duration,
48         selfTime: selfTime,
49         args: args,
50         selectionGenerator: selectionGenerator,
51         cpuDuration: cpuDuration});
52     },
53
54     appendHeadRow: function(table) {
55       if (table.headerRow)
56         throw new Error('Only one header row allowed.');
57       table.headerRow = [];
58       return table.headerRow;
59     },
60
61     appendTableCell: function(table, row, text) {
62       row.push(text);
63     },
64
65     appendSpacingRow: function(table) {
66       var row = {spacing: true};
67       table.rows.push(row);
68       return row;
69     },
70
71     appendInfoRow: function(table, label, opt_text) {
72       var row = {label: label, text: opt_text};
73       table.rows.push(row);
74       return row;
75     },
76
77     appendInfoRowTime: function(table, label, time) {
78       var row = {label: label, time: time};
79       table.rows.push(row);
80       return row;
81     },
82
83     appendDataRow: function(table, label, duration, cpuDuration, selfTime,
84                             cpuSelfTime, occurences, percentage, details,
85                             selectionGenerator) {
86       var row = {
87         label: label,
88         duration: duration,
89         cpuDuration: cpuDuration,
90         selfTime: selfTime,
91         cpuSelfTime: cpuSelfTime,
92         occurences: occurences,
93         percentage: percentage,
94         details: details,
95         selectionGenerator: selectionGenerator
96       };
97       table.rows.push(row);
98       return row;
99     }
100   };
101
102   return {
103     StubAnalysisResults: StubAnalysisResults
104   };
105 });