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

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

Issue 2523633003: [Devtools] Prepare network log view for grouping support (Closed)
Patch Set: changes Created 4 years 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 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 /** @type {!Map.<string, !Network.NetworkDataGridNode>} */ 74 /** @type {!Map.<string, !Network.NetworkDataGridNode>} */
75 this._nodesByRequestId = new Map(); 75 this._nodesByRequestId = new Map();
76 /** @type {!Object.<string, boolean>} */ 76 /** @type {!Object.<string, boolean>} */
77 this._staleRequestIds = {}; 77 this._staleRequestIds = {};
78 /** @type {number} */ 78 /** @type {number} */
79 this._mainRequestLoadTime = -1; 79 this._mainRequestLoadTime = -1;
80 /** @type {number} */ 80 /** @type {number} */
81 this._mainRequestDOMContentLoadedTime = -1; 81 this._mainRequestDOMContentLoadedTime = -1;
82 this._matchedRequestCount = 0; 82 this._matchedRequestCount = 0;
83 /** @type {!Array<!Array<!Object>>} */
83 this._highlightedSubstringChanges = []; 84 this._highlightedSubstringChanges = [];
84 85
85 /** @type {!Array.<!Network.NetworkLogView.Filter>} */ 86 /** @type {!Array.<!Network.NetworkLogView.Filter>} */
86 this._filters = []; 87 this._filters = [];
87 /** @type {?Network.NetworkLogView.Filter} */ 88 /** @type {?Network.NetworkLogView.Filter} */
88 this._timeFilter = null; 89 this._timeFilter = null;
90 /** @type {?Network.NetworkDataGridNode} */
89 this._hoveredNode = null; 91 this._hoveredNode = null;
90 92
91 this._currentMatchedRequestNode = null; 93 /** @type {?Network.NetworkDataGridNode} */
92 this._currentMatchedRequestIndex = -1; 94 this._currentMatchedNode = null;
95 this._currentMatchedNodeIndex = -1;
93 96
94 /** @type {!Components.Linkifier} */ 97 /** @type {!Components.Linkifier} */
95 this.linkifier = new Components.Linkifier(); 98 this.linkifier = new Components.Linkifier();
96 99
97 this._recording = false; 100 this._recording = false;
98 this._preserveLog = false; 101 this._preserveLog = false;
99 102
100 this._headerHeight = 0; 103 this._headerHeight = 0;
101 104
102 this._addFilters(); 105 this._addFilters();
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 */ 502 */
500 elementsToRestoreScrollPositionsFor() { 503 elementsToRestoreScrollPositionsFor() {
501 if (!this._dataGrid) // Not initialized yet. 504 if (!this._dataGrid) // Not initialized yet.
502 return []; 505 return [];
503 return [this._dataGrid.scrollContainer]; 506 return [this._dataGrid.scrollContainer];
504 } 507 }
505 508
506 _setupDataGrid() { 509 _setupDataGrid() {
507 /** @type {!UI.SortableDataGrid} */ 510 /** @type {!UI.SortableDataGrid} */
508 this._dataGrid = this._columns.dataGrid(); 511 this._dataGrid = this._columns.dataGrid();
512 var contextHandler = this.handleContextMenuForNode.bind(this);
509 this._dataGrid.setRowContextMenuCallback( 513 this._dataGrid.setRowContextMenuCallback(
510 (contextMenu, node) => this.handleContextMenuForRequest(contextMenu, nod e.request())); 514 (contextMenu, node) => contextHandler(contextMenu, /** @type {!Network.N etworkDataGridNode} */ (node)));
511 this._dataGrid.setStickToBottom(true); 515 this._dataGrid.setStickToBottom(true);
512 this._dataGrid.setName('networkLog'); 516 this._dataGrid.setName('networkLog');
513 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last); 517 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last);
514 this._dataGrid.element.classList.add('network-log-grid'); 518 this._dataGrid.element.classList.add('network-log-grid');
515 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true); 519 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true);
516 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true); 520 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true);
517 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true); 521 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true);
518 } 522 }
519 523
520 /** 524 /**
521 * @param {!Event} event 525 * @param {!Event} event
522 */ 526 */
523 _dataGridMouseMove(event) { 527 _dataGridMouseMove(event) {
524 var node = /** @type {?Network.NetworkDataGridNode} */ ( 528 var node = /** @type {?Network.NetworkDataGridNode} */ (
525 this._dataGrid.dataGridNodeFromNode(/** @type {!Node} */ (event.target)) ); 529 this._dataGrid.dataGridNodeFromNode(/** @type {!Node} */ (event.target)) );
526 var highlightInitiatorChain = event.shiftKey; 530 var highlightInitiatorChain = event.shiftKey;
527 this._setHoveredNode(node, highlightInitiatorChain); 531 this._setHoveredNode(node, highlightInitiatorChain);
532 // TODO(allada) Support groupping initiator chain instead of first request.
528 this._highlightInitiatorChain((highlightInitiatorChain && node) ? node.reque st() : null); 533 this._highlightInitiatorChain((highlightInitiatorChain && node) ? node.reque st() : null);
529 } 534 }
530 535
531 _dataGridMouseLeave() { 536 _dataGridMouseLeave() {
532 this._setHoveredNode(null); 537 this._setHoveredNode(null);
533 this._highlightInitiatorChain(null); 538 this._highlightInitiatorChain(null);
534 } 539 }
535 540
536 /** 541 /**
537 * @param {?Network.NetworkLogEntry} logEntry 542 * @param {?Network.NetworkDataGridNode} node
538 * @param {boolean} highlightInitiatorChain 543 * @param {boolean} highlightInitiatorChain
539 */ 544 */
540 setHoveredLogEntry(logEntry, highlightInitiatorChain) { 545 setHoveredNode(node, highlightInitiatorChain) {
541 // TODO(allada) Move this into LogEntry/NetworkDataGridNode. 546 // TODO(allada) Move this into NetworkDataGridNode.
542 this._setHoveredNode(/** @type {?Network.NetworkDataGridNode} */ (logEntry), highlightInitiatorChain); 547 this._setHoveredNode(node, highlightInitiatorChain);
543 this._highlightInitiatorChain((logEntry && highlightInitiatorChain) ? logEnt ry.request() : null); 548 // TODO(allada) Support groupping initiator chain instead of first request.
549 this._highlightInitiatorChain((node && highlightInitiatorChain) ? node.reque st() : null);
544 } 550 }
545 551
546 /** 552 /**
547 * @param {?Network.NetworkDataGridNode} node 553 * @param {?Network.NetworkDataGridNode} node
548 * @param {boolean=} highlightInitiatorChain 554 * @param {boolean=} highlightInitiatorChain
549 */ 555 */
550 _setHoveredNode(node, highlightInitiatorChain) { 556 _setHoveredNode(node, highlightInitiatorChain) {
551 if (this._hoveredNode) 557 if (this._hoveredNode)
552 this._hoveredNode.element().classList.remove('hover'); 558 this._hoveredNode.element().classList.remove('hover');
553 this._hoveredNode = node; 559 this._hoveredNode = node;
554 if (this._hoveredNode) 560 if (this._hoveredNode)
555 this._hoveredNode.element().classList.add('hover'); 561 this._hoveredNode.element().classList.add('hover');
556 this._columns.setHoveredLogEntry(this._hoveredNode, !!highlightInitiatorChai n); 562 this._columns.setHoveredNode(this._hoveredNode, !!highlightInitiatorChain);
557 } 563 }
558 564
559 /** 565 /**
560 * @param {!Event} event 566 * @param {!Event} event
561 */ 567 */
562 _dataGridMouseDown(event) { 568 _dataGridMouseDown(event) {
563 if (!this._dataGrid.selectedNode && event.button) 569 if (!this._dataGrid.selectedNode && event.button)
564 event.consume(); 570 event.consume();
565 } 571 }
566 572
567 /** 573 /**
568 * @param {?SDK.NetworkRequest} request 574 * @param {?SDK.NetworkRequest} request
569 */ 575 */
570 _highlightInitiatorChain(request) { 576 _highlightInitiatorChain(request) {
577 // TODO(allada) This should be converted into Node instead of request.
571 if (this._requestWithHighlightedInitiators === request) 578 if (this._requestWithHighlightedInitiators === request)
572 return; 579 return;
573 this._requestWithHighlightedInitiators = request; 580 this._requestWithHighlightedInitiators = request;
574 581
575 if (!request) { 582 if (!request) {
576 for (var node of this._nodesByRequestId.values()) { 583 for (var node of this._nodesByRequestId.values()) {
577 if (!node.dataGrid) 584 if (!node.dataGrid)
578 continue; 585 continue;
579 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path'); 586 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path');
580 } 587 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 /** 785 /**
779 * @override 786 * @override
780 */ 787 */
781 willHide() { 788 willHide() {
782 this._columns.willHide(); 789 this._columns.willHide();
783 } 790 }
784 791
785 /** 792 /**
786 * @return {!Array<!Network.NetworkDataGridNode>} 793 * @return {!Array<!Network.NetworkDataGridNode>}
787 */ 794 */
788 flatNodesList() { 795 flattenVisibleNodes() {
789 return this._dataGrid.rootNode().flattenChildren(); 796 return /** @type {!Array<!Network.NetworkDataGridNode>} */ (this._dataGrid.r ootNode().flattenChildren());
797 }
798
799 /**
800 * @return {!Array<!Network.NetworkDataGridNode>}
801 */
802 flattenAllNodes() {
803 return /** @type {!Array<!Network.NetworkDataGridNode>} */ (this._dataGrid.r ootNode().flattenChildren(true));
790 } 804 }
791 805
792 _refresh() { 806 _refresh() {
793 this._needsRefresh = false; 807 this._needsRefresh = false;
794 808
795 if (this._refreshRequestId) { 809 if (this._refreshRequestId) {
796 this.element.window().cancelAnimationFrame(this._refreshRequestId); 810 this.element.window().cancelAnimationFrame(this._refreshRequestId);
797 delete this._refreshRequestId; 811 delete this._refreshRequestId;
798 } 812 }
799 813
(...skipping 22 matching lines...) Expand all
822 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 836 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
823 rootNode.removeChild(node); 837 rootNode.removeChild(node);
824 838
825 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut; 839 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut;
826 840
827 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 841 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
828 nodesToInsert.push(node); 842 nodesToInsert.push(node);
829 } 843 }
830 if (!isFilteredOut) 844 if (!isFilteredOut)
831 nodesToRefresh.push(node); 845 nodesToRefresh.push(node);
832 var request = node.request(); 846 for (var request of node.requests()) {
dgozman 2016/11/30 00:25:26 Isn't this n^2, since we return all requests in a
allada 2016/11/30 01:38:24 Done.
833 this._timeCalculator.updateBoundaries(request); 847 this._timeCalculator.updateBoundaries(request);
834 this._durationCalculator.updateBoundaries(request); 848 this._durationCalculator.updateBoundaries(request);
849 }
835 } 850 }
836 851
837 for (var i = 0; i < nodesToInsert.length; ++i) { 852 for (var node of nodesToInsert) {
838 var node = nodesToInsert[i];
839 var request = node.request();
840 dataGrid.insertChild(node); 853 dataGrid.insertChild(node);
841 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchReq uest(request); 854 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._nodeHasM atch(node);
842 } 855 }
843 856
844 for (var node of nodesToRefresh) 857 for (var node of nodesToRefresh)
845 node.refresh(); 858 node.refresh();
846 859
847 this._highlightNthMatchedRequestForSearch( 860 this._highlightNthMatchedNodeForSearch(this._updateMatchCountAndFindMatchInd ex(this._currentMatchedNode), false);
848 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false);
849 861
850 this._staleRequestIds = {}; 862 this._staleRequestIds = {};
851 this._updateSummaryBar(); 863 this._updateSummaryBar();
852 864
853 this._columns.dataChanged(); 865 this._columns.dataChanged();
854 } 866 }
855 867
856 reset() { 868 reset() {
857 this._requestWithHighlightedInitiators = null; 869 this._requestWithHighlightedInitiators = null;
858 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null); 870 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 * @param {!SDK.NetworkRequest} request 920 * @param {!SDK.NetworkRequest} request
909 */ 921 */
910 _appendRequest(request) { 922 _appendRequest(request) {
911 var node = new Network.NetworkDataGridNode(this, request); 923 var node = new Network.NetworkDataGridNode(this, request);
912 node[Network.NetworkLogView._isFilteredOutSymbol] = true; 924 node[Network.NetworkLogView._isFilteredOutSymbol] = true;
913 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false; 925 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false;
914 926
915 // In case of redirect request id is reassigned to a redirected 927 // In case of redirect request id is reassigned to a redirected
916 // request and we need to update _nodesByRequestId and search results. 928 // request and we need to update _nodesByRequestId and search results.
917 var originalRequestNode = this._nodesByRequestId.get(request.requestId); 929 var originalRequestNode = this._nodesByRequestId.get(request.requestId);
918 if (originalRequestNode) 930 var originalRequest = originalRequestNode ? originalRequestNode.request() : null;
919 this._nodesByRequestId.set(originalRequestNode.request().requestId, origin alRequestNode); 931 if (originalRequest)
932 this._nodesByRequestId.set(originalRequest.requestId, originalRequestNode) ;
933
920 this._nodesByRequestId.set(request.requestId, node); 934 this._nodesByRequestId.set(request.requestId, node);
921 935
922 // Pull all the redirects of the main request upon commit load. 936 // Pull all the redirects of the main request upon commit load.
923 if (request.redirects) { 937 if (request.redirects)
924 for (var i = 0; i < request.redirects.length; ++i) 938 request.redirects.forEach(this._refreshRequest.bind(this));
925 this._refreshRequest(request.redirects[i]);
926 }
927 939
928 this._refreshRequest(request); 940 this._refreshRequest(request);
929 } 941 }
930 942
931 /** 943 /**
932 * @param {!Common.Event} event 944 * @param {!Common.Event} event
933 */ 945 */
934 _onRequestUpdated(event) { 946 _onRequestUpdated(event) {
935 var request = /** @type {!SDK.NetworkRequest} */ (event.data); 947 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
936 this._refreshRequest(request); 948 this._refreshRequest(request);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1039
1028 /** 1040 /**
1029 * @param {boolean} gridMode 1041 * @param {boolean} gridMode
1030 */ 1042 */
1031 switchViewMode(gridMode) { 1043 switchViewMode(gridMode) {
1032 this._columns.switchViewMode(gridMode); 1044 this._columns.switchViewMode(gridMode);
1033 } 1045 }
1034 1046
1035 /** 1047 /**
1036 * @param {!UI.ContextMenu} contextMenu 1048 * @param {!UI.ContextMenu} contextMenu
1037 * @param {!SDK.NetworkRequest} request 1049 * @param {!Network.NetworkDataGridNode} node
1038 */ 1050 */
1039 handleContextMenuForRequest(contextMenu, request) { 1051 handleContextMenuForNode(contextMenu, node) {
1052 // TODO(allada) Support groupped items context menu.
1053 var request = node.request();
1054 if (!request)
1055 return;
1040 contextMenu.appendApplicableItems(request); 1056 contextMenu.appendApplicableItems(request);
1041 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy')); 1057 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy'));
1042 if (request) { 1058 if (request) {
1043 copyMenu.appendItem( 1059 copyMenu.appendItem(
1044 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL())); 1060 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL()));
1045 copyMenu.appendSeparator(); 1061 copyMenu.appendSeparator();
1046 1062
1047 if (request.requestHeadersText()) { 1063 if (request.requestHeadersText()) {
1048 copyMenu.appendItem( 1064 copyMenu.appendItem(
1049 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request)); 1065 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1114 }
1099 } 1115 }
1100 1116
1101 if (request && request.resourceType() === Common.resourceTypes.XHR) { 1117 if (request && request.resourceType() === Common.resourceTypes.XHR) {
1102 contextMenu.appendSeparator(); 1118 contextMenu.appendSeparator();
1103 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request)); 1119 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request));
1104 contextMenu.appendSeparator(); 1120 contextMenu.appendSeparator();
1105 } 1121 }
1106 } 1122 }
1107 1123
1124 /**
1125 * @return {!Array<!SDK.NetworkRequest>}
1126 */
1127 _allRequests() {
1128 var requests = [];
1129 for (var node of this.flattenAllNodes())
1130 requests = requests.concat(node.requests());
dgozman 2016/11/30 00:25:26 Ditto.
allada 2016/11/30 01:38:24 Done.
1131 return requests;
1132 }
1133
1108 _harRequests() { 1134 _harRequests() {
1109 var requests = this._nodesByRequestId.valuesArray().map(function(node) { 1135 var httpRequests = this._allRequests().filter(Network.NetworkLogView.HTTPReq uestsFilter);
1110 return node.request();
1111 });
1112 var httpRequests = requests.filter(Network.NetworkLogView.HTTPRequestsFilter );
1113 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter); 1136 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter);
1114 } 1137 }
1115 1138
1116 _copyAll() { 1139 _copyAll() {
1117 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()}; 1140 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()};
1118 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2)); 1141 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2));
1119 } 1142 }
1120 1143
1121 /** 1144 /**
1122 * @param {!SDK.NetworkRequest} request 1145 * @param {!SDK.NetworkRequest} request
(...skipping 22 matching lines...) Expand all
1145 */ 1168 */
1146 _copyResponseHeaders(request) { 1169 _copyResponseHeaders(request) {
1147 InspectorFrontendHost.copyText(request.responseHeadersText); 1170 InspectorFrontendHost.copyText(request.responseHeadersText);
1148 } 1171 }
1149 1172
1150 /** 1173 /**
1151 * @param {!SDK.NetworkRequest} request 1174 * @param {!SDK.NetworkRequest} request
1152 * @param {string} platform 1175 * @param {string} platform
1153 */ 1176 */
1154 _copyCurlCommand(request, platform) { 1177 _copyCurlCommand(request, platform) {
1155 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platform)) ; 1178 InspectorFrontendHost.copyText(this._generateCurlCommand(platform, request)) ;
1156 } 1179 }
1157 1180
1158 /** 1181 /**
1159 * @param {string} platform 1182 * @param {string} platform
1160 */ 1183 */
1161 _copyAllCurlCommand(platform) { 1184 _copyAllCurlCommand(platform) {
1162 var requests = this._nodesByRequestId.valuesArray().map(node => node.request ()); 1185 var commands = this._allRequests().map(this._generateCurlCommand.bind(this, platform));
1163 var commands = [];
1164 for (var request of requests)
1165 commands.push(this._generateCurlCommand(request, platform));
1166 if (platform === 'win') 1186 if (platform === 'win')
1167 InspectorFrontendHost.copyText(commands.join(' &\r\n')); 1187 InspectorFrontendHost.copyText(commands.join(' &\r\n'));
1168 else 1188 else
1169 InspectorFrontendHost.copyText(commands.join(' ;\n')); 1189 InspectorFrontendHost.copyText(commands.join(' ;\n'));
1170 } 1190 }
1171 1191
1172 _exportAll() { 1192 _exportAll() {
1173 var url = SDK.targetManager.mainTarget().inspectedURL(); 1193 var url = SDK.targetManager.mainTarget().inspectedURL();
1174 var parsedURL = url.asParsedURL(); 1194 var parsedURL = url.asParsedURL();
1175 var filename = parsedURL ? parsedURL.host : 'network-log'; 1195 var filename = parsedURL ? parsedURL.host : 'network-log';
(...skipping 18 matching lines...) Expand all
1194 if (confirm(Common.UIString('Are you sure you want to clear browser cache?') )) 1214 if (confirm(Common.UIString('Are you sure you want to clear browser cache?') ))
1195 SDK.multitargetNetworkManager.clearBrowserCache(); 1215 SDK.multitargetNetworkManager.clearBrowserCache();
1196 } 1216 }
1197 1217
1198 _clearBrowserCookies() { 1218 _clearBrowserCookies() {
1199 if (confirm(Common.UIString('Are you sure you want to clear browser cookies? '))) 1219 if (confirm(Common.UIString('Are you sure you want to clear browser cookies? ')))
1200 SDK.multitargetNetworkManager.clearBrowserCookies(); 1220 SDK.multitargetNetworkManager.clearBrowserCookies();
1201 } 1221 }
1202 1222
1203 /** 1223 /**
1204 * @param {!SDK.NetworkRequest} request 1224 * @param {!Network.NetworkDataGridNode} node
1205 * @return {boolean} 1225 * @return {boolean}
1206 */ 1226 */
1207 _matchRequest(request) { 1227 _nodeHasMatch(node) {
1208 var re = this._searchRegex; 1228 var re = this._searchRegex;
1209 if (!re) 1229 if (!re)
1210 return false; 1230 return false;
1211 1231
1212 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + r equest.name() : request.name(); 1232 var request = node.request();
1213 return re.test(text); 1233 /** @type {!Array<!SDK.NetworkRequest>} */
1234 var requests = request ? [request] : [];
1235 requests.concat(node.requests());
dgozman 2016/11/30 00:25:26 This is n^2 as well.
allada 2016/11/30 01:38:24 Done.
1236 for (request of requests) {
1237 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + request.name() : request.name();
1238 if (re.test(text))
1239 return true;
1240 }
1241 return false;
1214 } 1242 }
1215 1243
1216 _clearSearchMatchedList() { 1244 _clearSearchMatchedList() {
1217 this._matchedRequestCount = -1; 1245 this._matchedRequestCount = -1;
1218 this._currentMatchedRequestNode = null; 1246 this._currentMatchedNode = null;
1219 this._removeAllHighlights(); 1247 this._removeAllHighlights();
1220 } 1248 }
1221 1249
1222 _removeAllHighlights() { 1250 _removeAllHighlights() {
1223 this.removeAllNodeHighlights(); 1251 this.removeAllNodeHighlights();
1224 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) 1252 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i)
1225 UI.revertDomChanges(this._highlightedSubstringChanges[i]); 1253 UI.revertDomChanges(this._highlightedSubstringChanges[i]);
1226 this._highlightedSubstringChanges = []; 1254 this._highlightedSubstringChanges = [];
1227 } 1255 }
1228 1256
1229 dataGridSorted() { 1257 dataGridSorted() {
1230 this._highlightNthMatchedRequestForSearch( 1258 this._highlightNthMatchedNodeForSearch(this._updateMatchCountAndFindMatchInd ex(this._currentMatchedNode), false);
1231 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false);
1232 } 1259 }
1233 1260
1234 /** 1261 /**
1235 * @param {number} n 1262 * @param {number} n
1236 * @param {boolean} reveal 1263 * @param {boolean} reveal
1237 */ 1264 */
1238 _highlightNthMatchedRequestForSearch(n, reveal) { 1265 _highlightNthMatchedNodeForSearch(n, reveal) {
1239 this._removeAllHighlights(); 1266 this._removeAllHighlights();
1240 1267
1241 /** @type {!Array.<!Network.NetworkDataGridNode>} */
1242 var nodes = this._dataGrid.rootNode().children;
1243 var matchCount = 0; 1268 var matchCount = 0;
1269 var request = null;
1244 var node = null; 1270 var node = null;
1245 for (var i = 0; i < nodes.length; ++i) { 1271 for (node of this.flattenAllNodes()) {
1246 if (nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) { 1272 if (!node[Network.NetworkLogView._isMatchingSearchQuerySymbol])
1247 if (matchCount === n) { 1273 continue;
1248 node = nodes[i]; 1274 if (matchCount === n) {
1249 break; 1275 // TODO(allada) This should support multiple requests.
1250 } 1276 request = node.request();
1251 matchCount++; 1277 break;
1252 } 1278 }
1279 matchCount++;
1253 } 1280 }
1254 if (!node) { 1281 if (!request || !node) {
1255 this._currentMatchedRequestNode = null; 1282 this._currentMatchedNode = null;
1256 return; 1283 return;
1257 } 1284 }
1258 1285
1259 var request = node.request();
1260 if (reveal) 1286 if (reveal)
1261 Common.Revealer.reveal(request); 1287 Common.Revealer.reveal(request);
1262 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex); 1288 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex);
1263 this._highlightedSubstringChanges.push(highlightedSubstringChanges); 1289 this._highlightedSubstringChanges.push(highlightedSubstringChanges);
1264 1290
1265 this._currentMatchedRequestNode = node; 1291 this._currentMatchedNode = node;
1266 this._currentMatchedRequestIndex = n; 1292 this._currentMatchedNodeIndex = n;
1267 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n); 1293 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n);
1268 } 1294 }
1269 1295
1270 /** 1296 /**
1271 * @override 1297 * @override
1272 * @param {!UI.SearchableView.SearchConfig} searchConfig 1298 * @param {!UI.SearchableView.SearchConfig} searchConfig
1273 * @param {boolean} shouldJump 1299 * @param {boolean} shouldJump
1274 * @param {boolean=} jumpBackwards 1300 * @param {boolean=} jumpBackwards
1275 */ 1301 */
1276 performSearch(searchConfig, shouldJump, jumpBackwards) { 1302 performSearch(searchConfig, shouldJump, jumpBackwards) {
1277 var query = searchConfig.query; 1303 var query = searchConfig.query;
1278 var currentMatchedRequestNode = this._currentMatchedRequestNode; 1304 var currentMatchedNode = this._currentMatchedNode;
1279 this._clearSearchMatchedList(); 1305 this._clearSearchMatchedList();
1280 this._searchRegex = createPlainTextSearchRegex(query, 'i'); 1306 this._searchRegex = createPlainTextSearchRegex(query, 'i');
1281 1307
1282 /** @type {!Array.<!Network.NetworkDataGridNode>} */ 1308 for (var node of this.flattenAllNodes())
1283 var nodes = this._dataGrid.rootNode().children; 1309 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._nodeHasM atch(node);
1284 for (var i = 0; i < nodes.length; ++i) 1310
1285 nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matc hRequest(nodes[i].request()); 1311 var newMatchedIndex = this._updateMatchCountAndFindMatchIndex(currentMatched Node);
1286 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current MatchedRequestNode); 1312 if (!newMatchedIndex && jumpBackwards)
1287 if (!newMatchedRequestIndex && jumpBackwards) 1313 newMatchedIndex = this._matchedRequestCount - 1;
1288 newMatchedRequestIndex = this._matchedRequestCount - 1; 1314 this._highlightNthMatchedNodeForSearch(newMatchedIndex, shouldJump);
1289 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump );
1290 } 1315 }
1291 1316
1292 /** 1317 /**
1293 * @override 1318 * @override
1294 * @return {boolean} 1319 * @return {boolean}
1295 */ 1320 */
1296 supportsCaseSensitiveSearch() { 1321 supportsCaseSensitiveSearch() {
1297 return false; 1322 return false;
1298 } 1323 }
1299 1324
1300 /** 1325 /**
1301 * @override 1326 * @override
1302 * @return {boolean} 1327 * @return {boolean}
1303 */ 1328 */
1304 supportsRegexSearch() { 1329 supportsRegexSearch() {
1305 return true; 1330 return true;
1306 } 1331 }
1307 1332
1308 /** 1333 /**
1309 * @param {?Network.NetworkDataGridNode} node 1334 * @param {?Network.NetworkDataGridNode} node
1310 * @return {number} 1335 * @return {number}
1311 */ 1336 */
1312 _updateMatchCountAndFindMatchIndex(node) { 1337 _updateMatchCountAndFindMatchIndex(node) {
1313 /** @type {!Array.<!Network.NetworkDataGridNode>} */ 1338 /** @type {!Array.<!Network.NetworkDataGridNode>} */
1314 var nodes = this._dataGrid.rootNode().children; 1339 var nodes = this.flattenAllNodes();
1315 var matchCount = 0; 1340 var matchCount = 0;
1316 var matchIndex = 0; 1341 var matchIndex = 0;
1317 for (var i = 0; i < nodes.length; ++i) { 1342 for (var i = 0; i < nodes.length; ++i) {
1318 if (!nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) 1343 if (!nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol])
1319 continue; 1344 continue;
1320 if (node === nodes[i]) 1345 if (node === nodes[i])
1321 matchIndex = matchCount; 1346 matchIndex = matchCount;
1322 matchCount++; 1347 matchCount++;
1323 } 1348 }
1324 if (this._matchedRequestCount !== matchCount) { 1349 if (this._matchedRequestCount !== matchCount) {
1325 this._matchedRequestCount = matchCount; 1350 this._matchedRequestCount = matchCount;
1326 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd ated, matchCount); 1351 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd ated, matchCount);
1327 } 1352 }
1328 return matchIndex; 1353 return matchIndex;
1329 } 1354 }
1330 1355
1331 /** 1356 /**
1332 * @param {number} index 1357 * @param {number} index
1333 * @return {number} 1358 * @return {number}
1334 */ 1359 */
1335 _normalizeSearchResultIndex(index) { 1360 _normalizeSearchResultIndex(index) {
1336 return (index + this._matchedRequestCount) % this._matchedRequestCount; 1361 return (index + this._matchedRequestCount) % this._matchedRequestCount;
1337 } 1362 }
1338 1363
1339 /** 1364 /**
1340 * @param {!Network.NetworkDataGridNode} node 1365 * @param {!Network.NetworkDataGridNode} node
1341 * @return {boolean} 1366 * @return {boolean}
1342 */ 1367 */
1343 _applyFilter(node) { 1368 _applyFilter(node) {
1344 var request = node.request(); 1369 for (var request of node.requests()) {
1345 if (this._timeFilter && !this._timeFilter(request)) 1370 if (this._timeFilter && !this._timeFilter(request))
1346 return false; 1371 continue;
1347 var categoryName = request.resourceType().category().title; 1372 var categoryName = request.resourceType().category().title;
1348 if (!this._resourceCategoryFilterUI.accept(categoryName)) 1373 if (!this._resourceCategoryFilterUI.accept(categoryName))
1349 return false; 1374 continue;
1350 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL()) 1375 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL())
1351 return false; 1376 continue;
1352 if (request.statusText === 'Service Worker Fallback Required') 1377 if (request.statusText === 'Service Worker Fallback Required')
1353 return false; 1378 continue;
1354 for (var i = 0; i < this._filters.length; ++i) { 1379 if (this._filters.some(filter => !filter(request)))
1355 if (!this._filters[i](request)) 1380 continue;
1356 return false; 1381 return true;
1357 } 1382 }
1358 return true; 1383 return false;
1359 } 1384 }
1360 1385
1361 /** 1386 /**
1362 * @param {string} query 1387 * @param {string} query
1363 */ 1388 */
1364 _parseFilterQuery(query) { 1389 _parseFilterQuery(query) {
1365 var parsedQuery; 1390 var parsedQuery;
1366 if (this._textFilterUI.isRegexChecked() && query !== '') 1391 if (this._textFilterUI.isRegexChecked() && query !== '')
1367 parsedQuery = {text: [query], filters: []}; 1392 parsedQuery = {text: [query], filters: []};
1368 else 1393 else
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 this._removeAllHighlights(); 1514 this._removeAllHighlights();
1490 this._invalidateAllItems(); 1515 this._invalidateAllItems();
1491 } 1516 }
1492 1517
1493 /** 1518 /**
1494 * @override 1519 * @override
1495 */ 1520 */
1496 jumpToPreviousSearchResult() { 1521 jumpToPreviousSearchResult() {
1497 if (!this._matchedRequestCount) 1522 if (!this._matchedRequestCount)
1498 return; 1523 return;
1499 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde x - 1); 1524 var index = this._normalizeSearchResultIndex(this._currentMatchedNodeIndex - 1);
1500 this._highlightNthMatchedRequestForSearch(index, true); 1525 this._highlightNthMatchedNodeForSearch(index, true);
1501 } 1526 }
1502 1527
1503 /** 1528 /**
1504 * @override 1529 * @override
1505 */ 1530 */
1506 jumpToNextSearchResult() { 1531 jumpToNextSearchResult() {
1507 if (!this._matchedRequestCount) 1532 if (!this._matchedRequestCount)
1508 return; 1533 return;
1509 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde x + 1); 1534 var index = this._normalizeSearchResultIndex(this._currentMatchedNodeIndex + 1);
1510 this._highlightNthMatchedRequestForSearch(index, true); 1535 this._highlightNthMatchedNodeForSearch(index, true);
1511 } 1536 }
1512 1537
1513 /** 1538 /**
1514 * @override 1539 * @override
1515 */ 1540 */
1516 searchCanceled() { 1541 searchCanceled() {
1517 delete this._searchRegex; 1542 delete this._searchRegex;
1518 this._clearSearchMatchedList(); 1543 this._clearSearchMatchedList();
1519 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat ed, 0); 1544 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat ed, 0);
1520 } 1545 }
(...skipping 20 matching lines...) Expand all
1541 1566
1542 /** 1567 /**
1543 * @param {!Network.NetworkDataGridNode} node 1568 * @param {!Network.NetworkDataGridNode} node
1544 */ 1569 */
1545 _highlightNode(node) { 1570 _highlightNode(node) {
1546 UI.runCSSAnimationOnce(node.element(), 'highlighted-row'); 1571 UI.runCSSAnimationOnce(node.element(), 'highlighted-row');
1547 this._highlightedNode = node; 1572 this._highlightedNode = node;
1548 } 1573 }
1549 1574
1550 /** 1575 /**
1576 * @param {string} platform
1551 * @param {!SDK.NetworkRequest} request 1577 * @param {!SDK.NetworkRequest} request
1552 * @param {string} platform
1553 * @return {string} 1578 * @return {string}
1554 */ 1579 */
1555 _generateCurlCommand(request, platform) { 1580 _generateCurlCommand(platform, request) {
1556 var command = ['curl']; 1581 var command = ['curl'];
1557 // These headers are derived from URL (except "version") and would be added by cURL anyway. 1582 // These headers are derived from URL (except "version") and would be added by cURL anyway.
1558 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi on': 1}; 1583 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi on': 1};
1559 1584
1560 function escapeStringWin(str) { 1585 function escapeStringWin(str) {
1561 /* If there are no new line characters do not escape the " characters 1586 /* If there are no new line characters do not escape the " characters
1562 since it only uglifies the command. 1587 since it only uglifies the command.
1563 1588
1564 Because cmd.exe parser and MS Crt arguments parsers use some of t he 1589 Because cmd.exe parser and MS Crt arguments parsers use some of t he
1565 same escape characters, they can interact with each other in 1590 same escape characters, they can interact with each other in
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 Running: 'running', 1741 Running: 'running',
1717 FromCache: 'from-cache' 1742 FromCache: 'from-cache'
1718 }; 1743 };
1719 1744
1720 /** @type {!Array<string>} */ 1745 /** @type {!Array<string>} */
1721 Network.NetworkLogView._searchKeys = 1746 Network.NetworkLogView._searchKeys =
1722 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]); 1747 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]);
1723 1748
1724 /** @typedef {function(!SDK.NetworkRequest): boolean} */ 1749 /** @typedef {function(!SDK.NetworkRequest): boolean} */
1725 Network.NetworkLogView.Filter; 1750 Network.NetworkLogView.Filter;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698