Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/EventSourceMessagesView.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.EventSourceMessagesView = class extends WebInspector.VBox { 7 Network.EventSourceMessagesView = class extends UI.VBox {
8 /** 8 /**
9 * @param {!WebInspector.NetworkRequest} request 9 * @param {!SDK.NetworkRequest} request
10 */ 10 */
11 constructor(request) { 11 constructor(request) {
12 super(); 12 super();
13 this.registerRequiredCSS('network/eventSourceMessagesView.css'); 13 this.registerRequiredCSS('network/eventSourceMessagesView.css');
14 this.element.classList.add('event-source-messages-view'); 14 this.element.classList.add('event-source-messages-view');
15 this._request = request; 15 this._request = request;
16 16
17 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([ 17 var columns = /** @type {!Array<!UI.DataGrid.ColumnDescriptor>} */ ([
18 {id: 'id', title: WebInspector.UIString('Id'), sortable: true, weight: 8}, 18 {id: 'id', title: Common.UIString('Id'), sortable: true, weight: 8},
19 {id: 'type', title: WebInspector.UIString('Type'), sortable: true, weight: 8}, 19 {id: 'type', title: Common.UIString('Type'), sortable: true, weight: 8},
20 {id: 'data', title: WebInspector.UIString('Data'), sortable: false, weight : 88}, 20 {id: 'data', title: Common.UIString('Data'), sortable: false, weight: 88},
21 {id: 'time', title: WebInspector.UIString('Time'), sortable: true, weight: 8} 21 {id: 'time', title: Common.UIString('Time'), sortable: true, weight: 8}
22 ]); 22 ]);
23 23
24 this._dataGrid = new WebInspector.SortableDataGrid(columns); 24 this._dataGrid = new UI.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', UI.DataGrid.Order.Ascending);
27 this._sortItems(); 27 this._sortItems();
28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this); 28 this._dataGrid.addEventListener(UI.DataGrid.Events.SortingChanged, this._sor tItems, 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 /** 34 /**
35 * @override 35 * @override
36 */ 36 */
37 wasShown() { 37 wasShown() {
38 this._dataGrid.rootNode().removeChildren(); 38 this._dataGrid.rootNode().removeChildren();
39 var messages = this._request.eventSourceMessages(); 39 var messages = this._request.eventSourceMessages();
40 for (var i = 0; i < messages.length; ++i) 40 for (var i = 0; i < messages.length; ++i)
41 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(message s[i])); 41 this._dataGrid.insertChild(new Network.EventSourceMessageNode(messages[i]) );
42 42
43 this._request.addEventListener( 43 this._request.addEventListener(
44 WebInspector.NetworkRequest.Events.EventSourceMessageAdded, this._messag eAdded, this); 44 SDK.NetworkRequest.Events.EventSourceMessageAdded, this._messageAdded, t his);
45 } 45 }
46 46
47 /** 47 /**
48 * @override 48 * @override
49 */ 49 */
50 willHide() { 50 willHide() {
51 this._request.removeEventListener( 51 this._request.removeEventListener(
52 WebInspector.NetworkRequest.Events.EventSourceMessageAdded, this._messag eAdded, this); 52 SDK.NetworkRequest.Events.EventSourceMessageAdded, this._messageAdded, t his);
53 } 53 }
54 54
55 /** 55 /**
56 * @param {!WebInspector.Event} event 56 * @param {!Common.Event} event
57 */ 57 */
58 _messageAdded(event) { 58 _messageAdded(event) {
59 var message = /** @type {!WebInspector.NetworkRequest.EventSourceMessage} */ (event.data); 59 var message = /** @type {!SDK.NetworkRequest.EventSourceMessage} */ (event.d ata);
60 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(message)) ; 60 this._dataGrid.insertChild(new Network.EventSourceMessageNode(message));
61 } 61 }
62 62
63 _sortItems() { 63 _sortItems() {
64 var sortColumnId = this._dataGrid.sortColumnId(); 64 var sortColumnId = this._dataGrid.sortColumnId();
65 if (!sortColumnId) 65 if (!sortColumnId)
66 return; 66 return;
67 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortColumnI d]; 67 var comparator = Network.EventSourceMessageNode.Comparators[sortColumnId];
68 if (!comparator) 68 if (!comparator)
69 return; 69 return;
70 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscending()) ; 70 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscending()) ;
71 } 71 }
72 }; 72 };
73 73
74 /** 74 /**
75 * @unrestricted 75 * @unrestricted
76 */ 76 */
77 WebInspector.EventSourceMessageNode = class extends WebInspector.SortableDataGri dNode { 77 Network.EventSourceMessageNode = class extends UI.SortableDataGridNode {
78 /** 78 /**
79 * @param {!WebInspector.NetworkRequest.EventSourceMessage} message 79 * @param {!SDK.NetworkRequest.EventSourceMessage} message
80 */ 80 */
81 constructor(message) { 81 constructor(message) {
82 var time = new Date(message.time * 1000); 82 var time = new Date(message.time * 1000);
83 var timeText = ('0' + time.getHours()).substr(-2) + ':' + ('0' + time.getMin utes()).substr(-2) + ':' + 83 var timeText = ('0' + time.getHours()).substr(-2) + ':' + ('0' + time.getMin utes()).substr(-2) + ':' +
84 ('0' + time.getSeconds()).substr(-2) + '.' + ('00' + time.getMillisecond s()).substr(-3); 84 ('0' + time.getSeconds()).substr(-2) + '.' + ('00' + time.getMillisecond s()).substr(-3);
85 var timeNode = createElement('div'); 85 var timeNode = createElement('div');
86 timeNode.createTextChild(timeText); 86 timeNode.createTextChild(timeText);
87 timeNode.title = time.toLocaleString(); 87 timeNode.title = time.toLocaleString();
88 super({id: message.eventId, type: message.eventName, data: message.data, tim e: timeNode}); 88 super({id: message.eventId, type: message.eventName, data: message.data, tim e: timeNode});
89 this._message = message; 89 this._message = message;
90 } 90 }
91 }; 91 };
92 92
93 /** 93 /**
94 * @param {string} field 94 * @param {string} field
95 * @param {!WebInspector.EventSourceMessageNode} a 95 * @param {!Network.EventSourceMessageNode} a
96 * @param {!WebInspector.EventSourceMessageNode} b 96 * @param {!Network.EventSourceMessageNode} b
97 * @return {number} 97 * @return {number}
98 */ 98 */
99 WebInspector.EventSourceMessageNodeComparator = function(field, a, b) { 99 Network.EventSourceMessageNodeComparator = function(field, a, b) {
100 var aValue = a._message[field]; 100 var aValue = a._message[field];
101 var bValue = b._message[field]; 101 var bValue = b._message[field];
102 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; 102 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
103 }; 103 };
104 104
105 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ 105 /** @type {!Object.<string, !UI.SortableDataGrid.NodeComparator>} */
106 WebInspector.EventSourceMessageNode.Comparators = { 106 Network.EventSourceMessageNode.Comparators = {
107 'id': WebInspector.EventSourceMessageNodeComparator.bind(null, 'eventId'), 107 'id': Network.EventSourceMessageNodeComparator.bind(null, 'eventId'),
108 'type': WebInspector.EventSourceMessageNodeComparator.bind(null, 'eventName'), 108 'type': Network.EventSourceMessageNodeComparator.bind(null, 'eventName'),
109 'time': WebInspector.EventSourceMessageNodeComparator.bind(null, 'time') 109 'time': Network.EventSourceMessageNodeComparator.bind(null, 'time')
110 }; 110 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698