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