Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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._clearAllButton = new UI.ToolbarButton(Common.UIString('Clear All'), 'l argeicon-clear'); |
| 63 this._splitWidget.setSidebarWidget(view); | 62 this._clearAllButton.addEventListener(UI.ToolbarButton.Events.Click, this._o nClearAllWidgetClicked, this); |
| 63 this._clearFrameOffset = 0; | |
| 64 | |
| 65 this._textFilterUI = new UI.TextFilterUI(true); | |
| 66 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ onFilterUIChanged, this); | |
|
allada
2017/04/17 21:11:19
Lets inline "_onFilterUIChanged"
ie: this.refresh
| |
| 67 | |
| 68 var typeFilterItems = [ | |
|
allada
2017/04/17 21:11:19
Lets move this to near the bottom of the file.
So
| |
| 69 {name: 'send', label: Common.UIString('Send')}, | |
| 70 {name: 'receive', label: Common.UIString('Receive')}, | |
| 71 ]; | |
| 72 this._typeFilterSetting = Common.settings.createSetting('resourceWebSocketFr ameViewTypeFilters', {}); | |
|
allada
2017/04/17 21:11:19
lets make this a local variable since it's not nee
| |
| 73 this._typeFilterUI = new UI.NamedBitSetFilterUI(typeFilterItems, this._typeF ilterSetting); | |
| 74 this._typeFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ onFilterUIChanged, this); | |
|
allada
2017/04/17 21:11:19
Same here... inline "_onFilterUIChanged"
ie: this
| |
| 75 | |
| 76 this._filterBar = new UI.FilterBar('resourceWebSocketFrameView', true); | |
|
allada
2017/04/17 21:11:19
lets rename this just "websocketFrameView". (resou
| |
| 77 this._filterBar.addFilter(this._textFilterUI); | |
|
allada
2017/04/17 21:11:19
Did you mean to add this twice?
muzuiget
2017/04/20 09:40:01
Sorry, I didn't get your point. One is "_textFilte
allada
2017/04/24 18:28:14
I see.
| |
| 78 this._filterBar.addFilter(this._typeFilterUI); | |
| 79 | |
| 80 this._mainToolbar = new UI.Toolbar(''); | |
| 81 this._mainToolbar.appendToolbarItem(this._clearAllButton); | |
| 82 this._mainToolbar.appendToolbarItem(this._filterBar.filterButton()); | |
| 83 | |
| 84 var mainContainer = new UI.VBox(); | |
| 85 mainContainer.element.appendChild(this._mainToolbar.element); | |
| 86 this._filterBar.show(mainContainer.element); | |
| 87 this._dataGrid.asWidget().show(mainContainer.element); | |
| 88 this._splitWidget.setMainWidget(mainContainer); | |
| 89 | |
| 90 this._frameEmptyWidget = new UI.EmptyWidget('Select frame to browse its cont ent.'); | |
|
allada
2017/04/17 21:11:19
I know this was not how it was originally, but can
| |
| 91 this._splitWidget.setSidebarWidget(this._frameEmptyWidget); | |
| 64 | 92 |
| 65 /** @type {?Network.ResourceWebSocketFrameNode} */ | 93 /** @type {?Network.ResourceWebSocketFrameNode} */ |
| 66 this._selectedNode = null; | 94 this._selectedNode = null; |
| 67 | 95 |
| 68 /** | 96 /** |
| 69 * @param {!UI.ContextMenu} contextMenu | 97 * @param {!UI.ContextMenu} contextMenu |
| 70 * @param {!DataGrid.DataGridNode} node | 98 * @param {!DataGrid.DataGridNode} node |
| 99 * @this {Network.ResourceWebSocketFrameView} | |
| 71 */ | 100 */ |
| 72 function onRowContextMenu(contextMenu, node) { | 101 function onRowContextMenu(contextMenu, node) { |
| 73 contextMenu.appendItem( | 102 contextMenu.appendItem( |
| 74 Common.UIString.capitalize('Copy ^message'), | 103 Common.UIString.capitalize('Copy ^message'), |
| 75 InspectorFrontendHost.copyText.bind(InspectorFrontendHost, node.data.d ata)); | 104 InspectorFrontendHost.copyText.bind(InspectorFrontendHost, node.data.d ata)); |
| 105 contextMenu.appendSeparator(); | |
| 106 contextMenu.appendItem(Common.UIString.capitalize('Clear ^all'), this._onC learAllWidgetClicked.bind(this)); | |
| 76 } | 107 } |
| 77 } | 108 } |
| 78 | 109 |
| 79 /** | 110 /** |
| 80 * @param {number} opCode | 111 * @param {number} opCode |
| 81 * @param {boolean} mask | 112 * @param {boolean} mask |
| 82 * @return {string} | 113 * @return {string} |
| 83 */ | 114 */ |
| 84 static opCodeDescription(opCode, mask) { | 115 static opCodeDescription(opCode, mask) { |
| 85 var rawDescription = Network.ResourceWebSocketFrameView.opCodeDescriptions[o pCode] || ''; | 116 var rawDescription = Network.ResourceWebSocketFrameView.opCodeDescriptions[o pCode] || ''; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 100 */ | 131 */ |
| 101 willHide() { | 132 willHide() { |
| 102 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this); | 133 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this); |
| 103 } | 134 } |
| 104 | 135 |
| 105 /** | 136 /** |
| 106 * @param {!Common.Event} event | 137 * @param {!Common.Event} event |
| 107 */ | 138 */ |
| 108 _frameAdded(event) { | 139 _frameAdded(event) { |
| 109 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data); | 140 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data); |
| 141 if (!this._frameFilter(frame)) | |
| 142 return; | |
| 110 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame)); | 143 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame)); |
| 111 } | 144 } |
| 112 | 145 |
| 113 /** | 146 /** |
| 147 * @param {!SDK.NetworkRequest.WebSocketFrame} frame | |
| 148 */ | |
| 149 _frameFilter(frame) { | |
| 150 var regex = this._textFilterUI.regex(); | |
|
allada
2017/04/17 21:11:19
In this case regex should be the tester used for b
| |
| 151 if (regex) { | |
| 152 if (!regex.test(frame.text)) | |
| 153 return false; | |
| 154 } else { | |
| 155 var text = this._textFilterUI.value(); | |
| 156 if (!frame.text.includes(text)) | |
| 157 return false; | |
| 158 } | |
| 159 | |
| 160 if (!this._typeFilterUI.accept(frame.type)) | |
| 161 return false; | |
| 162 | |
| 163 return true; | |
| 164 } | |
| 165 | |
| 166 /** | |
| 167 * @param {!Common.Event} event | |
| 168 */ | |
| 169 _onClearAllWidgetClicked(event) { | |
|
allada
2017/04/17 21:11:19
Lets rename this "_clearFrames" and remove the eve
| |
| 170 this._clearFrameOffset = this._request.frames().length; | |
| 171 this.refresh(); | |
| 172 } | |
| 173 | |
| 174 /** | |
| 175 * @param {!Common.Event} event | |
| 176 */ | |
| 177 _onFilterUIChanged(event) { | |
| 178 this.refresh(); | |
| 179 } | |
| 180 | |
| 181 /** | |
| 114 * @param {!Common.Event} event | 182 * @param {!Common.Event} event |
| 115 */ | 183 */ |
| 116 _onFrameSelected(event) { | 184 _onFrameSelected(event) { |
| 117 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data); | 185 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data); |
| 118 this._currentSelectedNode = selectedNode; | 186 this._currentSelectedNode = selectedNode; |
| 119 var contentProvider = selectedNode.contentProvider(); | 187 var contentProvider = selectedNode.contentProvider(); |
| 120 contentProvider.requestContent().then(contentHandler.bind(this)); | 188 contentProvider.requestContent().then(contentHandler.bind(this)); |
| 121 | 189 |
| 122 /** | 190 /** |
| 123 * @param {(string|null)} content | 191 * @param {(string|null)} content |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 141 else | 209 else |
| 142 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider)); | 210 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider)); |
| 143 } | 211 } |
| 144 } | 212 } |
| 145 | 213 |
| 146 /** | 214 /** |
| 147 * @param {!Common.Event} event | 215 * @param {!Common.Event} event |
| 148 */ | 216 */ |
| 149 _onFrameDeselected(event) { | 217 _onFrameDeselected(event) { |
| 150 this._currentSelectedNode = null; | 218 this._currentSelectedNode = null; |
| 219 this._splitWidget.setSidebarWidget(this._frameEmptyWidget); | |
| 151 } | 220 } |
| 152 | 221 |
| 153 refresh() { | 222 refresh() { |
| 154 this._dataGrid.rootNode().removeChildren(); | 223 this._dataGrid.rootNode().removeChildren(); |
| 224 | |
| 225 var url = this._request.url(); | |
| 155 var frames = this._request.frames(); | 226 var frames = this._request.frames(); |
| 156 for (var i = 0; i < frames.length; ++i) | 227 var start = this._clearFrameOffset; |
| 157 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._re quest.url(), frames[i])); | 228 for (var i = start; i < frames.length; ++i) { |
|
allada
2017/04/17 21:11:19
Can we change this to:
frames = frames.slice(this
| |
| 229 var frame = frames[i]; | |
| 230 if (this._frameFilter(frame)) | |
| 231 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(url, f rame)); | |
| 232 } | |
| 158 } | 233 } |
| 159 | 234 |
| 160 _sortItems() { | 235 _sortItems() { |
| 161 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending()); | 236 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending()); |
| 162 } | 237 } |
| 163 }; | 238 }; |
| 164 | 239 |
| 165 /** @enum {number} */ | 240 /** @enum {number} */ |
| 166 Network.ResourceWebSocketFrameView.OpCodes = { | 241 Network.ResourceWebSocketFrameView.OpCodes = { |
| 167 ContinuationFrame: 0, | 242 ContinuationFrame: 0, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 }; | 321 }; |
| 247 | 322 |
| 248 /** | 323 /** |
| 249 * @param {!Network.ResourceWebSocketFrameNode} a | 324 * @param {!Network.ResourceWebSocketFrameNode} a |
| 250 * @param {!Network.ResourceWebSocketFrameNode} b | 325 * @param {!Network.ResourceWebSocketFrameNode} b |
| 251 * @return {number} | 326 * @return {number} |
| 252 */ | 327 */ |
| 253 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) { | 328 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) { |
| 254 return a._frame.time - b._frame.time; | 329 return a._frame.time - b._frame.time; |
| 255 }; | 330 }; |
| OLD | NEW |