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

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

Issue 1912973002: [DevTools] JSONView parsing smarter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js ('k') | no next file » | 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 29 matching lines...) Expand all
40 this._dataGrid = new WebInspector.SortableDataGrid(columns, undefined, undef ined, undefined, this._onContextMenu.bind(this)); 40 this._dataGrid = new WebInspector.SortableDataGrid(columns, undefined, undef ined, undefined, this._onContextMenu.bind(this));
41 this._dataGrid.setStickToBottom(true); 41 this._dataGrid.setStickToBottom(true);
42 this._dataGrid.setCellClass("websocket-frame-view-td"); 42 this._dataGrid.setCellClass("websocket-frame-view-td");
43 this._timeComparator = /** @type {!WebInspector.SortableDataGrid.NodeCompara tor} */ (WebInspector.ResourceWebSocketFrameNodeTimeComparator); 43 this._timeComparator = /** @type {!WebInspector.SortableDataGrid.NodeCompara tor} */ (WebInspector.ResourceWebSocketFrameNodeTimeComparator);
44 this._dataGrid.sortNodes(this._timeComparator, false); 44 this._dataGrid.sortNodes(this._timeComparator, false);
45 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding); 45 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding);
46 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this); 46 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this);
47 47
48 this._dataGrid.setName("ResourceWebSocketFrameView"); 48 this._dataGrid.setName("ResourceWebSocketFrameView");
49 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, t his._onFrameSelected, this); 49 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, t his._onFrameSelected, this);
50 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode, this._onFrameDeselected, this);
50 this._splitWidget.setMainWidget(this._dataGrid.asWidget()); 51 this._splitWidget.setMainWidget(this._dataGrid.asWidget());
51 52
52 var view = new WebInspector.EmptyWidget("Select frame to browse its content. "); 53 var view = new WebInspector.EmptyWidget("Select frame to browse its content. ");
53 this._splitWidget.setSidebarWidget(view); 54 this._splitWidget.setSidebarWidget(view);
55
56 /** @type {?WebInspector.ResourceWebSocketFrameNode} */
57 this._selectedNode = null;
54 } 58 }
55 59
56 /** @enum {number} */ 60 /** @enum {number} */
57 WebInspector.ResourceWebSocketFrameView.OpCodes = { 61 WebInspector.ResourceWebSocketFrameView.OpCodes = {
58 ContinuationFrame: 0, 62 ContinuationFrame: 0,
59 TextFrame: 1, 63 TextFrame: 1,
60 BinaryFrame: 2, 64 BinaryFrame: 2,
61 ConnectionCloseFrame: 8, 65 ConnectionCloseFrame: 8,
62 PingFrame: 9, 66 PingFrame: 9,
63 PongFrame: 10 67 PongFrame: 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 var frame = /** @type {!WebInspector.NetworkRequest.WebSocketFrame} */ ( event.data); 113 var frame = /** @type {!WebInspector.NetworkRequest.WebSocketFrame} */ ( event.data);
110 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNode(f rame)); 114 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNode(f rame));
111 }, 115 },
112 116
113 /** 117 /**
114 * @param {!WebInspector.Event} event 118 * @param {!WebInspector.Event} event
115 */ 119 */
116 _onFrameSelected: function(event) 120 _onFrameSelected: function(event)
117 { 121 {
118 var selectedNode = /** @type {!WebInspector.ResourceWebSocketFrameNode} */ (event.target.selectedNode); 122 var selectedNode = /** @type {!WebInspector.ResourceWebSocketFrameNode} */ (event.target.selectedNode);
123 this._currentSelectedNode = selectedNode;
119 var contentProvider = selectedNode.contentProvider(); 124 var contentProvider = selectedNode.contentProvider();
120 contentProvider.requestContent().then(content => { 125 contentProvider.requestContent().then(contentHandler.bind(this));
121 var parsedJSON = content ? WebInspector.JSONView.parseJSON(content) : null; 126
122 var view = parsedJSON ? new WebInspector.JSONView(parsedJSON) : new WebInspector.ResourceSourceFrame(contentProvider); 127 /**
123 this._splitWidget.setSidebarWidget(view); 128 * @param {(string|null)} content
124 }); 129 * @this {WebInspector.ResourceWebSocketFrameView}
130 */
131 function contentHandler(content) {
132 if (this._currentSelectedNode !== selectedNode)
133 return;
134 WebInspector.JSONView.parseJSON(content).then(handleJSONData.bind(th is));
135 }
136
137 /**
138 * @param {?WebInspector.ParsedJSON} parsedJSON
139 * @this {WebInspector.ResourceWebSocketFrameView}
140 */
141 function handleJSONData(parsedJSON)
142 {
143 if (this._currentSelectedNode !== selectedNode)
144 return;
145 if (parsedJSON)
146 this._splitWidget.setSidebarWidget(new WebInspector.JSONView(par sedJSON));
147 else
148 this._splitWidget.setSidebarWidget(new WebInspector.ResourceSour ceFrame(contentProvider));
149 }
150 },
151
152 /**
153 * @param {!WebInspector.Event} event
154 */
155 _onFrameDeselected: function(event)
156 {
157 this._currentSelectedNode = null;
125 }, 158 },
126 159
127 refresh: function() 160 refresh: function()
128 { 161 {
129 this._dataGrid.rootNode().removeChildren(); 162 this._dataGrid.rootNode().removeChildren();
130 var frames = this._request.frames(); 163 var frames = this._request.frames();
131 for (var i = 0; i < frames.length; ++i) 164 for (var i = 0; i < frames.length; ++i)
132 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(frames[i])); 165 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(frames[i]));
133 }, 166 },
134 167
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 248
216 /** 249 /**
217 * @param {!WebInspector.ResourceWebSocketFrameNode} a 250 * @param {!WebInspector.ResourceWebSocketFrameNode} a
218 * @param {!WebInspector.ResourceWebSocketFrameNode} b 251 * @param {!WebInspector.ResourceWebSocketFrameNode} b
219 * @return {number} 252 * @return {number}
220 */ 253 */
221 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b) 254 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b)
222 { 255 {
223 return a._frame.time - b._frame.time; 256 return a._frame.time - b._frame.time;
224 } 257 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698