Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / analysis / default_object_view.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="stylesheet" href="/tracing/analysis/default_object_view.css">
9
10 <link rel="import" href="/tracing/analysis/analysis_link.html">
11 <link rel="import" href="/tracing/analysis/object_instance_view.html">
12 <link rel="import" href="/tracing/analysis/object_snapshot_view.html">
13 <link rel="import" href="/tracing/analysis/util.html">
14 <link rel="import" href="/tracing/analysis/generic_object_view.html">
15
16 <script>
17 'use strict';
18
19 tv.exportTo('tracing.analysis', function() {
20   var tsRound = tracing.analysis.tsRound;
21
22   /*
23    * Displays an object instance in a human readable form.
24    * @constructor
25    */
26   var DefaultObjectSnapshotView = tv.ui.define(
27       'default-object-snapshot-view',
28       tracing.analysis.ObjectSnapshotView);
29
30   DefaultObjectSnapshotView.prototype = {
31     __proto__: tracing.analysis.ObjectSnapshotView.prototype,
32
33     decorate: function() {
34       tracing.analysis.ObjectSnapshotView.prototype.decorate.apply(this);
35       this.classList.add('default-object-view');
36       this.classList.add('default-object-snapshot-view');
37     },
38
39     updateContents: function() {
40       var snapshot = this.objectSnapshot;
41       if (!snapshot) {
42         this.textContent = '';
43         return;
44       }
45       var instance = snapshot.objectInstance;
46
47       var html = '';
48       html += '<div class="title">Snapshot of <a id="instance-link"></a> @ ' +
49           tsRound(snapshot.ts) + 'ms</div>\n';
50       html += '<table>';
51       html += '<tr>';
52       html += '<tr><td>args:</td><td id="args"></td></tr>\n';
53       html += '</table>';
54       this.innerHTML = html;
55
56       // TODO(nduca): tv.ui.decoreate doesn't work when subclassed. So,
57       // replace the template element.
58       var instanceLinkEl = new tracing.analysis.ObjectInstanceLink();
59       instanceLinkEl.objectInstance = instance;
60       var tmp = this.querySelector('#instance-link');
61       tmp.parentElement.replaceChild(instanceLinkEl, tmp);
62
63       var argsEl = this.querySelector('#args');
64       argsEl.textContent = '';
65       var objectView = tracing.analysis.GenericObjectView();
66       objectView.object = snapshot.args;
67       argsEl.appendChild(objectView);
68     }
69   };
70
71   /**
72    * Displays an object instance in a human readable form.
73    * @constructor
74    */
75   var DefaultObjectInstanceView = tv.ui.define(
76       'default-object-instance-view',
77       tracing.analysis.ObjectInstanceView);
78
79   DefaultObjectInstanceView.prototype = {
80     __proto__: tracing.analysis.ObjectInstanceView.prototype,
81
82     decorate: function() {
83       tracing.analysis.ObjectInstanceView.prototype.decorate.apply(this);
84       this.classList.add('default-object-view');
85       this.classList.add('default-object-instance-view');
86     },
87
88     updateContents: function() {
89       var instance = this.objectInstance;
90       if (!instance) {
91         this.textContent = '';
92         return;
93       }
94
95       var html = '';
96       html += '<div class="title">' +
97           instance.typeName + ' ' +
98           instance.id + '</div>\n';
99       html += '<table>';
100       html += '<tr>';
101       html += '<tr><td>creationTs:</td><td>' +
102           instance.creationTs + '</td></tr>\n';
103       if (instance.deletionTs != Number.MAX_VALUE) {
104         html += '<tr><td>deletionTs:</td><td>' +
105             instance.deletionTs + '</td></tr>\n';
106       } else {
107         html += '<tr><td>deletionTs:</td><td>not deleted</td></tr>\n';
108       }
109       html += '<tr><td>snapshots:</td><td id="snapshots"></td></tr>\n';
110       html += '</table>';
111       this.innerHTML = html;
112       var snapshotsEl = this.querySelector('#snapshots');
113       instance.snapshots.forEach(function(snapshot) {
114         var snapshotLink = new tracing.analysis.ObjectSnapshotLink();
115         snapshotLink.objectSnapshot = snapshot;
116         snapshotsEl.appendChild(snapshotLink);
117       });
118     }
119   };
120
121   return {
122     DefaultObjectSnapshotView: DefaultObjectSnapshotView,
123     DefaultObjectInstanceView: DefaultObjectInstanceView
124   };
125 });
126 </script>
127