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

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

Issue 2806993002: DevTools: WebSocketFrameView - Add frames display control toolbar (Closed)
Patch Set: wip Created 3 years, 7 months 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
« no previous file with comments | « AUTHORS ('k') | third_party/WebKit/Source/devtools/front_end/network/webSocketFrameView.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public 5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 26 matching lines...) Expand all
37 id: 'length', 37 id: 'length',
38 title: Common.UIString('Length'), 38 title: Common.UIString('Length'),
39 sortable: false, 39 sortable: false,
40 align: DataGrid.DataGrid.Align.Right, 40 align: DataGrid.DataGrid.Align.Right,
41 weight: 5 41 weight: 5
42 }, 42 },
43 {id: 'time', title: Common.UIString('Time'), sortable: true, weight: 7} 43 {id: 'time', title: Common.UIString('Time'), sortable: true, weight: 7}
44 ]); 44 ]);
45 45
46 this._dataGrid = new DataGrid.SortableDataGrid(columns); 46 this._dataGrid = new DataGrid.SortableDataGrid(columns);
47 this._dataGrid.setRowContextMenuCallback(onRowContextMenu); 47 this._dataGrid.setRowContextMenuCallback(onRowContextMenu.bind(this));
48 this._dataGrid.setStickToBottom(true); 48 this._dataGrid.setStickToBottom(true);
49 this._dataGrid.setCellClass('websocket-frame-view-td'); 49 this._dataGrid.setCellClass('websocket-frame-view-td');
50 this._timeComparator = 50 this._timeComparator =
51 /** @type {function(!Network.ResourceWebSocketFrameNode, !Network.Resour ceWebSocketFrameNode):number} */ ( 51 /** @type {function(!Network.ResourceWebSocketFrameNode, !Network.Resour ceWebSocketFrameNode):number} */ (
52 Network.ResourceWebSocketFrameNodeTimeComparator); 52 Network.ResourceWebSocketFrameNodeTimeComparator);
53 this._dataGrid.sortNodes(this._timeComparator, false); 53 this._dataGrid.sortNodes(this._timeComparator, false);
54 this._dataGrid.markColumnAsSortedBy('time', DataGrid.DataGrid.Order.Ascendin g); 54 this._dataGrid.markColumnAsSortedBy('time', DataGrid.DataGrid.Order.Ascendin g);
55 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortItems, this); 55 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortItems, this);
56 56
57 this._dataGrid.setName('ResourceWebSocketFrameView'); 57 this._dataGrid.setName('ResourceWebSocketFrameView');
58 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this. _onFrameSelected, this); 58 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this. _onFrameSelected, this);
59 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, thi s._onFrameDeselected, this); 59 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, thi s._onFrameDeselected, this);
60 this._splitWidget.setMainWidget(this._dataGrid.asWidget());
61 60
62 var view = new UI.EmptyWidget('Select frame to browse its content.'); 61 this._mainToolbar = new UI.Toolbar('');
63 this._splitWidget.setSidebarWidget(view); 62
63 this._clearAllButton = new UI.ToolbarButton(Common.UIString('Clear All'), 'l argeicon-clear');
64 this._clearAllButton.addEventListener(UI.ToolbarButton.Events.Click, this._c learFrames, this);
65 this._mainToolbar.appendToolbarItem(this._clearAllButton);
66
67 this._filterTypeCombobox = new UI.ToolbarComboBox(this._updateFilterSetting. bind(this));
68 for (var filterItem of Network.ResourceWebSocketFrameView._filterTypes) {
69 var option = this._filterTypeCombobox.createOption(filterItem.label, filte rItem.label, filterItem.name);
70 this._filterTypeCombobox.addOption(option);
71 }
72 this._mainToolbar.appendToolbarItem(this._filterTypeCombobox);
73 this._filterType = null;
74
75 this._filterTextInput = new UI.ToolbarInput(Common.UIString('Filter'), 0.4, undefined, true);
dgozman 2017/05/05 19:04:45 So, what about placeholder saying "Enter regex, fo
76 this._filterTextInput.addEventListener(UI.ToolbarInput.Event.TextChanged, th is._updateFilterSetting, this);
77 this._mainToolbar.appendToolbarItem(this._filterTextInput);
78 this._filterRegex = null;
79
80 var mainContainer = new UI.VBox();
81 mainContainer.element.appendChild(this._mainToolbar.element);
82 this._dataGrid.asWidget().show(mainContainer.element);
83 this._splitWidget.setMainWidget(mainContainer);
84
85 this._frameEmptyWidget = new UI.EmptyWidget(Common.UIString('Select frame to browse its content.'));
86 this._splitWidget.setSidebarWidget(this._frameEmptyWidget);
64 87
65 /** @type {?Network.ResourceWebSocketFrameNode} */ 88 /** @type {?Network.ResourceWebSocketFrameNode} */
66 this._selectedNode = null; 89 this._selectedNode = null;
67 90
68 /** 91 /**
69 * @param {!UI.ContextMenu} contextMenu 92 * @param {!UI.ContextMenu} contextMenu
70 * @param {!DataGrid.DataGridNode} node 93 * @param {!DataGrid.DataGridNode} node
94 * @this {Network.ResourceWebSocketFrameView}
71 */ 95 */
72 function onRowContextMenu(contextMenu, node) { 96 function onRowContextMenu(contextMenu, node) {
73 contextMenu.appendItem( 97 contextMenu.appendItem(
74 Common.UIString.capitalize('Copy ^message'), 98 Common.UIString.capitalize('Copy ^message'),
75 InspectorFrontendHost.copyText.bind(InspectorFrontendHost, node.data.d ata)); 99 InspectorFrontendHost.copyText.bind(InspectorFrontendHost, node.data.d ata));
100 contextMenu.appendSeparator();
101 contextMenu.appendItem(Common.UIString.capitalize('Clear ^all'), this._cle arFrames.bind(this));
76 } 102 }
77 } 103 }
78 104
79 /** 105 /**
80 * @param {number} opCode 106 * @param {number} opCode
81 * @param {boolean} mask 107 * @param {boolean} mask
82 * @return {string} 108 * @return {string}
83 */ 109 */
84 static opCodeDescription(opCode, mask) { 110 static opCodeDescription(opCode, mask) {
85 var rawDescription = Network.ResourceWebSocketFrameView.opCodeDescriptions[o pCode] || ''; 111 var rawDescription = Network.ResourceWebSocketFrameView.opCodeDescriptions[o pCode] || '';
(...skipping 14 matching lines...) Expand all
100 */ 126 */
101 willHide() { 127 willHide() {
102 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this); 128 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this);
103 } 129 }
104 130
105 /** 131 /**
106 * @param {!Common.Event} event 132 * @param {!Common.Event} event
107 */ 133 */
108 _frameAdded(event) { 134 _frameAdded(event) {
109 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data); 135 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data);
136 if (!this._frameFilter(frame))
137 return;
110 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame)); 138 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame));
111 } 139 }
112 140
113 /** 141 /**
114 * @param {!Common.Event} event 142 * @param {!SDK.NetworkRequest.WebSocketFrame} frame
143 * @return {boolean}
144 */
145 _frameFilter(frame) {
146 if (this._filterType && frame.type !== this._filterType)
147 return false;
148 return !this._filterRegex || this._filterRegex.test(frame.text);
149 }
150
151 _clearFrames() {
152 this._request._clearFrameOffset = this._request.frames().length;
dgozman 2017/05/05 19:04:45 I meant JavaScript symbol here: this._request[Net
allada 2017/05/05 19:05:46 Please add this above this line: // TODO(allada):
allada 2017/05/05 19:05:46 Example of the symbol stuff he was talking about:
153 this.refresh();
154 }
155
156 _updateFilterSetting() {
157 var text = this._filterTextInput.value();
158 var type = this._filterTypeCombobox.selectedOption().value;
159 this._filterRegex = text ? new RegExp(text.escapeForRegExp(), 'i') : null;
160 this._filterType = type === 'all' ? null : type;
161 this.refresh();
162 }
163
164 /**
165 * @param {!Common.Event} event
115 */ 166 */
116 _onFrameSelected(event) { 167 _onFrameSelected(event) {
117 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data); 168 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data);
118 this._currentSelectedNode = selectedNode; 169 this._currentSelectedNode = selectedNode;
119 var contentProvider = selectedNode.contentProvider(); 170 var contentProvider = selectedNode.contentProvider();
120 contentProvider.requestContent().then(contentHandler.bind(this)); 171 contentProvider.requestContent().then(contentHandler.bind(this));
121 172
122 /** 173 /**
123 * @param {(string|null)} content 174 * @param {(string|null)} content
124 * @this {Network.ResourceWebSocketFrameView} 175 * @this {Network.ResourceWebSocketFrameView}
(...skipping 16 matching lines...) Expand all
141 else 192 else
142 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider)); 193 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider));
143 } 194 }
144 } 195 }
145 196
146 /** 197 /**
147 * @param {!Common.Event} event 198 * @param {!Common.Event} event
148 */ 199 */
149 _onFrameDeselected(event) { 200 _onFrameDeselected(event) {
150 this._currentSelectedNode = null; 201 this._currentSelectedNode = null;
202 this._splitWidget.setSidebarWidget(this._frameEmptyWidget);
151 } 203 }
152 204
153 refresh() { 205 refresh() {
154 this._dataGrid.rootNode().removeChildren(); 206 this._dataGrid.rootNode().removeChildren();
207
208 var url = this._request.url();
155 var frames = this._request.frames(); 209 var frames = this._request.frames();
156 for (var i = 0; i < frames.length; ++i) 210 frames = frames.slice(this._request._clearFrameOffset || 0);
allada 2017/05/05 19:05:46 And here would be: var offset = this._request[Netw
157 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._re quest.url(), frames[i])); 211 frames = frames.filter(this._frameFilter.bind(this));
212 frames.forEach(frame => this._dataGrid.insertChild(new Network.ResourceWebSo cketFrameNode(url, frame)));
158 } 213 }
159 214
160 _sortItems() { 215 _sortItems() {
161 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending()); 216 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending());
162 } 217 }
163 }; 218 };
164 219
allada 2017/05/05 19:05:46 Then add this here: Network.ResourceWebSocketFram
165 /** @enum {number} */ 220 /** @enum {number} */
166 Network.ResourceWebSocketFrameView.OpCodes = { 221 Network.ResourceWebSocketFrameView.OpCodes = {
167 ContinuationFrame: 0, 222 ContinuationFrame: 0,
168 TextFrame: 1, 223 TextFrame: 1,
169 BinaryFrame: 2, 224 BinaryFrame: 2,
170 ConnectionCloseFrame: 8, 225 ConnectionCloseFrame: 8,
171 PingFrame: 9, 226 PingFrame: 9,
172 PongFrame: 10 227 PongFrame: 10
173 }; 228 };
174 229
175 /** @type {!Array.<string> } */ 230 /** @type {!Array.<string> } */
176 Network.ResourceWebSocketFrameView.opCodeDescriptions = (function() { 231 Network.ResourceWebSocketFrameView.opCodeDescriptions = (function() {
177 var opCodes = Network.ResourceWebSocketFrameView.OpCodes; 232 var opCodes = Network.ResourceWebSocketFrameView.OpCodes;
178 var map = []; 233 var map = [];
179 map[opCodes.ContinuationFrame] = 'Continuation Frame'; 234 map[opCodes.ContinuationFrame] = 'Continuation Frame';
180 map[opCodes.TextFrame] = 'Text Frame'; 235 map[opCodes.TextFrame] = 'Text Frame';
181 map[opCodes.BinaryFrame] = 'Binary Frame'; 236 map[opCodes.BinaryFrame] = 'Binary Frame';
182 map[opCodes.ContinuationFrame] = 'Connection Close Frame'; 237 map[opCodes.ContinuationFrame] = 'Connection Close Frame';
183 map[opCodes.PingFrame] = 'Ping Frame'; 238 map[opCodes.PingFrame] = 'Ping Frame';
184 map[opCodes.PongFrame] = 'Pong Frame'; 239 map[opCodes.PongFrame] = 'Pong Frame';
185 return map; 240 return map;
186 })(); 241 })();
187 242
243 /** @type {!Array<!UI.NamedBitSetFilterUI.Item>} */
244 Network.ResourceWebSocketFrameView._filterTypes = [
245 {name: 'all', label: Common.UIString('All')},
246 {name: 'send', label: Common.UIString('Send')},
247 {name: 'receive', label: Common.UIString('Receive')},
248 ];
188 249
189 /** 250 /**
190 * @unrestricted 251 * @unrestricted
191 */ 252 */
192 Network.ResourceWebSocketFrameNode = class extends DataGrid.SortableDataGridNode { 253 Network.ResourceWebSocketFrameNode = class extends DataGrid.SortableDataGridNode {
193 /** 254 /**
194 * @param {string} url 255 * @param {string} url
195 * @param {!SDK.NetworkRequest.WebSocketFrame} frame 256 * @param {!SDK.NetworkRequest.WebSocketFrame} frame
196 */ 257 */
197 constructor(url, frame) { 258 constructor(url, frame) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 }; 307 };
247 308
248 /** 309 /**
249 * @param {!Network.ResourceWebSocketFrameNode} a 310 * @param {!Network.ResourceWebSocketFrameNode} a
250 * @param {!Network.ResourceWebSocketFrameNode} b 311 * @param {!Network.ResourceWebSocketFrameNode} b
251 * @return {number} 312 * @return {number}
252 */ 313 */
253 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) { 314 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) {
254 return a._frame.time - b._frame.time; 315 return a._frame.time - b._frame.time;
255 }; 316 };
OLDNEW
« no previous file with comments | « AUTHORS ('k') | third_party/WebKit/Source/devtools/front_end/network/webSocketFrameView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698