OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
8 * @param {!WebInspector.NetworkRequest} request | 8 * @param {!WebInspector.NetworkRequest} request |
9 */ | 9 */ |
10 WebInspector.EventSourceMessagesView = function(request) | 10 WebInspector.EventSourceMessagesView = function(request) |
(...skipping 11 matching lines...) Expand all Loading... |
22 ]; | 22 ]; |
23 | 23 |
24 this._dataGrid = new WebInspector.SortableDataGrid(columns); | 24 this._dataGrid = new WebInspector.SortableDataGrid(columns); |
25 this._dataGrid.setStickToBottom(true); | 25 this._dataGrid.setStickToBottom(true); |
26 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce
nding); | 26 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce
nding); |
27 this._sortItems(); | 27 this._sortItems(); |
28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._sortItems, this); | 28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._sortItems, this); |
29 | 29 |
30 this._dataGrid.setName("EventSourceMessagesView"); | 30 this._dataGrid.setName("EventSourceMessagesView"); |
31 this._dataGrid.asWidget().show(this.element); | 31 this._dataGrid.asWidget().show(this.element); |
32 } | 32 }; |
33 | 33 |
34 WebInspector.EventSourceMessagesView.prototype = { | 34 WebInspector.EventSourceMessagesView.prototype = { |
35 wasShown: function() | 35 wasShown: function() |
36 { | 36 { |
37 this._dataGrid.rootNode().removeChildren(); | 37 this._dataGrid.rootNode().removeChildren(); |
38 var messages = this._request.eventSourceMessages(); | 38 var messages = this._request.eventSourceMessages(); |
39 for (var i = 0; i < messages.length; ++i) | 39 for (var i = 0; i < messages.length; ++i) |
40 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(m
essages[i])); | 40 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(m
essages[i])); |
41 | 41 |
42 this._request.addEventListener(WebInspector.NetworkRequest.Events.EventS
ourceMessageAdded, this._messageAdded, this); | 42 this._request.addEventListener(WebInspector.NetworkRequest.Events.EventS
ourceMessageAdded, this._messageAdded, this); |
(...skipping 18 matching lines...) Expand all Loading... |
61 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier(); | 61 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier(); |
62 if (!sortColumnIdentifier) | 62 if (!sortColumnIdentifier) |
63 return; | 63 return; |
64 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortCol
umnIdentifier]; | 64 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortCol
umnIdentifier]; |
65 if (!comparator) | 65 if (!comparator) |
66 return; | 66 return; |
67 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscendin
g()); | 67 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscendin
g()); |
68 }, | 68 }, |
69 | 69 |
70 __proto__: WebInspector.VBox.prototype | 70 __proto__: WebInspector.VBox.prototype |
71 } | 71 }; |
72 | 72 |
73 /** | 73 /** |
74 * @constructor | 74 * @constructor |
75 * @extends {WebInspector.SortableDataGridNode} | 75 * @extends {WebInspector.SortableDataGridNode} |
76 * @param {!WebInspector.NetworkRequest.EventSourceMessage} message | 76 * @param {!WebInspector.NetworkRequest.EventSourceMessage} message |
77 */ | 77 */ |
78 WebInspector.EventSourceMessageNode = function(message) | 78 WebInspector.EventSourceMessageNode = function(message) |
79 { | 79 { |
80 this._message = message; | 80 this._message = message; |
81 var time = new Date(message.time * 1000); | 81 var time = new Date(message.time * 1000); |
82 var timeText = ("0" + time.getHours()).substr(-2) + ":" + ("0" + time.getMin
utes()).substr(-2) + ":" + ("0" + time.getSeconds()).substr(-2) + "." + ("00" +
time.getMilliseconds()).substr(-3); | 82 var timeText = ("0" + time.getHours()).substr(-2) + ":" + ("0" + time.getMin
utes()).substr(-2) + ":" + ("0" + time.getSeconds()).substr(-2) + "." + ("00" +
time.getMilliseconds()).substr(-3); |
83 var timeNode = createElement("div"); | 83 var timeNode = createElement("div"); |
84 timeNode.createTextChild(timeText); | 84 timeNode.createTextChild(timeText); |
85 timeNode.title = time.toLocaleString(); | 85 timeNode.title = time.toLocaleString(); |
86 WebInspector.SortableDataGridNode.call(this, {id: message.eventId, type: mes
sage.eventName, data: message.data, time: timeNode}); | 86 WebInspector.SortableDataGridNode.call(this, {id: message.eventId, type: mes
sage.eventName, data: message.data, time: timeNode}); |
87 } | 87 }; |
88 | 88 |
89 WebInspector.EventSourceMessageNode.prototype = { | 89 WebInspector.EventSourceMessageNode.prototype = { |
90 __proto__: WebInspector.SortableDataGridNode.prototype | 90 __proto__: WebInspector.SortableDataGridNode.prototype |
91 } | 91 }; |
92 | 92 |
93 /** | 93 /** |
94 * @param {string} field | 94 * @param {string} field |
95 * @param {!WebInspector.EventSourceMessageNode} a | 95 * @param {!WebInspector.EventSourceMessageNode} a |
96 * @param {!WebInspector.EventSourceMessageNode} b | 96 * @param {!WebInspector.EventSourceMessageNode} b |
97 * @return {number} | 97 * @return {number} |
98 */ | 98 */ |
99 WebInspector.EventSourceMessageNodeComparator = function(field, a, b) | 99 WebInspector.EventSourceMessageNodeComparator = function(field, a, b) |
100 { | 100 { |
101 var aValue = a._message[field]; | 101 var aValue = a._message[field]; |
102 var bValue = b._message[field]; | 102 var bValue = b._message[field]; |
103 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; | 103 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; |
104 } | 104 }; |
105 | 105 |
106 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ | 106 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ |
107 WebInspector.EventSourceMessageNode.Comparators = { | 107 WebInspector.EventSourceMessageNode.Comparators = { |
108 "id": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventId"), | 108 "id": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventId"), |
109 "type": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventName"
), | 109 "type": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventName"
), |
110 "time": WebInspector.EventSourceMessageNodeComparator.bind(null, "time") | 110 "time": WebInspector.EventSourceMessageNodeComparator.bind(null, "time") |
111 }; | 111 }; |
OLD | NEW |