| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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.NetworkDataGridNode} node | 542 * @param {?Network.NetworkDataGridNode} node |
| (...skipping 22 matching lines...) Expand all Loading... |
| 560 */ | 565 */ |
| 561 _dataGridMouseDown(event) { | 566 _dataGridMouseDown(event) { |
| 562 if (!this._dataGrid.selectedNode && event.button) | 567 if (!this._dataGrid.selectedNode && event.button) |
| 563 event.consume(); | 568 event.consume(); |
| 564 } | 569 } |
| 565 | 570 |
| 566 /** | 571 /** |
| 567 * @param {?SDK.NetworkRequest} request | 572 * @param {?SDK.NetworkRequest} request |
| 568 */ | 573 */ |
| 569 _highlightInitiatorChain(request) { | 574 _highlightInitiatorChain(request) { |
| 575 // TODO(allada) This should be converted into Node instead of request. |
| 570 if (this._requestWithHighlightedInitiators === request) | 576 if (this._requestWithHighlightedInitiators === request) |
| 571 return; | 577 return; |
| 572 this._requestWithHighlightedInitiators = request; | 578 this._requestWithHighlightedInitiators = request; |
| 573 | 579 |
| 574 if (!request) { | 580 if (!request) { |
| 575 for (var node of this._nodesByRequestId.values()) { | 581 for (var node of this._nodesByRequestId.values()) { |
| 576 if (!node.dataGrid) | 582 if (!node.dataGrid) |
| 577 continue; | 583 continue; |
| 578 node.element().classList.remove('network-node-on-initiator-path', 'netwo
rk-node-on-initiated-path'); | 584 node.element().classList.remove('network-node-on-initiator-path', 'netwo
rk-node-on-initiated-path'); |
| 579 } | 585 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 /** | 783 /** |
| 778 * @override | 784 * @override |
| 779 */ | 785 */ |
| 780 willHide() { | 786 willHide() { |
| 781 this._columns.willHide(); | 787 this._columns.willHide(); |
| 782 } | 788 } |
| 783 | 789 |
| 784 /** | 790 /** |
| 785 * @return {!Array<!Network.NetworkDataGridNode>} | 791 * @return {!Array<!Network.NetworkDataGridNode>} |
| 786 */ | 792 */ |
| 787 flatNodesList() { | 793 flattenVisibleNodes() { |
| 788 return this._dataGrid.rootNode().flattenChildren(); | 794 return /** @type {!Array<!Network.NetworkDataGridNode>} */ (this._dataGrid.r
ootNode().flattenChildren()); |
| 795 } |
| 796 |
| 797 /** |
| 798 * @return {!Array<!Network.NetworkDataGridNode>} |
| 799 */ |
| 800 flattenAllNodes() { |
| 801 return /** @type {!Array<!Network.NetworkDataGridNode>} */ (this._dataGrid.r
ootNode().flattenChildren(true)); |
| 789 } | 802 } |
| 790 | 803 |
| 791 _refresh() { | 804 _refresh() { |
| 792 this._needsRefresh = false; | 805 this._needsRefresh = false; |
| 793 | 806 |
| 794 if (this._refreshRequestId) { | 807 if (this._refreshRequestId) { |
| 795 this.element.window().cancelAnimationFrame(this._refreshRequestId); | 808 this.element.window().cancelAnimationFrame(this._refreshRequestId); |
| 796 delete this._refreshRequestId; | 809 delete this._refreshRequestId; |
| 797 } | 810 } |
| 798 | 811 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 826 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) | 839 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) |
| 827 nodesToInsert.push(node); | 840 nodesToInsert.push(node); |
| 828 } | 841 } |
| 829 if (!isFilteredOut) | 842 if (!isFilteredOut) |
| 830 nodesToRefresh.push(node); | 843 nodesToRefresh.push(node); |
| 831 var request = node.request(); | 844 var request = node.request(); |
| 832 this._timeCalculator.updateBoundaries(request); | 845 this._timeCalculator.updateBoundaries(request); |
| 833 this._durationCalculator.updateBoundaries(request); | 846 this._durationCalculator.updateBoundaries(request); |
| 834 } | 847 } |
| 835 | 848 |
| 836 for (var i = 0; i < nodesToInsert.length; ++i) { | 849 for (var node of nodesToInsert) { |
| 837 var node = nodesToInsert[i]; | |
| 838 var request = node.request(); | |
| 839 dataGrid.insertChild(node); | 850 dataGrid.insertChild(node); |
| 840 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchReq
uest(request); | 851 var matched = this._nodeHasDirectMatch(node); |
| 852 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = matched; |
| 853 var parent = /** @type {?Network.NetworkDataGridNode} */ (node.parent); |
| 854 while (matched && parent && !parent[Network.NetworkLogView._isMatchingSear
chQuerySymbol]) { |
| 855 parent[Network.NetworkLogView._isMatchingSearchQuerySymbol] = true; |
| 856 parent = /** @type {?Network.NetworkDataGridNode} */ (parent.parent); |
| 857 } |
| 841 } | 858 } |
| 842 | 859 |
| 843 for (var node of nodesToRefresh) | 860 for (var node of nodesToRefresh) |
| 844 node.refresh(); | 861 node.refresh(); |
| 845 | 862 |
| 846 this._highlightNthMatchedRequestForSearch( | 863 this._highlightNthMatchedNodeForSearch(this._updateMatchCountAndFindMatchInd
ex(this._currentMatchedNode), false); |
| 847 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode)
, false); | |
| 848 | 864 |
| 849 this._staleRequestIds = {}; | 865 this._staleRequestIds = {}; |
| 850 this._updateSummaryBar(); | 866 this._updateSummaryBar(); |
| 851 | 867 |
| 852 this._columns.dataChanged(); | 868 this._columns.dataChanged(); |
| 853 } | 869 } |
| 854 | 870 |
| 855 reset() { | 871 reset() { |
| 856 this._requestWithHighlightedInitiators = null; | 872 this._requestWithHighlightedInitiators = null; |
| 857 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected,
null); | 873 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected,
null); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 * @param {!SDK.NetworkRequest} request | 923 * @param {!SDK.NetworkRequest} request |
| 908 */ | 924 */ |
| 909 _appendRequest(request) { | 925 _appendRequest(request) { |
| 910 var node = new Network.NetworkDataGridNode(this, request); | 926 var node = new Network.NetworkDataGridNode(this, request); |
| 911 node[Network.NetworkLogView._isFilteredOutSymbol] = true; | 927 node[Network.NetworkLogView._isFilteredOutSymbol] = true; |
| 912 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false; | 928 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false; |
| 913 | 929 |
| 914 // In case of redirect request id is reassigned to a redirected | 930 // In case of redirect request id is reassigned to a redirected |
| 915 // request and we need to update _nodesByRequestId and search results. | 931 // request and we need to update _nodesByRequestId and search results. |
| 916 var originalRequestNode = this._nodesByRequestId.get(request.requestId); | 932 var originalRequestNode = this._nodesByRequestId.get(request.requestId); |
| 917 if (originalRequestNode) | 933 var originalRequest = originalRequestNode ? originalRequestNode.request() :
null; |
| 918 this._nodesByRequestId.set(originalRequestNode.request().requestId, origin
alRequestNode); | 934 if (originalRequest) |
| 935 this._nodesByRequestId.set(originalRequest.requestId, originalRequestNode)
; |
| 936 |
| 919 this._nodesByRequestId.set(request.requestId, node); | 937 this._nodesByRequestId.set(request.requestId, node); |
| 920 | 938 |
| 921 // Pull all the redirects of the main request upon commit load. | 939 // Pull all the redirects of the main request upon commit load. |
| 922 if (request.redirects) { | 940 if (request.redirects) |
| 923 for (var i = 0; i < request.redirects.length; ++i) | 941 request.redirects.forEach(this._refreshRequest.bind(this)); |
| 924 this._refreshRequest(request.redirects[i]); | |
| 925 } | |
| 926 | 942 |
| 927 this._refreshRequest(request); | 943 this._refreshRequest(request); |
| 928 } | 944 } |
| 929 | 945 |
| 930 /** | 946 /** |
| 931 * @param {!Common.Event} event | 947 * @param {!Common.Event} event |
| 932 */ | 948 */ |
| 933 _onRequestUpdated(event) { | 949 _onRequestUpdated(event) { |
| 934 var request = /** @type {!SDK.NetworkRequest} */ (event.data); | 950 var request = /** @type {!SDK.NetworkRequest} */ (event.data); |
| 935 this._refreshRequest(request); | 951 this._refreshRequest(request); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 | 1042 |
| 1027 /** | 1043 /** |
| 1028 * @param {boolean} gridMode | 1044 * @param {boolean} gridMode |
| 1029 */ | 1045 */ |
| 1030 switchViewMode(gridMode) { | 1046 switchViewMode(gridMode) { |
| 1031 this._columns.switchViewMode(gridMode); | 1047 this._columns.switchViewMode(gridMode); |
| 1032 } | 1048 } |
| 1033 | 1049 |
| 1034 /** | 1050 /** |
| 1035 * @param {!UI.ContextMenu} contextMenu | 1051 * @param {!UI.ContextMenu} contextMenu |
| 1036 * @param {!SDK.NetworkRequest} request | 1052 * @param {!Network.NetworkDataGridNode} node |
| 1037 */ | 1053 */ |
| 1038 handleContextMenuForRequest(contextMenu, request) { | 1054 handleContextMenuForNode(contextMenu, node) { |
| 1055 // TODO(allada) Support groupped items context menu. |
| 1056 var request = node.request(); |
| 1057 if (!request) |
| 1058 return; |
| 1039 contextMenu.appendApplicableItems(request); | 1059 contextMenu.appendApplicableItems(request); |
| 1040 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy')); | 1060 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy')); |
| 1041 if (request) { | 1061 if (request) { |
| 1042 copyMenu.appendItem( | 1062 copyMenu.appendItem( |
| 1043 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect
orFrontendHost, request.contentURL())); | 1063 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect
orFrontendHost, request.contentURL())); |
| 1044 copyMenu.appendSeparator(); | 1064 copyMenu.appendSeparator(); |
| 1045 | 1065 |
| 1046 if (request.requestHeadersText()) { | 1066 if (request.requestHeadersText()) { |
| 1047 copyMenu.appendItem( | 1067 copyMenu.appendItem( |
| 1048 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ
estHeaders.bind(this, request)); | 1068 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ
estHeaders.bind(this, request)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } | 1117 } |
| 1098 } | 1118 } |
| 1099 | 1119 |
| 1100 if (request && request.resourceType() === Common.resourceTypes.XHR) { | 1120 if (request && request.resourceType() === Common.resourceTypes.XHR) { |
| 1101 contextMenu.appendSeparator(); | 1121 contextMenu.appendSeparator(); |
| 1102 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi
nd(request)); | 1122 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi
nd(request)); |
| 1103 contextMenu.appendSeparator(); | 1123 contextMenu.appendSeparator(); |
| 1104 } | 1124 } |
| 1105 } | 1125 } |
| 1106 | 1126 |
| 1127 /** |
| 1128 * @return {!Array<!SDK.NetworkRequest>} |
| 1129 */ |
| 1130 _allRequests() { |
| 1131 return this.flattenAllNodes().map(node => node.request()).filter(request =>
!!request); |
| 1132 } |
| 1133 |
| 1107 _harRequests() { | 1134 _harRequests() { |
| 1108 var requests = this._nodesByRequestId.valuesArray().map(function(node) { | 1135 var httpRequests = this._allRequests().filter(Network.NetworkLogView.HTTPReq
uestsFilter); |
| 1109 return node.request(); | |
| 1110 }); | |
| 1111 var httpRequests = requests.filter(Network.NetworkLogView.HTTPRequestsFilter
); | |
| 1112 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter); | 1136 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter); |
| 1113 } | 1137 } |
| 1114 | 1138 |
| 1115 _copyAll() { | 1139 _copyAll() { |
| 1116 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()}; | 1140 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()}; |
| 1117 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2)); | 1141 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2)); |
| 1118 } | 1142 } |
| 1119 | 1143 |
| 1120 /** | 1144 /** |
| 1121 * @param {!SDK.NetworkRequest} request | 1145 * @param {!SDK.NetworkRequest} request |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1144 */ | 1168 */ |
| 1145 _copyResponseHeaders(request) { | 1169 _copyResponseHeaders(request) { |
| 1146 InspectorFrontendHost.copyText(request.responseHeadersText); | 1170 InspectorFrontendHost.copyText(request.responseHeadersText); |
| 1147 } | 1171 } |
| 1148 | 1172 |
| 1149 /** | 1173 /** |
| 1150 * @param {!SDK.NetworkRequest} request | 1174 * @param {!SDK.NetworkRequest} request |
| 1151 * @param {string} platform | 1175 * @param {string} platform |
| 1152 */ | 1176 */ |
| 1153 _copyCurlCommand(request, platform) { | 1177 _copyCurlCommand(request, platform) { |
| 1154 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platform))
; | 1178 InspectorFrontendHost.copyText(this._generateCurlCommand(platform, request))
; |
| 1155 } | 1179 } |
| 1156 | 1180 |
| 1157 /** | 1181 /** |
| 1158 * @param {string} platform | 1182 * @param {string} platform |
| 1159 */ | 1183 */ |
| 1160 _copyAllCurlCommand(platform) { | 1184 _copyAllCurlCommand(platform) { |
| 1161 var requests = this._nodesByRequestId.valuesArray().map(node => node.request
()); | 1185 var commands = this._allRequests().map(this._generateCurlCommand.bind(this,
platform)); |
| 1162 var commands = []; | |
| 1163 for (var request of requests) | |
| 1164 commands.push(this._generateCurlCommand(request, platform)); | |
| 1165 if (platform === 'win') | 1186 if (platform === 'win') |
| 1166 InspectorFrontendHost.copyText(commands.join(' &\r\n')); | 1187 InspectorFrontendHost.copyText(commands.join(' &\r\n')); |
| 1167 else | 1188 else |
| 1168 InspectorFrontendHost.copyText(commands.join(' ;\n')); | 1189 InspectorFrontendHost.copyText(commands.join(' ;\n')); |
| 1169 } | 1190 } |
| 1170 | 1191 |
| 1171 _exportAll() { | 1192 _exportAll() { |
| 1172 var url = SDK.targetManager.mainTarget().inspectedURL(); | 1193 var url = SDK.targetManager.mainTarget().inspectedURL(); |
| 1173 var parsedURL = url.asParsedURL(); | 1194 var parsedURL = url.asParsedURL(); |
| 1174 var filename = parsedURL ? parsedURL.host : 'network-log'; | 1195 var filename = parsedURL ? parsedURL.host : 'network-log'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1193 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?')
)) |
| 1194 SDK.multitargetNetworkManager.clearBrowserCache(); | 1215 SDK.multitargetNetworkManager.clearBrowserCache(); |
| 1195 } | 1216 } |
| 1196 | 1217 |
| 1197 _clearBrowserCookies() { | 1218 _clearBrowserCookies() { |
| 1198 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?
'))) |
| 1199 SDK.multitargetNetworkManager.clearBrowserCookies(); | 1220 SDK.multitargetNetworkManager.clearBrowserCookies(); |
| 1200 } | 1221 } |
| 1201 | 1222 |
| 1202 /** | 1223 /** |
| 1203 * @param {!SDK.NetworkRequest} request | 1224 * @param {!Network.NetworkDataGridNode} node |
| 1204 * @return {boolean} | 1225 * @return {boolean} |
| 1205 */ | 1226 */ |
| 1206 _matchRequest(request) { | 1227 _nodeHasDirectMatch(node) { |
| 1207 var re = this._searchRegex; | 1228 var re = this._searchRegex; |
| 1208 if (!re) | 1229 if (!re) |
| 1209 return false; | 1230 return false; |
| 1210 | 1231 |
| 1232 var request = node.request(); |
| 1211 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + r
equest.name() : request.name(); | 1233 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + r
equest.name() : request.name(); |
| 1212 return re.test(text); | 1234 if (re.test(text)) |
| 1235 return true; |
| 1236 return false; |
| 1213 } | 1237 } |
| 1214 | 1238 |
| 1215 _clearSearchMatchedList() { | 1239 _clearSearchMatchedList() { |
| 1216 this._matchedRequestCount = -1; | 1240 this._matchedRequestCount = -1; |
| 1217 this._currentMatchedRequestNode = null; | 1241 this._currentMatchedNode = null; |
| 1218 this._removeAllHighlights(); | 1242 this._removeAllHighlights(); |
| 1219 } | 1243 } |
| 1220 | 1244 |
| 1221 _removeAllHighlights() { | 1245 _removeAllHighlights() { |
| 1222 this.removeAllNodeHighlights(); | 1246 this.removeAllNodeHighlights(); |
| 1223 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) | 1247 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) |
| 1224 UI.revertDomChanges(this._highlightedSubstringChanges[i]); | 1248 UI.revertDomChanges(this._highlightedSubstringChanges[i]); |
| 1225 this._highlightedSubstringChanges = []; | 1249 this._highlightedSubstringChanges = []; |
| 1226 } | 1250 } |
| 1227 | 1251 |
| 1228 dataGridSorted() { | 1252 dataGridSorted() { |
| 1229 this._highlightNthMatchedRequestForSearch( | 1253 this._highlightNthMatchedNodeForSearch(this._updateMatchCountAndFindMatchInd
ex(this._currentMatchedNode), false); |
| 1230 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode)
, false); | |
| 1231 } | 1254 } |
| 1232 | 1255 |
| 1233 /** | 1256 /** |
| 1234 * @param {number} n | 1257 * @param {number} n |
| 1235 * @param {boolean} reveal | 1258 * @param {boolean} reveal |
| 1236 */ | 1259 */ |
| 1237 _highlightNthMatchedRequestForSearch(n, reveal) { | 1260 _highlightNthMatchedNodeForSearch(n, reveal) { |
| 1238 this._removeAllHighlights(); | 1261 this._removeAllHighlights(); |
| 1239 | 1262 |
| 1240 /** @type {!Array.<!Network.NetworkDataGridNode>} */ | |
| 1241 var nodes = this._dataGrid.rootNode().children; | |
| 1242 var matchCount = 0; | 1263 var matchCount = 0; |
| 1264 var request = null; |
| 1243 var node = null; | 1265 var node = null; |
| 1244 for (var i = 0; i < nodes.length; ++i) { | 1266 for (node of this.flattenAllNodes()) { |
| 1245 if (nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) { | 1267 if (!node[Network.NetworkLogView._isMatchingSearchQuerySymbol]) |
| 1246 if (matchCount === n) { | 1268 continue; |
| 1247 node = nodes[i]; | 1269 if (matchCount === n) { |
| 1248 break; | 1270 // TODO(allada) This should support multiple requests. |
| 1249 } | 1271 request = node.request(); |
| 1250 matchCount++; | 1272 break; |
| 1251 } | 1273 } |
| 1274 matchCount++; |
| 1252 } | 1275 } |
| 1253 if (!node) { | 1276 if (!request || !node) { |
| 1254 this._currentMatchedRequestNode = null; | 1277 this._currentMatchedNode = null; |
| 1255 return; | 1278 return; |
| 1256 } | 1279 } |
| 1257 | 1280 |
| 1258 var request = node.request(); | |
| 1259 if (reveal) | 1281 if (reveal) |
| 1260 Common.Revealer.reveal(request); | 1282 Common.Revealer.reveal(request); |
| 1261 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc
hRegex); | 1283 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc
hRegex); |
| 1262 this._highlightedSubstringChanges.push(highlightedSubstringChanges); | 1284 this._highlightedSubstringChanges.push(highlightedSubstringChanges); |
| 1263 | 1285 |
| 1264 this._currentMatchedRequestNode = node; | 1286 this._currentMatchedNode = node; |
| 1265 this._currentMatchedRequestIndex = n; | 1287 this._currentMatchedNodeIndex = n; |
| 1266 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat
ed, n); | 1288 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat
ed, n); |
| 1267 } | 1289 } |
| 1268 | 1290 |
| 1269 /** | 1291 /** |
| 1270 * @override | 1292 * @override |
| 1271 * @param {!UI.SearchableView.SearchConfig} searchConfig | 1293 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 1272 * @param {boolean} shouldJump | 1294 * @param {boolean} shouldJump |
| 1273 * @param {boolean=} jumpBackwards | 1295 * @param {boolean=} jumpBackwards |
| 1274 */ | 1296 */ |
| 1275 performSearch(searchConfig, shouldJump, jumpBackwards) { | 1297 performSearch(searchConfig, shouldJump, jumpBackwards) { |
| 1276 var query = searchConfig.query; | 1298 var query = searchConfig.query; |
| 1277 var currentMatchedRequestNode = this._currentMatchedRequestNode; | 1299 var currentMatchedNode = this._currentMatchedNode; |
| 1278 this._clearSearchMatchedList(); | 1300 this._clearSearchMatchedList(); |
| 1279 this._searchRegex = createPlainTextSearchRegex(query, 'i'); | 1301 this._searchRegex = createPlainTextSearchRegex(query, 'i'); |
| 1280 | 1302 |
| 1281 /** @type {!Array.<!Network.NetworkDataGridNode>} */ | 1303 var node = this._dataGrid.rootNode(); |
| 1282 var nodes = this._dataGrid.rootNode().children; | 1304 while ((node = /** @type {?Network.NetworkDataGridNode} */ (node.traverseNex
tNode(false)))) { |
| 1283 for (var i = 0; i < nodes.length; ++i) | 1305 var matched = this._nodeHasDirectMatch(node); |
| 1284 nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matc
hRequest(nodes[i].request()); | 1306 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = matched; |
| 1285 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current
MatchedRequestNode); | 1307 var parent = /** @type {?Network.NetworkDataGridNode} */ (node.parent); |
| 1286 if (!newMatchedRequestIndex && jumpBackwards) | 1308 while (matched && parent && parent[Network.NetworkLogView._isMatchingSearc
hQuerySymbol] === false) { |
| 1287 newMatchedRequestIndex = this._matchedRequestCount - 1; | 1309 parent[Network.NetworkLogView._isMatchingSearchQuerySymbol] = true; |
| 1288 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump
); | 1310 parent = /** @type {?Network.NetworkDataGridNode} */ (parent.parent); |
| 1311 } |
| 1312 } |
| 1313 |
| 1314 var newMatchedIndex = this._updateMatchCountAndFindMatchIndex(currentMatched
Node); |
| 1315 if (!newMatchedIndex && jumpBackwards) |
| 1316 newMatchedIndex = this._matchedRequestCount - 1; |
| 1317 this._highlightNthMatchedNodeForSearch(newMatchedIndex, shouldJump); |
| 1289 } | 1318 } |
| 1290 | 1319 |
| 1291 /** | 1320 /** |
| 1292 * @override | 1321 * @override |
| 1293 * @return {boolean} | 1322 * @return {boolean} |
| 1294 */ | 1323 */ |
| 1295 supportsCaseSensitiveSearch() { | 1324 supportsCaseSensitiveSearch() { |
| 1296 return false; | 1325 return false; |
| 1297 } | 1326 } |
| 1298 | 1327 |
| 1299 /** | 1328 /** |
| 1300 * @override | 1329 * @override |
| 1301 * @return {boolean} | 1330 * @return {boolean} |
| 1302 */ | 1331 */ |
| 1303 supportsRegexSearch() { | 1332 supportsRegexSearch() { |
| 1304 return true; | 1333 return true; |
| 1305 } | 1334 } |
| 1306 | 1335 |
| 1307 /** | 1336 /** |
| 1308 * @param {?Network.NetworkDataGridNode} node | 1337 * @param {?Network.NetworkDataGridNode} node |
| 1309 * @return {number} | 1338 * @return {number} |
| 1310 */ | 1339 */ |
| 1311 _updateMatchCountAndFindMatchIndex(node) { | 1340 _updateMatchCountAndFindMatchIndex(node) { |
| 1312 /** @type {!Array.<!Network.NetworkDataGridNode>} */ | 1341 /** @type {!Array.<!Network.NetworkDataGridNode>} */ |
| 1313 var nodes = this._dataGrid.rootNode().children; | 1342 var nodes = this.flattenAllNodes(); |
| 1314 var matchCount = 0; | 1343 var matchCount = 0; |
| 1315 var matchIndex = 0; | 1344 var matchIndex = 0; |
| 1316 for (var i = 0; i < nodes.length; ++i) { | 1345 for (var i = 0; i < nodes.length; ++i) { |
| 1317 if (!nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) | 1346 if (!nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) |
| 1318 continue; | 1347 continue; |
| 1319 if (node === nodes[i]) | 1348 if (node === nodes[i]) |
| 1320 matchIndex = matchCount; | 1349 matchIndex = matchCount; |
| 1321 matchCount++; | 1350 matchCount++; |
| 1322 } | 1351 } |
| 1323 if (this._matchedRequestCount !== matchCount) { | 1352 if (this._matchedRequestCount !== matchCount) { |
| 1324 this._matchedRequestCount = matchCount; | 1353 this._matchedRequestCount = matchCount; |
| 1325 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd
ated, matchCount); | 1354 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd
ated, matchCount); |
| 1326 } | 1355 } |
| 1327 return matchIndex; | 1356 return matchIndex; |
| 1328 } | 1357 } |
| 1329 | 1358 |
| 1330 /** | 1359 /** |
| 1331 * @param {number} index | 1360 * @param {number} index |
| 1332 * @return {number} | 1361 * @return {number} |
| 1333 */ | 1362 */ |
| 1334 _normalizeSearchResultIndex(index) { | 1363 _normalizeSearchResultIndex(index) { |
| 1335 return (index + this._matchedRequestCount) % this._matchedRequestCount; | 1364 return (index + this._matchedRequestCount) % this._matchedRequestCount; |
| 1336 } | 1365 } |
| 1337 | 1366 |
| 1338 /** | 1367 /** |
| 1339 * @param {!Network.NetworkDataGridNode} node | 1368 * @param {!Network.NetworkDataGridNode} node |
| 1340 * @return {boolean} | 1369 * @return {boolean} |
| 1341 */ | 1370 */ |
| 1342 _applyFilter(node) { | 1371 _applyFilter(node) { |
| 1343 var request = node.request(); | 1372 for (var request of node.requests()) { |
| 1344 if (this._timeFilter && !this._timeFilter(request)) | 1373 if (this._timeFilter && !this._timeFilter(request)) |
| 1345 return false; | 1374 continue; |
| 1346 var categoryName = request.resourceType().category().title; | 1375 var categoryName = request.resourceType().category().title; |
| 1347 if (!this._resourceCategoryFilterUI.accept(categoryName)) | 1376 if (!this._resourceCategoryFilterUI.accept(categoryName)) |
| 1348 return false; | 1377 continue; |
| 1349 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL()) | 1378 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL()) |
| 1350 return false; | 1379 continue; |
| 1351 if (request.statusText === 'Service Worker Fallback Required') | 1380 if (request.statusText === 'Service Worker Fallback Required') |
| 1352 return false; | 1381 continue; |
| 1353 for (var i = 0; i < this._filters.length; ++i) { | 1382 if (this._filters.some(filter => !filter(request))) |
| 1354 if (!this._filters[i](request)) | 1383 continue; |
| 1355 return false; | 1384 return true; |
| 1356 } | 1385 } |
| 1357 return true; | 1386 return false; |
| 1358 } | 1387 } |
| 1359 | 1388 |
| 1360 /** | 1389 /** |
| 1361 * @param {string} query | 1390 * @param {string} query |
| 1362 */ | 1391 */ |
| 1363 _parseFilterQuery(query) { | 1392 _parseFilterQuery(query) { |
| 1364 var parsedQuery; | 1393 var parsedQuery; |
| 1365 if (this._textFilterUI.isRegexChecked() && query !== '') | 1394 if (this._textFilterUI.isRegexChecked() && query !== '') |
| 1366 parsedQuery = {text: [query], filters: []}; | 1395 parsedQuery = {text: [query], filters: []}; |
| 1367 else | 1396 else |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 this._removeAllHighlights(); | 1517 this._removeAllHighlights(); |
| 1489 this._invalidateAllItems(); | 1518 this._invalidateAllItems(); |
| 1490 } | 1519 } |
| 1491 | 1520 |
| 1492 /** | 1521 /** |
| 1493 * @override | 1522 * @override |
| 1494 */ | 1523 */ |
| 1495 jumpToPreviousSearchResult() { | 1524 jumpToPreviousSearchResult() { |
| 1496 if (!this._matchedRequestCount) | 1525 if (!this._matchedRequestCount) |
| 1497 return; | 1526 return; |
| 1498 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde
x - 1); | 1527 var index = this._normalizeSearchResultIndex(this._currentMatchedNodeIndex -
1); |
| 1499 this._highlightNthMatchedRequestForSearch(index, true); | 1528 this._highlightNthMatchedNodeForSearch(index, true); |
| 1500 } | 1529 } |
| 1501 | 1530 |
| 1502 /** | 1531 /** |
| 1503 * @override | 1532 * @override |
| 1504 */ | 1533 */ |
| 1505 jumpToNextSearchResult() { | 1534 jumpToNextSearchResult() { |
| 1506 if (!this._matchedRequestCount) | 1535 if (!this._matchedRequestCount) |
| 1507 return; | 1536 return; |
| 1508 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde
x + 1); | 1537 var index = this._normalizeSearchResultIndex(this._currentMatchedNodeIndex +
1); |
| 1509 this._highlightNthMatchedRequestForSearch(index, true); | 1538 this._highlightNthMatchedNodeForSearch(index, true); |
| 1510 } | 1539 } |
| 1511 | 1540 |
| 1512 /** | 1541 /** |
| 1513 * @override | 1542 * @override |
| 1514 */ | 1543 */ |
| 1515 searchCanceled() { | 1544 searchCanceled() { |
| 1516 delete this._searchRegex; | 1545 delete this._searchRegex; |
| 1517 this._clearSearchMatchedList(); | 1546 this._clearSearchMatchedList(); |
| 1518 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat
ed, 0); | 1547 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat
ed, 0); |
| 1519 } | 1548 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1540 | 1569 |
| 1541 /** | 1570 /** |
| 1542 * @param {!Network.NetworkDataGridNode} node | 1571 * @param {!Network.NetworkDataGridNode} node |
| 1543 */ | 1572 */ |
| 1544 _highlightNode(node) { | 1573 _highlightNode(node) { |
| 1545 UI.runCSSAnimationOnce(node.element(), 'highlighted-row'); | 1574 UI.runCSSAnimationOnce(node.element(), 'highlighted-row'); |
| 1546 this._highlightedNode = node; | 1575 this._highlightedNode = node; |
| 1547 } | 1576 } |
| 1548 | 1577 |
| 1549 /** | 1578 /** |
| 1579 * @param {string} platform |
| 1550 * @param {!SDK.NetworkRequest} request | 1580 * @param {!SDK.NetworkRequest} request |
| 1551 * @param {string} platform | |
| 1552 * @return {string} | 1581 * @return {string} |
| 1553 */ | 1582 */ |
| 1554 _generateCurlCommand(request, platform) { | 1583 _generateCurlCommand(platform, request) { |
| 1555 var command = ['curl']; | 1584 var command = ['curl']; |
| 1556 // These headers are derived from URL (except "version") and would be added
by cURL anyway. | 1585 // These headers are derived from URL (except "version") and would be added
by cURL anyway. |
| 1557 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi
on': 1}; | 1586 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi
on': 1}; |
| 1558 | 1587 |
| 1559 function escapeStringWin(str) { | 1588 function escapeStringWin(str) { |
| 1560 /* If there are no new line characters do not escape the " characters | 1589 /* If there are no new line characters do not escape the " characters |
| 1561 since it only uglifies the command. | 1590 since it only uglifies the command. |
| 1562 | 1591 |
| 1563 Because cmd.exe parser and MS Crt arguments parsers use some of t
he | 1592 Because cmd.exe parser and MS Crt arguments parsers use some of t
he |
| 1564 same escape characters, they can interact with each other in | 1593 same escape characters, they can interact with each other in |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 Running: 'running', | 1744 Running: 'running', |
| 1716 FromCache: 'from-cache' | 1745 FromCache: 'from-cache' |
| 1717 }; | 1746 }; |
| 1718 | 1747 |
| 1719 /** @type {!Array<string>} */ | 1748 /** @type {!Array<string>} */ |
| 1720 Network.NetworkLogView._searchKeys = | 1749 Network.NetworkLogView._searchKeys = |
| 1721 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog
View.FilterType[key]); | 1750 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog
View.FilterType[key]); |
| 1722 | 1751 |
| 1723 /** @typedef {function(!SDK.NetworkRequest): boolean} */ | 1752 /** @typedef {function(!SDK.NetworkRequest): boolean} */ |
| 1724 Network.NetworkLogView.Filter; | 1753 Network.NetworkLogView.Filter; |
| OLD | NEW |