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

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: Merge branch 'master' into NETWORK_GROUP_SUPPORT_1 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 * @return {!Array.<!Element>} 498 * @return {!Array.<!Element>}
499 */ 499 */
500 elementsToRestoreScrollPositionsFor() { 500 elementsToRestoreScrollPositionsFor() {
501 if (!this._dataGrid) // Not initialized yet. 501 if (!this._dataGrid) // Not initialized yet.
502 return []; 502 return [];
503 return [this._dataGrid.scrollContainer]; 503 return [this._dataGrid.scrollContainer];
504 } 504 }
505 505
506 _setupDataGrid() { 506 _setupDataGrid() {
507 this._dataGrid = this._columns.dataGrid(); 507 this._dataGrid = this._columns.dataGrid();
508 var contextMenuHandler = this.handleContextMenuForLogEntry.bind(this);
508 this._dataGrid.setRowContextMenuCallback( 509 this._dataGrid.setRowContextMenuCallback(
509 (contextMenu, node) => this.handleContextMenuForRequest(contextMenu, nod e.request())); 510 (contextMenu, node) => contextMenuHandler(contextMenu, /** @type {!Netwo rk.NetworkDataGridNode} */ (node)));
510 this._dataGrid.setStickToBottom(true); 511 this._dataGrid.setStickToBottom(true);
511 this._dataGrid.setName('networkLog'); 512 this._dataGrid.setName('networkLog');
512 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last); 513 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last);
513 this._dataGrid.element.classList.add('network-log-grid'); 514 this._dataGrid.element.classList.add('network-log-grid');
514 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true); 515 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true);
515 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true); 516 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true);
516 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true); 517 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true);
517 } 518 }
518 519
519 /** 520 /**
520 * @param {!Event} event 521 * @param {!Event} event
521 */ 522 */
522 _dataGridMouseMove(event) { 523 _dataGridMouseMove(event) {
523 var node = this._dataGrid.dataGridNodeFromNode(event.target); 524 var node = this._dataGrid.dataGridNodeFromNode(event.target);
524 var highlightInitiatorChain = event.shiftKey; 525 var highlightInitiatorChain = event.shiftKey;
525 this._setHoveredNode(node, highlightInitiatorChain); 526 this._setHoveredNode(node, highlightInitiatorChain);
526 this._highlightInitiatorChain((highlightInitiatorChain && node) ? node.reque st() : null); 527 // TODO(allada) Support groupping initiator chain instead of first request.
528 var firstRequest = node ? node.firstRequest() : null;
529 this._highlightInitiatorChain(highlightInitiatorChain ? firstRequest : null) ;
527 } 530 }
528 531
529 _dataGridMouseLeave() { 532 _dataGridMouseLeave() {
530 this._setHoveredNode(null); 533 this._setHoveredNode(null);
531 this._highlightInitiatorChain(null); 534 this._highlightInitiatorChain(null);
532 } 535 }
533 536
534 /** 537 /**
535 * @param {?Network.NetworkLogEntry} logEntry 538 * @param {?Network.NetworkLogEntry} logEntry
536 * @param {boolean} highlightInitiatorChain 539 * @param {boolean} highlightInitiatorChain
537 */ 540 */
538 setHoveredLogEntry(logEntry, highlightInitiatorChain) { 541 setHoveredLogEntry(logEntry, highlightInitiatorChain) {
539 // TODO(allada) Move this into LogEntry/NetworkDataGridNode. 542 // TODO(allada) Move this into LogEntry/NetworkDataGridNode.
540 this._setHoveredNode(/** @type {?Network.NetworkDataGridNode} */ (logEntry), highlightInitiatorChain); 543 this._setHoveredNode(/** @type {?Network.NetworkDataGridNode} */ (logEntry), highlightInitiatorChain);
541 this._highlightInitiatorChain((logEntry && highlightInitiatorChain) ? logEnt ry.request() : null); 544 // TODO(allada) Support groupping initiator chain instead of first request.
545 this._highlightInitiatorChain((logEntry && highlightInitiatorChain) ? logEnt ry.firstRequest() : null);
542 } 546 }
543 547
544 /** 548 /**
545 * @param {?Network.NetworkDataGridNode} node 549 * @param {?Network.NetworkDataGridNode} node
546 * @param {boolean=} highlightInitiatorChain 550 * @param {boolean=} highlightInitiatorChain
547 */ 551 */
548 _setHoveredNode(node, highlightInitiatorChain) { 552 _setHoveredNode(node, highlightInitiatorChain) {
549 if (this._hoveredNode) 553 if (this._hoveredNode)
550 this._hoveredNode.element().classList.remove('hover'); 554 this._hoveredNode.element().classList.remove('hover');
551 this._hoveredNode = node; 555 this._hoveredNode = node;
(...skipping 24 matching lines...) Expand all
576 continue; 580 continue;
577 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path'); 581 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path');
578 } 582 }
579 return; 583 return;
580 } 584 }
581 585
582 var initiatorGraph = request.initiatorGraph(); 586 var initiatorGraph = request.initiatorGraph();
583 for (var node of this._nodesByRequestId.values()) { 587 for (var node of this._nodesByRequestId.values()) {
584 if (!node.dataGrid) 588 if (!node.dataGrid)
585 continue; 589 continue;
586 node.element().classList.toggle( 590 var hasInitiator = false;
587 'network-node-on-initiator-path', 591 var hasInitiated = false;
588 node.request() !== request && initiatorGraph.initiators.has(node.reque st())); 592 for (var childRequest of node.requests()) {
589 node.element().classList.toggle( 593 if (childRequest === request)
590 'network-node-on-initiated-path', node.request() !== request && initia torGraph.initiated.has(node.request())); 594 continue;
595 hasInitiator = initiatorGraph.initiators.has(childRequest);
596 hasInitiated = initiatorGraph.initiated.has(childRequest);
597 if (hasInitiator || hasInitiated)
598 break;
599 }
600
601 node.element().classList.toggle('network-node-on-initiator-path', hasIniti ator);
602 node.element().classList.toggle('network-node-on-initiated-path', hasIniti ated);
591 } 603 }
592 } 604 }
593 605
594 _updateSummaryBar() { 606 _updateSummaryBar() {
595 var requestsNumber = this._nodesByRequestId.size; 607 var requestsNumber = this._nodesByRequestId.size;
596 608
597 if (!requestsNumber) { 609 if (!requestsNumber) {
598 this._showRecordingHint(); 610 this._showRecordingHint();
599 return; 611 return;
600 } 612 }
601 this._hideRecordingHint(); 613 this._hideRecordingHint();
602 614
603 var transferSize = 0; 615 var transferSize = 0;
604 var selectedRequestsNumber = 0; 616 var selectedRequestsNumber = 0;
605 var selectedTransferSize = 0; 617 var selectedTransferSize = 0;
606 var baseTime = -1; 618 var baseTime = -1;
607 var maxTime = -1; 619 var maxTime = -1;
608 var nodes = this._nodesByRequestId.valuesArray(); 620 for (var node of this._nodesByRequestId.values()) {
609 for (var i = 0; i < nodes.length; ++i) { 621 var isFilteredOut = node[Network.NetworkLogView._isFilteredOutSymbol];
610 var request = nodes[i].request(); 622 for (var request of node.requests()) {
611 var requestTransferSize = request.transferSize; 623 var requestTransferSize = request.transferSize;
612 transferSize += requestTransferSize; 624 transferSize += requestTransferSize;
613 if (!nodes[i][Network.NetworkLogView._isFilteredOutSymbol]) { 625 if (!isFilteredOut) {
614 selectedRequestsNumber++; 626 selectedRequestsNumber++;
615 selectedTransferSize += requestTransferSize; 627 selectedTransferSize += requestTransferSize;
628 }
629 if (request.url === request.target().inspectedURL() && request.resourceT ype() === Common.resourceTypes.Document)
630 baseTime = request.startTime;
631 if (request.endTime > maxTime)
632 maxTime = request.endTime;
616 } 633 }
617 if (request.url === request.target().inspectedURL() && request.resourceTyp e() === Common.resourceTypes.Document)
618 baseTime = request.startTime;
619 if (request.endTime > maxTime)
620 maxTime = request.endTime;
621 } 634 }
622 635
623 var summaryBar = this._summaryBarElement; 636 var summaryBar = this._summaryBarElement;
624 summaryBar.removeChildren(); 637 summaryBar.removeChildren();
625 var separator = '\u2002\u2758\u2002'; 638 var separator = '\u2002\u2758\u2002';
626 var text = ''; 639 var text = '';
627 /** 640 /**
628 * @param {string} chunk 641 * @param {string} chunk
629 * @return {!Element} 642 * @return {!Element}
630 */ 643 */
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 this.removeAllNodeHighlights(); 811 this.removeAllNodeHighlights();
799 812
800 var oldBoundary = this.calculator().boundary(); 813 var oldBoundary = this.calculator().boundary();
801 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime) ; 814 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime) ;
802 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime); 815 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime);
803 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMConten tLoadedTime); 816 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMConten tLoadedTime);
804 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime); 817 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime);
805 818
806 var dataGrid = this._dataGrid; 819 var dataGrid = this._dataGrid;
807 var rootNode = dataGrid.rootNode(); 820 var rootNode = dataGrid.rootNode();
821
808 /** @type {!Array<!Network.NetworkDataGridNode> } */ 822 /** @type {!Array<!Network.NetworkDataGridNode> } */
809 var nodesToInsert = []; 823 var nodesToInsert = [];
810 /** @type {!Array<!Network.NetworkDataGridNode> } */ 824 /** @type {!Array<!Network.NetworkDataGridNode> } */
811 var nodesToRefresh = []; 825 var nodesToRefresh = [];
812 for (var requestId in this._staleRequestIds) { 826 for (var requestId in this._staleRequestIds) {
813 var node = this._nodesByRequestId.get(requestId); 827 var node = this._nodesByRequestId.get(requestId);
814 if (!node) 828 if (!node)
815 continue; 829 continue;
816 var isFilteredOut = !this._applyFilter(node); 830 var isFilteredOut = !this._applyFilter(node);
817 if (isFilteredOut && node === this._hoveredNode) 831 if (isFilteredOut && node === this._hoveredNode)
818 this._setHoveredNode(null); 832 this._setHoveredNode(null);
819 if (node[Network.NetworkLogView._isFilteredOutSymbol] !== isFilteredOut) { 833 if (node[Network.NetworkLogView._isFilteredOutSymbol] !== isFilteredOut) {
820 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 834 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
821 rootNode.removeChild(node); 835 rootNode.removeChild(node);
822 836
823 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut; 837 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut;
824 838
825 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 839 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
826 nodesToInsert.push(node); 840 nodesToInsert.push(node);
827 } 841 }
828 if (!isFilteredOut) 842 if (!isFilteredOut)
829 nodesToRefresh.push(node); 843 nodesToRefresh.push(node);
830 var request = node.request(); 844 for (var request of node.requests()) {
831 this._timeCalculator.updateBoundaries(request); 845 this._timeCalculator.updateBoundaries(request);
832 this._durationCalculator.updateBoundaries(request); 846 this._durationCalculator.updateBoundaries(request);
847 }
833 } 848 }
834 849
835 for (var i = 0; i < nodesToInsert.length; ++i) { 850 for (var node of nodesToInsert) {
836 var node = nodesToInsert[i]; 851 for (var request of node.requests()) {
837 var request = node.request(); 852 dataGrid.insertChild(node);
dgozman 2016/11/23 01:57:30 This should go outside of the for loop.
allada 2016/11/23 22:39:14 Done.
838 dataGrid.insertChild(node); 853 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchR equest(request);
839 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchReq uest(request); 854 }
840 } 855 }
841 856
842 for (var node of nodesToRefresh) 857 for (var node of nodesToRefresh)
843 node.refresh(); 858 node.refresh();
844 859
845 this._highlightNthMatchedRequestForSearch( 860 this._highlightNthMatchedRequestForSearch(
846 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false); 861 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false);
847 862
848 this._staleRequestIds = {}; 863 this._staleRequestIds = {};
849 this._updateSummaryBar(); 864 this._updateSummaryBar();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 * @param {!SDK.NetworkRequest} request 921 * @param {!SDK.NetworkRequest} request
907 */ 922 */
908 _appendRequest(request) { 923 _appendRequest(request) {
909 var node = new Network.NetworkDataGridNode(this, request); 924 var node = new Network.NetworkDataGridNode(this, request);
910 node[Network.NetworkLogView._isFilteredOutSymbol] = true; 925 node[Network.NetworkLogView._isFilteredOutSymbol] = true;
911 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false; 926 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false;
912 927
913 // In case of redirect request id is reassigned to a redirected 928 // In case of redirect request id is reassigned to a redirected
914 // request and we need to update _nodesByRequestId and search results. 929 // request and we need to update _nodesByRequestId and search results.
915 var originalRequestNode = this._nodesByRequestId.get(request.requestId); 930 var originalRequestNode = this._nodesByRequestId.get(request.requestId);
916 if (originalRequestNode) 931 if (originalRequestNode) {
917 this._nodesByRequestId.set(originalRequestNode.request().requestId, origin alRequestNode); 932 for (var originalRequest of originalRequestNode.requests())
933 this._nodesByRequestId.set(originalRequest.requestId, originalRequestNod e);
dgozman 2016/11/23 01:57:30 I believe this is incorrect now - only a single re
allada 2016/11/23 22:39:14 Done.
934 }
935
918 this._nodesByRequestId.set(request.requestId, node); 936 this._nodesByRequestId.set(request.requestId, node);
919 937
920 // Pull all the redirects of the main request upon commit load. 938 // Pull all the redirects of the main request upon commit load.
921 if (request.redirects) { 939 if (request.redirects)
922 for (var i = 0; i < request.redirects.length; ++i) 940 request.redirects.forEach(this._refreshRequest.bind(this));
923 this._refreshRequest(request.redirects[i]);
924 }
925 941
926 this._refreshRequest(request); 942 this._refreshRequest(request);
927 } 943 }
928 944
929 /** 945 /**
930 * @param {!Common.Event} event 946 * @param {!Common.Event} event
931 */ 947 */
932 _onRequestUpdated(event) { 948 _onRequestUpdated(event) {
933 var request = /** @type {!SDK.NetworkRequest} */ (event.data); 949 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
934 this._refreshRequest(request); 950 this._refreshRequest(request);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1041
1026 /** 1042 /**
1027 * @param {boolean} gridMode 1043 * @param {boolean} gridMode
1028 */ 1044 */
1029 switchViewMode(gridMode) { 1045 switchViewMode(gridMode) {
1030 this._columns.switchViewMode(gridMode); 1046 this._columns.switchViewMode(gridMode);
1031 } 1047 }
1032 1048
1033 /** 1049 /**
1034 * @param {!UI.ContextMenu} contextMenu 1050 * @param {!UI.ContextMenu} contextMenu
1035 * @param {!SDK.NetworkRequest} request 1051 * @param {!Network.NetworkLogEntry} logEntry
1036 */ 1052 */
1037 handleContextMenuForRequest(contextMenu, request) { 1053 handleContextMenuForLogEntry(contextMenu, logEntry) {
1054 // TODO(allada) Support groupped items context menu.
1055 var request = logEntry.firstRequest();
1056 if (logEntry.isGroup() || !request)
1057 return;
1038 contextMenu.appendApplicableItems(request); 1058 contextMenu.appendApplicableItems(request);
1039 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy')); 1059 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy'));
1040 if (request) { 1060 if (request) {
1041 copyMenu.appendItem( 1061 copyMenu.appendItem(
1042 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL())); 1062 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL()));
1043 copyMenu.appendSeparator(); 1063 copyMenu.appendSeparator();
1044 1064
1045 if (request.requestHeadersText()) { 1065 if (request.requestHeadersText()) {
1046 copyMenu.appendItem( 1066 copyMenu.appendItem(
1047 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request)); 1067 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1117 }
1098 1118
1099 if (request && request.resourceType() === Common.resourceTypes.XHR) { 1119 if (request && request.resourceType() === Common.resourceTypes.XHR) {
1100 contextMenu.appendSeparator(); 1120 contextMenu.appendSeparator();
1101 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request)); 1121 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request));
1102 contextMenu.appendSeparator(); 1122 contextMenu.appendSeparator();
1103 } 1123 }
1104 } 1124 }
1105 1125
1106 _harRequests() { 1126 _harRequests() {
1107 var requests = this._nodesByRequestId.valuesArray().map(function(node) { 1127 var requests = [];
1108 return node.request(); 1128 for (var node of this._nodesByRequestId.values())
1109 }); 1129 requests = requests.concat(node.requests());
1110 var httpRequests = requests.filter(Network.NetworkLogView.HTTPRequestsFilter ); 1130 var httpRequests = requests.filter(Network.NetworkLogView.HTTPRequestsFilter );
1111 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter); 1131 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter);
1112 } 1132 }
1113 1133
1114 _copyAll() { 1134 _copyAll() {
1115 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()}; 1135 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()};
1116 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2)); 1136 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2));
1117 } 1137 }
1118 1138
1119 /** 1139 /**
(...skipping 30 matching lines...) Expand all
1150 * @param {string} platform 1170 * @param {string} platform
1151 */ 1171 */
1152 _copyCurlCommand(request, platform) { 1172 _copyCurlCommand(request, platform) {
1153 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platform)) ; 1173 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platform)) ;
1154 } 1174 }
1155 1175
1156 /** 1176 /**
1157 * @param {string} platform 1177 * @param {string} platform
1158 */ 1178 */
1159 _copyAllCurlCommand(platform) { 1179 _copyAllCurlCommand(platform) {
1160 var requests = this._nodesByRequestId.valuesArray().map(node => node.request ()); 1180 var requests = [];
1181 for (var node of this._nodesByRequestId.values())
dgozman 2016/11/23 01:57:30 Let's have a helper method which does this.
allada 2016/11/23 22:39:14 Done.
1182 requests = requests.concat(node.requests());
1161 var commands = []; 1183 var commands = [];
1162 for (var request of requests) 1184 for (var request of requests)
1163 commands.push(this._generateCurlCommand(request, platform)); 1185 commands.push(this._generateCurlCommand(request, platform));
1164 if (platform === 'win') 1186 if (platform === 'win')
1165 InspectorFrontendHost.copyText(commands.join(' &\r\n')); 1187 InspectorFrontendHost.copyText(commands.join(' &\r\n'));
1166 else 1188 else
1167 InspectorFrontendHost.copyText(commands.join(' ;\n')); 1189 InspectorFrontendHost.copyText(commands.join(' ;\n'));
1168 } 1190 }
1169 1191
1170 _exportAll() { 1192 _exportAll() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false); 1251 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false);
1230 } 1252 }
1231 1253
1232 /** 1254 /**
1233 * @param {number} n 1255 * @param {number} n
1234 * @param {boolean} reveal 1256 * @param {boolean} reveal
1235 */ 1257 */
1236 _highlightNthMatchedRequestForSearch(n, reveal) { 1258 _highlightNthMatchedRequestForSearch(n, reveal) {
1237 this._removeAllHighlights(); 1259 this._removeAllHighlights();
1238 1260
1239 /** @type {!Array.<!Network.NetworkDataGridNode>} */
1240 var nodes = this._dataGrid.rootNode().children;
1241 var matchCount = 0; 1261 var matchCount = 0;
1242 var node = null; 1262 var node = null;
1243 for (var i = 0; i < nodes.length; ++i) { 1263 var request = null;
1244 if (nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) { 1264 for (node of this.flatNodesList()) {
dgozman 2016/11/23 01:57:30 var node
allada 2016/11/23 22:39:14 Done.
1265 if (node[Network.NetworkLogView._isMatchingSearchQuerySymbol]) {
1245 if (matchCount === n) { 1266 if (matchCount === n) {
1246 node = nodes[i]; 1267 // TODO(allada) This should support multiple requests.
1268 request = node.firstRequest();
1247 break; 1269 break;
1248 } 1270 }
1249 matchCount++; 1271 matchCount++;
1250 } 1272 }
1251 } 1273 }
1252 if (!node) { 1274 if (!request) {
1253 this._currentMatchedRequestNode = null; 1275 this._currentMatchedRequestNode = null;
1254 return; 1276 return;
1255 } 1277 }
1256 1278
1257 var request = node.request();
1258 if (reveal) 1279 if (reveal)
1259 Common.Revealer.reveal(request); 1280 Common.Revealer.reveal(request);
1260 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex); 1281 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex);
1261 this._highlightedSubstringChanges.push(highlightedSubstringChanges); 1282 this._highlightedSubstringChanges.push(highlightedSubstringChanges);
1262 1283
1263 this._currentMatchedRequestNode = node; 1284 this._currentMatchedRequestNode = node;
1264 this._currentMatchedRequestIndex = n; 1285 this._currentMatchedRequestIndex = n;
1265 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n); 1286 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n);
1266 } 1287 }
1267 1288
1268 /** 1289 /**
1269 * @override 1290 * @override
1270 * @param {!UI.SearchableView.SearchConfig} searchConfig 1291 * @param {!UI.SearchableView.SearchConfig} searchConfig
1271 * @param {boolean} shouldJump 1292 * @param {boolean} shouldJump
1272 * @param {boolean=} jumpBackwards 1293 * @param {boolean=} jumpBackwards
1273 */ 1294 */
1274 performSearch(searchConfig, shouldJump, jumpBackwards) { 1295 performSearch(searchConfig, shouldJump, jumpBackwards) {
1275 var query = searchConfig.query; 1296 var query = searchConfig.query;
1276 var currentMatchedRequestNode = this._currentMatchedRequestNode; 1297 var currentMatchedRequestNode = this._currentMatchedRequestNode;
1277 this._clearSearchMatchedList(); 1298 this._clearSearchMatchedList();
1278 this._searchRegex = createPlainTextSearchRegex(query, 'i'); 1299 this._searchRegex = createPlainTextSearchRegex(query, 'i');
1279 1300
1280 /** @type {!Array.<!Network.NetworkDataGridNode>} */ 1301 var isMatchingSearchQuerySymbol = Network.NetworkLogView._isMatchingSearchQu erySymbol;
dgozman 2016/11/23 01:57:30 Inline it back :-)
allada 2016/11/23 22:39:14 Done.
1281 var nodes = this._dataGrid.rootNode().children; 1302 for (var node of this.flatNodesList()) {
dgozman 2016/11/23 01:57:30 Is this really an equivalent of what was here befo
allada 2016/11/23 22:39:14 Done.
1282 for (var i = 0; i < nodes.length; ++i) 1303 var firstRequest = node.firstRequest();
1283 nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matc hRequest(nodes[i].request()); 1304 // TODO(allada) This should properly support groupped requests.
dgozman 2016/11/23 01:57:30 definitely!
allada 2016/11/23 22:39:14 Acknowledged.
1305 node[isMatchingSearchQuerySymbol] = firstRequest ? this._matchRequest(firs tRequest) : null;
1306 }
1284 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current MatchedRequestNode); 1307 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current MatchedRequestNode);
1285 if (!newMatchedRequestIndex && jumpBackwards) 1308 if (!newMatchedRequestIndex && jumpBackwards)
1286 newMatchedRequestIndex = this._matchedRequestCount - 1; 1309 newMatchedRequestIndex = this._matchedRequestCount - 1;
1287 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump ); 1310 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump );
1288 } 1311 }
1289 1312
1290 /** 1313 /**
1291 * @override 1314 * @override
1292 * @return {boolean} 1315 * @return {boolean}
1293 */ 1316 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 */ 1355 */
1333 _normalizeSearchResultIndex(index) { 1356 _normalizeSearchResultIndex(index) {
1334 return (index + this._matchedRequestCount) % this._matchedRequestCount; 1357 return (index + this._matchedRequestCount) % this._matchedRequestCount;
1335 } 1358 }
1336 1359
1337 /** 1360 /**
1338 * @param {!Network.NetworkDataGridNode} node 1361 * @param {!Network.NetworkDataGridNode} node
1339 * @return {boolean} 1362 * @return {boolean}
1340 */ 1363 */
1341 _applyFilter(node) { 1364 _applyFilter(node) {
1342 var request = node.request(); 1365 for (var request of node.requests()) {
dgozman 2016/11/23 01:57:30 This is incorrect: if one request matches, we shou
allada 2016/11/23 22:39:14 Done.
1343 if (this._timeFilter && !this._timeFilter(request)) 1366 if (this._timeFilter && !this._timeFilter(request))
1344 return false;
1345 var categoryName = request.resourceType().category().title;
1346 if (!this._resourceCategoryFilterUI.accept(categoryName))
1347 return false;
1348 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL())
1349 return false;
1350 if (request.statusText === 'Service Worker Fallback Required')
1351 return false;
1352 for (var i = 0; i < this._filters.length; ++i) {
1353 if (!this._filters[i](request))
1354 return false; 1367 return false;
1368 var categoryName = request.resourceType().category().title;
1369 if (!this._resourceCategoryFilterUI.accept(categoryName))
1370 return false;
1371 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL())
1372 return false;
1373 if (request.statusText === 'Service Worker Fallback Required')
1374 return false;
1375 for (var i = 0; i < this._filters.length; ++i) {
1376 if (!this._filters[i](request))
1377 return false;
1378 }
1355 } 1379 }
1356 return true; 1380 return true;
1357 } 1381 }
1358 1382
1359 /** 1383 /**
1360 * @param {string} query 1384 * @param {string} query
1361 */ 1385 */
1362 _parseFilterQuery(query) { 1386 _parseFilterQuery(query) {
1363 var parsedQuery; 1387 var parsedQuery;
1364 if (this._textFilterUI.isRegexChecked() && query !== '') 1388 if (this._textFilterUI.isRegexChecked() && query !== '')
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 Running: 'running', 1738 Running: 'running',
1715 FromCache: 'from-cache' 1739 FromCache: 'from-cache'
1716 }; 1740 };
1717 1741
1718 /** @type {!Array<string>} */ 1742 /** @type {!Array<string>} */
1719 Network.NetworkLogView._searchKeys = 1743 Network.NetworkLogView._searchKeys =
1720 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]); 1744 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]);
1721 1745
1722 /** @typedef {function(!SDK.NetworkRequest): boolean} */ 1746 /** @typedef {function(!SDK.NetworkRequest): boolean} */
1723 Network.NetworkLogView.Filter; 1747 Network.NetworkLogView.Filter;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698