Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / analysis / analyze_samples.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 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/analysis/analysis_sub_view.html">
9 <link rel="import" href="/tracing/analysis/util.html">
10 <link rel="import" href="/tracing/side_panel/sampling_summary.html">
11 <link rel="import" href="/base.html">
12 <link rel="import" href="/base/ui.html">
13 <link rel="import" href="/base/ui/sortable_table.html">
14
15 <polymer-element name="single-sample-analysis-sub-view"
16     extends="tracing-analysis-sub-view"
17     constructor="SingleSampleAnalysisSubView">
18   <script>
19   'use strict';
20   tv.onPolymerReady(function() {
21     tracing.registerAnalysisSubViewType(
22         0,
23         function(selection) {
24           if (selection.length != 1)
25             return false;
26           return selection[0] instanceof tracing.trace_model.Sample;
27         },
28         SingleSampleAnalysisSubView);
29     tracing.registerAnalysisSubViewType(
30         0,
31         function(selection) {
32           if (selection.length == 1)
33             return false;
34           return selection[0] instanceof tracing.trace_model.Sample;
35         },
36         MultipleSamplesAnalysisSubView);
37   });
38
39   Polymer({
40     created: function() {
41       this.currentSelection_ = undefined;
42     },
43
44     set selection(selection) {
45       this.currentSelection_ = selection;
46       this.textContent = '';
47
48       if (selection.length === 0)
49         return;
50
51       var results = new tracing.analysis.AnalysisResults();
52       this.appendChild(results);
53
54       this.analyzeSingleSampleEvent_(
55           results, selection[0], 'Sample Event');
56     },
57
58     get selection() {
59       return this.currentSelection_;
60     },
61
62     analyzeSingleSampleEvent_: function(results, sample, type) {
63       results.appendHeader('Selected ' + type + ':');
64       var table = results.appendTable('analysis-slice-table', 2);
65
66       results.appendInfoRow(table, 'Title', sample.title);
67       results.appendInfoRowTime(table, 'Sample Time', sample.start);
68       results.appendInfoRow(table,
69                             'Stack Trace',
70                             sample.getUserFriendlyStackTrace());
71     }
72   });
73   </script>
74 </polymer-element>
75
76 <polymer-element name="multiple-samples-analysis-sub-view"
77     extends="tracing-analysis-sub-view"
78     constructor="MultipleSamplesAnalysisSubView">
79   <script>
80   'use strict';
81   Polymer({
82     created: function() {
83       this.currentSelection_ = undefined;
84     },
85
86     set selection(selection) {
87       this.currentSelection_ = selection;
88       this.textContent = '';
89
90       if (selection.length === 0)
91         return;
92
93       var results = new tracing.analysis.AnalysisResults();
94       this.appendChild(results);
95
96       this.analyzeMultipleSampleEvents_(results, selection);
97     },
98
99     get selection() {
100       return this.currentSelection_;
101     },
102
103     analyzeMultipleSampleEvents_: function(results, slices) {
104       var panel = new tracing.SamplingSummaryPanel();
105       results.appendChild(panel);
106       panel.selection = slices;
107     }
108   });
109   </script>
110 </polymer-element>