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

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

Issue 2523633003: [Devtools] Prepare network log view for grouping support (Closed)
Patch Set: changes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 /** @type {!Map.<string, !Network.NetworkDataGridNode>} */ 74 /** @type {!Map.<string, !Network.NetworkDataGridNode>} */
75 this._nodesByRequestId = new Map(); 75 this._nodesByRequestId = new Map();
76 /** @type {!Object.<string, boolean>} */ 76 /** @type {!Object.<string, boolean>} */
77 this._staleRequestIds = {}; 77 this._staleRequestIds = {};
78 /** @type {number} */ 78 /** @type {number} */
79 this._mainRequestLoadTime = -1; 79 this._mainRequestLoadTime = -1;
80 /** @type {number} */ 80 /** @type {number} */
81 this._mainRequestDOMContentLoadedTime = -1; 81 this._mainRequestDOMContentLoadedTime = -1;
82 this._matchedRequestCount = 0; 82 this._matchedRequestCount = 0;
83 /** @type {!Array<!Array<!Object>>} */
83 this._highlightedSubstringChanges = []; 84 this._highlightedSubstringChanges = [];
84 85
85 /** @type {!Array.<!Network.NetworkLogView.Filter>} */ 86 /** @type {!Array.<!Network.NetworkLogView.Filter>} */
86 this._filters = []; 87 this._filters = [];
87 /** @type {?Network.NetworkLogView.Filter} */ 88 /** @type {?Network.NetworkLogView.Filter} */
88 this._timeFilter = null; 89 this._timeFilter = null;
90 /** @type {?Network.NetworkDataGridNode} */
89 this._hoveredNode = null; 91 this._hoveredNode = null;
90 92
91 this._currentMatchedRequestNode = null; 93 /** @type {?Network.NetworkLogEntry} */
92 this._currentMatchedRequestIndex = -1; 94 this._currentMatchedLogEntry = null;
95 this._currentMatchedLogEntryIndex = -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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 */ 331 */
329 static _requestTimeFilter(windowStart, windowEnd, request) { 332 static _requestTimeFilter(windowStart, windowEnd, request) {
330 if (request.issueTime() > windowEnd) 333 if (request.issueTime() > windowEnd)
331 return false; 334 return false;
332 if (request.endTime !== -1 && request.endTime < windowStart) 335 if (request.endTime !== -1 && request.endTime < windowStart)
333 return false; 336 return false;
334 return true; 337 return true;
335 } 338 }
336 339
337 /** 340 /**
341 * @return {!Array<!Network.NetworkLogEntry>}
342 */
343 flatenChildren() {
dgozman 2016/11/28 18:39:51 These are definitely not children of log view. fla
allada 2016/11/29 00:35:09 Done.
344 return this._dataGrid.rootNode().flatenChildren();
345 }
346
347 /**
338 * @return {number} 348 * @return {number}
339 */ 349 */
340 headerHeight() { 350 headerHeight() {
341 return this._headerHeight; 351 return this._headerHeight;
342 } 352 }
343 353
344 /** 354 /**
345 * @param {boolean} recording 355 * @param {boolean} recording
346 */ 356 */
347 setRecording(recording) { 357 setRecording(recording) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 * @return {!Array.<!Element>} 508 * @return {!Array.<!Element>}
499 */ 509 */
500 elementsToRestoreScrollPositionsFor() { 510 elementsToRestoreScrollPositionsFor() {
501 if (!this._dataGrid) // Not initialized yet. 511 if (!this._dataGrid) // Not initialized yet.
502 return []; 512 return [];
503 return [this._dataGrid.scrollContainer]; 513 return [this._dataGrid.scrollContainer];
504 } 514 }
505 515
506 _setupDataGrid() { 516 _setupDataGrid() {
507 this._dataGrid = this._columns.dataGrid(); 517 this._dataGrid = this._columns.dataGrid();
518 var contextMenuHandler = this.handleContextMenuForLogEntry.bind(this);
508 this._dataGrid.setRowContextMenuCallback( 519 this._dataGrid.setRowContextMenuCallback(
509 (contextMenu, node) => this.handleContextMenuForRequest(contextMenu, nod e.request())); 520 (contextMenu, node) => contextMenuHandler(contextMenu, /** @type {!Netwo rk.NetworkDataGridNode} */ (node)));
510 this._dataGrid.setStickToBottom(true); 521 this._dataGrid.setStickToBottom(true);
511 this._dataGrid.setName('networkLog'); 522 this._dataGrid.setName('networkLog');
512 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last); 523 this._dataGrid.setResizeMethod(UI.DataGrid.ResizeMethod.Last);
513 this._dataGrid.element.classList.add('network-log-grid'); 524 this._dataGrid.element.classList.add('network-log-grid');
514 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true); 525 this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown .bind(this), true);
515 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true); 526 this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove .bind(this), true);
516 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true); 527 this._dataGrid.element.addEventListener('mouseleave', this._dataGridMouseLea ve.bind(this), true);
517 } 528 }
518 529
519 /** 530 /**
520 * @param {!Event} event 531 * @param {!Event} event
521 */ 532 */
522 _dataGridMouseMove(event) { 533 _dataGridMouseMove(event) {
523 var node = this._dataGrid.dataGridNodeFromNode(event.target); 534 var node = this._dataGrid.dataGridNodeFromNode(event.target);
524 var highlightInitiatorChain = event.shiftKey; 535 var highlightInitiatorChain = event.shiftKey;
525 this._setHoveredNode(node, highlightInitiatorChain); 536 this._setHoveredNode(node, highlightInitiatorChain);
537 // TODO(allada) Support groupping initiator chain instead of first request.
526 this._highlightInitiatorChain((highlightInitiatorChain && node) ? node.reque st() : null); 538 this._highlightInitiatorChain((highlightInitiatorChain && node) ? node.reque st() : null);
527 } 539 }
528 540
529 _dataGridMouseLeave() { 541 _dataGridMouseLeave() {
530 this._setHoveredNode(null); 542 this._setHoveredNode(null);
531 this._highlightInitiatorChain(null); 543 this._highlightInitiatorChain(null);
532 } 544 }
533 545
534 /** 546 /**
535 * @param {?Network.NetworkLogEntry} logEntry 547 * @param {?Network.NetworkLogEntry} logEntry
536 * @param {boolean} highlightInitiatorChain 548 * @param {boolean} highlightInitiatorChain
537 */ 549 */
538 setHoveredLogEntry(logEntry, highlightInitiatorChain) { 550 setHoveredLogEntry(logEntry, highlightInitiatorChain) {
539 // TODO(allada) Move this into LogEntry/NetworkDataGridNode. 551 // TODO(allada) Move this into LogEntry/NetworkDataGridNode.
540 this._setHoveredNode(/** @type {?Network.NetworkDataGridNode} */ (logEntry), highlightInitiatorChain); 552 this._setHoveredNode(/** @type {?Network.NetworkDataGridNode} */ (logEntry), highlightInitiatorChain);
553 // TODO(allada) Support groupping initiator chain instead of first request.
541 this._highlightInitiatorChain((logEntry && highlightInitiatorChain) ? logEnt ry.request() : null); 554 this._highlightInitiatorChain((logEntry && highlightInitiatorChain) ? logEnt ry.request() : null);
542 } 555 }
543 556
544 /** 557 /**
545 * @param {?Network.NetworkDataGridNode} node 558 * @param {?Network.NetworkDataGridNode} node
546 * @param {boolean=} highlightInitiatorChain 559 * @param {boolean=} highlightInitiatorChain
547 */ 560 */
548 _setHoveredNode(node, highlightInitiatorChain) { 561 _setHoveredNode(node, highlightInitiatorChain) {
549 if (this._hoveredNode) 562 if (this._hoveredNode)
550 this._hoveredNode.element().classList.remove('hover'); 563 this._hoveredNode.element().classList.remove('hover');
(...skipping 25 matching lines...) Expand all
576 continue; 589 continue;
577 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path'); 590 node.element().classList.remove('network-node-on-initiator-path', 'netwo rk-node-on-initiated-path');
578 } 591 }
579 return; 592 return;
580 } 593 }
581 594
582 var initiatorGraph = request.initiatorGraph(); 595 var initiatorGraph = request.initiatorGraph();
583 for (var node of this._nodesByRequestId.values()) { 596 for (var node of this._nodesByRequestId.values()) {
584 if (!node.dataGrid) 597 if (!node.dataGrid)
585 continue; 598 continue;
586 node.element().classList.toggle( 599 var hasInitiator = false;
587 'network-node-on-initiator-path', 600 var hasInitiated = false;
588 node.request() !== request && initiatorGraph.initiators.has(node.reque st())); 601 for (var childRequest of node.requests()) {
589 node.element().classList.toggle( 602 if (childRequest === request)
590 'network-node-on-initiated-path', node.request() !== request && initia torGraph.initiated.has(node.request())); 603 continue;
604 hasInitiator = initiatorGraph.initiators.has(childRequest);
605 hasInitiated = initiatorGraph.initiated.has(childRequest);
606 if (hasInitiator || hasInitiated)
607 break;
608 }
609
610 node.element().classList.toggle('network-node-on-initiator-path', hasIniti ator);
611 node.element().classList.toggle('network-node-on-initiated-path', hasIniti ated);
591 } 612 }
592 } 613 }
593 614
594 _updateSummaryBar() { 615 _updateSummaryBar() {
595 var requestsNumber = this._nodesByRequestId.size; 616 var requestsNumber = this._nodesByRequestId.size;
596 617
597 if (!requestsNumber) { 618 if (!requestsNumber) {
598 this._showRecordingHint(); 619 this._showRecordingHint();
599 return; 620 return;
600 } 621 }
601 this._hideRecordingHint(); 622 this._hideRecordingHint();
602 623
603 var transferSize = 0; 624 var transferSize = 0;
604 var selectedRequestsNumber = 0; 625 var selectedRequestsNumber = 0;
605 var selectedTransferSize = 0; 626 var selectedTransferSize = 0;
606 var baseTime = -1; 627 var baseTime = -1;
607 var maxTime = -1; 628 var maxTime = -1;
608 var nodes = this._nodesByRequestId.valuesArray(); 629 for (var node of this._nodesByRequestId.values()) {
609 for (var i = 0; i < nodes.length; ++i) { 630 var isFilteredOut = node[Network.NetworkLogView._isFilteredOutSymbol];
610 var request = nodes[i].request(); 631 for (var request of node.requests()) {
611 var requestTransferSize = request.transferSize; 632 var requestTransferSize = request.transferSize;
612 transferSize += requestTransferSize; 633 transferSize += requestTransferSize;
613 if (!nodes[i][Network.NetworkLogView._isFilteredOutSymbol]) { 634 if (!isFilteredOut) {
614 selectedRequestsNumber++; 635 selectedRequestsNumber++;
615 selectedTransferSize += requestTransferSize; 636 selectedTransferSize += requestTransferSize;
637 }
638 if (request.url === request.target().inspectedURL() && request.resourceT ype() === Common.resourceTypes.Document)
639 baseTime = request.startTime;
640 if (request.endTime > maxTime)
641 maxTime = request.endTime;
616 } 642 }
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 } 643 }
622 644
623 var summaryBar = this._summaryBarElement; 645 var summaryBar = this._summaryBarElement;
624 summaryBar.removeChildren(); 646 summaryBar.removeChildren();
625 var separator = '\u2002\u2758\u2002'; 647 var separator = '\u2002\u2758\u2002';
626 var text = ''; 648 var text = '';
627 /** 649 /**
628 * @param {string} chunk 650 * @param {string} chunk
629 * @return {!Element} 651 * @return {!Element}
630 */ 652 */
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 this._columns.wasShown(); 795 this._columns.wasShown();
774 } 796 }
775 797
776 /** 798 /**
777 * @override 799 * @override
778 */ 800 */
779 willHide() { 801 willHide() {
780 this._columns.willHide(); 802 this._columns.willHide();
781 } 803 }
782 804
783 /**
784 * @return {!Array<!Network.NetworkDataGridNode>}
785 */
786 flatNodesList() {
787 return this._dataGrid.flatNodesList();
788 }
789
790 _refresh() { 805 _refresh() {
791 this._needsRefresh = false; 806 this._needsRefresh = false;
792 807
793 if (this._refreshRequestId) { 808 if (this._refreshRequestId) {
794 this.element.window().cancelAnimationFrame(this._refreshRequestId); 809 this.element.window().cancelAnimationFrame(this._refreshRequestId);
795 delete this._refreshRequestId; 810 delete this._refreshRequestId;
796 } 811 }
797 812
798 this.removeAllNodeHighlights(); 813 this.removeAllNodeHighlights();
799 814
800 var oldBoundary = this.calculator().boundary(); 815 var oldBoundary = this.calculator().boundary();
801 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime) ; 816 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime) ;
802 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime); 817 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime);
803 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMConten tLoadedTime); 818 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMConten tLoadedTime);
804 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime); 819 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime);
805 820
806 var dataGrid = this._dataGrid; 821 var dataGrid = this._dataGrid;
807 var rootNode = dataGrid.rootNode(); 822 var rootNode = dataGrid.rootNode();
823
808 /** @type {!Array<!Network.NetworkDataGridNode> } */ 824 /** @type {!Array<!Network.NetworkDataGridNode> } */
809 var nodesToInsert = []; 825 var nodesToInsert = [];
810 /** @type {!Array<!Network.NetworkDataGridNode> } */ 826 /** @type {!Array<!Network.NetworkDataGridNode> } */
811 var nodesToRefresh = []; 827 var nodesToRefresh = [];
812 for (var requestId in this._staleRequestIds) { 828 for (var requestId in this._staleRequestIds) {
813 var node = this._nodesByRequestId.get(requestId); 829 var node = this._nodesByRequestId.get(requestId);
814 if (!node) 830 if (!node)
815 continue; 831 continue;
816 var isFilteredOut = !this._applyFilter(node); 832 var isFilteredOut = !this._applyFilter(node);
817 if (isFilteredOut && node === this._hoveredNode) 833 if (isFilteredOut && node === this._hoveredNode)
818 this._setHoveredNode(null); 834 this._setHoveredNode(null);
819 if (node[Network.NetworkLogView._isFilteredOutSymbol] !== isFilteredOut) { 835 if (node[Network.NetworkLogView._isFilteredOutSymbol] !== isFilteredOut) {
820 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 836 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
821 rootNode.removeChild(node); 837 rootNode.removeChild(node);
822 838
823 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut; 839 node[Network.NetworkLogView._isFilteredOutSymbol] = isFilteredOut;
824 840
825 if (!node[Network.NetworkLogView._isFilteredOutSymbol]) 841 if (!node[Network.NetworkLogView._isFilteredOutSymbol])
826 nodesToInsert.push(node); 842 nodesToInsert.push(node);
827 } 843 }
828 if (!isFilteredOut) 844 if (!isFilteredOut)
829 nodesToRefresh.push(node); 845 nodesToRefresh.push(node);
830 var request = node.request(); 846 for (var request of node.requests()) {
831 this._timeCalculator.updateBoundaries(request); 847 this._timeCalculator.updateBoundaries(request);
832 this._durationCalculator.updateBoundaries(request); 848 this._durationCalculator.updateBoundaries(request);
849 }
833 } 850 }
834 851
835 for (var i = 0; i < nodesToInsert.length; ++i) { 852 for (var node of nodesToInsert) {
836 var node = nodesToInsert[i];
837 var request = node.request();
838 dataGrid.insertChild(node); 853 dataGrid.insertChild(node);
839 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchReq uest(request); 854 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchLog Entry(node);
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._currentMatchedLogEntry), f alse);
847 862
848 this._staleRequestIds = {}; 863 this._staleRequestIds = {};
849 this._updateSummaryBar(); 864 this._updateSummaryBar();
850 865
851 this._columns.dataChanged(); 866 this._columns.dataChanged();
852 } 867 }
853 868
854 reset() { 869 reset() {
855 this._requestWithHighlightedInitiators = null; 870 this._requestWithHighlightedInitiators = null;
856 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null); 871 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null);
(...skipping 49 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 var originalRequest = originalRequestNode ? originalRequestNode.request() : null;
917 this._nodesByRequestId.set(originalRequestNode.request().requestId, origin alRequestNode); 932 if (originalRequest)
933 this._nodesByRequestId.set(originalRequest.requestId, originalRequestNode) ;
934
918 this._nodesByRequestId.set(request.requestId, node); 935 this._nodesByRequestId.set(request.requestId, node);
919 936
920 // Pull all the redirects of the main request upon commit load. 937 // Pull all the redirects of the main request upon commit load.
921 if (request.redirects) { 938 if (request.redirects)
922 for (var i = 0; i < request.redirects.length; ++i) 939 request.redirects.forEach(this._refreshRequest.bind(this));
923 this._refreshRequest(request.redirects[i]);
924 }
925 940
926 this._refreshRequest(request); 941 this._refreshRequest(request);
927 } 942 }
928 943
929 /** 944 /**
930 * @param {!Common.Event} event 945 * @param {!Common.Event} event
931 */ 946 */
932 _onRequestUpdated(event) { 947 _onRequestUpdated(event) {
933 var request = /** @type {!SDK.NetworkRequest} */ (event.data); 948 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
934 this._refreshRequest(request); 949 this._refreshRequest(request);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1040
1026 /** 1041 /**
1027 * @param {boolean} gridMode 1042 * @param {boolean} gridMode
1028 */ 1043 */
1029 switchViewMode(gridMode) { 1044 switchViewMode(gridMode) {
1030 this._columns.switchViewMode(gridMode); 1045 this._columns.switchViewMode(gridMode);
1031 } 1046 }
1032 1047
1033 /** 1048 /**
1034 * @param {!UI.ContextMenu} contextMenu 1049 * @param {!UI.ContextMenu} contextMenu
1035 * @param {!SDK.NetworkRequest} request 1050 * @param {!Network.NetworkLogEntry} logEntry
1036 */ 1051 */
1037 handleContextMenuForRequest(contextMenu, request) { 1052 handleContextMenuForLogEntry(contextMenu, logEntry) {
1053 // TODO(allada) Support groupped items context menu.
1054 var request = logEntry.request();
1055 if (!request)
1056 return;
1038 contextMenu.appendApplicableItems(request); 1057 contextMenu.appendApplicableItems(request);
1039 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy')); 1058 var copyMenu = contextMenu.appendSubMenuItem(Common.UIString('Copy'));
1040 if (request) { 1059 if (request) {
1041 copyMenu.appendItem( 1060 copyMenu.appendItem(
1042 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL())); 1061 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspect orFrontendHost, request.contentURL()));
1043 copyMenu.appendSeparator(); 1062 copyMenu.appendSeparator();
1044 1063
1045 if (request.requestHeadersText()) { 1064 if (request.requestHeadersText()) {
1046 copyMenu.appendItem( 1065 copyMenu.appendItem(
1047 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request)); 1066 Common.UIString.capitalize('Copy ^request ^headers'), this._copyRequ estHeaders.bind(this, request));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 } 1115 }
1097 } 1116 }
1098 1117
1099 if (request && request.resourceType() === Common.resourceTypes.XHR) { 1118 if (request && request.resourceType() === Common.resourceTypes.XHR) {
1100 contextMenu.appendSeparator(); 1119 contextMenu.appendSeparator();
1101 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request)); 1120 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi nd(request));
1102 contextMenu.appendSeparator(); 1121 contextMenu.appendSeparator();
1103 } 1122 }
1104 } 1123 }
1105 1124
1125 /**
1126 * @return {!Array<!SDK.NetworkRequest>}
1127 */
1128 _allRequests() {
1129 var requests = [];
1130 for (var node of this._nodesByRequestId.values())
1131 requests = requests.concat(node.requests());
dgozman 2016/11/28 18:39:51 Should this be node.request() instead?
allada 2016/11/29 00:35:09 Done.
1132 return requests;
1133 }
1134
1106 _harRequests() { 1135 _harRequests() {
1107 var requests = this._nodesByRequestId.valuesArray().map(function(node) { 1136 var httpRequests = this._allRequests().filter(Network.NetworkLogView.HTTPReq uestsFilter);
1108 return node.request();
1109 });
1110 var httpRequests = requests.filter(Network.NetworkLogView.HTTPRequestsFilter );
1111 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter); 1137 return httpRequests.filter(Network.NetworkLogView.FinishedRequestsFilter);
1112 } 1138 }
1113 1139
1114 _copyAll() { 1140 _copyAll() {
1115 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()}; 1141 var harArchive = {log: (new SDK.HARLog(this._harRequests())).build()};
1116 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2)); 1142 InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2));
1117 } 1143 }
1118 1144
1119 /** 1145 /**
1120 * @param {!SDK.NetworkRequest} request 1146 * @param {!SDK.NetworkRequest} request
(...skipping 22 matching lines...) Expand all
1143 */ 1169 */
1144 _copyResponseHeaders(request) { 1170 _copyResponseHeaders(request) {
1145 InspectorFrontendHost.copyText(request.responseHeadersText); 1171 InspectorFrontendHost.copyText(request.responseHeadersText);
1146 } 1172 }
1147 1173
1148 /** 1174 /**
1149 * @param {!SDK.NetworkRequest} request 1175 * @param {!SDK.NetworkRequest} request
1150 * @param {string} platform 1176 * @param {string} platform
1151 */ 1177 */
1152 _copyCurlCommand(request, platform) { 1178 _copyCurlCommand(request, platform) {
1153 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platform)) ; 1179 InspectorFrontendHost.copyText(this._generateCurlCommand(platform, request)) ;
1154 } 1180 }
1155 1181
1156 /** 1182 /**
1157 * @param {string} platform 1183 * @param {string} platform
1158 */ 1184 */
1159 _copyAllCurlCommand(platform) { 1185 _copyAllCurlCommand(platform) {
1160 var requests = this._nodesByRequestId.valuesArray().map(node => node.request ()); 1186 var commands = this._allRequests().map(this._generateCurlCommand.bind(this, platform));
1161 var commands = [];
1162 for (var request of requests)
1163 commands.push(this._generateCurlCommand(request, platform));
1164 if (platform === 'win') 1187 if (platform === 'win')
1165 InspectorFrontendHost.copyText(commands.join(' &\r\n')); 1188 InspectorFrontendHost.copyText(commands.join(' &\r\n'));
1166 else 1189 else
1167 InspectorFrontendHost.copyText(commands.join(' ;\n')); 1190 InspectorFrontendHost.copyText(commands.join(' ;\n'));
1168 } 1191 }
1169 1192
1170 _exportAll() { 1193 _exportAll() {
1171 var url = SDK.targetManager.mainTarget().inspectedURL(); 1194 var url = SDK.targetManager.mainTarget().inspectedURL();
1172 var parsedURL = url.asParsedURL(); 1195 var parsedURL = url.asParsedURL();
1173 var filename = parsedURL ? parsedURL.host : 'network-log'; 1196 var filename = parsedURL ? parsedURL.host : 'network-log';
(...skipping 18 matching lines...) Expand all
1192 if (confirm(Common.UIString('Are you sure you want to clear browser cache?') )) 1215 if (confirm(Common.UIString('Are you sure you want to clear browser cache?') ))
1193 SDK.multitargetNetworkManager.clearBrowserCache(); 1216 SDK.multitargetNetworkManager.clearBrowserCache();
1194 } 1217 }
1195 1218
1196 _clearBrowserCookies() { 1219 _clearBrowserCookies() {
1197 if (confirm(Common.UIString('Are you sure you want to clear browser cookies? '))) 1220 if (confirm(Common.UIString('Are you sure you want to clear browser cookies? ')))
1198 SDK.multitargetNetworkManager.clearBrowserCookies(); 1221 SDK.multitargetNetworkManager.clearBrowserCookies();
1199 } 1222 }
1200 1223
1201 /** 1224 /**
1202 * @param {!SDK.NetworkRequest} request 1225 * @param {!Network.NetworkLogEntry} logEntry
1203 * @return {boolean} 1226 * @return {boolean}
1204 */ 1227 */
1205 _matchRequest(request) { 1228 _matchLogEntry(logEntry) {
1206 var re = this._searchRegex; 1229 var re = this._searchRegex;
1207 if (!re) 1230 if (!re)
1208 return false; 1231 return false;
1209 1232 var requests = logEntry.request() ? [logEntry.request()] : [];
dgozman 2016/11/28 18:39:51 I don't get this line.
allada 2016/11/29 00:35:09 Done.
1210 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + r equest.name() : request.name(); 1233 for (var request of requests) {
1211 return re.test(text); 1234 var text = this._networkLogLargeRowsSetting.get() ? request.path() + '/' + request.name() : request.name();
1235 if (re.test(text))
1236 return true;
1237 }
1238 return false;
1212 } 1239 }
1213 1240
1214 _clearSearchMatchedList() { 1241 _clearSearchMatchedList() {
1215 this._matchedRequestCount = -1; 1242 this._matchedRequestCount = -1;
1216 this._currentMatchedRequestNode = null; 1243 this._currentMatchedLogEntry = null;
1217 this._removeAllHighlights(); 1244 this._removeAllHighlights();
1218 } 1245 }
1219 1246
1220 _removeAllHighlights() { 1247 _removeAllHighlights() {
1221 this.removeAllNodeHighlights(); 1248 this.removeAllNodeHighlights();
1222 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) 1249 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i)
1223 UI.revertDomChanges(this._highlightedSubstringChanges[i]); 1250 UI.revertDomChanges(this._highlightedSubstringChanges[i]);
1224 this._highlightedSubstringChanges = []; 1251 this._highlightedSubstringChanges = [];
1225 } 1252 }
1226 1253
1227 dataGridSorted() { 1254 dataGridSorted() {
1228 this._highlightNthMatchedRequestForSearch( 1255 this._highlightNthMatchedRequestForSearch(
1229 this._updateMatchCountAndFindMatchIndex(this._currentMatchedRequestNode) , false); 1256 this._updateMatchCountAndFindMatchIndex(this._currentMatchedLogEntry), f alse);
1230 } 1257 }
1231 1258
1232 /** 1259 /**
1233 * @param {number} n 1260 * @param {number} n
1234 * @param {boolean} reveal 1261 * @param {boolean} reveal
1235 */ 1262 */
1236 _highlightNthMatchedRequestForSearch(n, reveal) { 1263 _highlightNthMatchedRequestForSearch(n, reveal) {
1237 this._removeAllHighlights(); 1264 this._removeAllHighlights();
1238 1265
1239 /** @type {!Array.<!Network.NetworkDataGridNode>} */
1240 var nodes = this._dataGrid.rootNode().children;
1241 var matchCount = 0; 1266 var matchCount = 0;
1242 var node = null; 1267 var request = null;
1243 for (var i = 0; i < nodes.length; ++i) { 1268 for (var node of this.flatenChildren()) {
1244 if (nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) { 1269 if (!node[Network.NetworkLogView._isMatchingSearchQuerySymbol])
1245 if (matchCount === n) { 1270 continue;
1246 node = nodes[i]; 1271 if (matchCount === n) {
1247 break; 1272 // TODO(allada) This should support multiple requests.
1248 } 1273 request = node.request();
1249 matchCount++; 1274 break;
1250 } 1275 }
1276 matchCount++;
1251 } 1277 }
1252 if (!node) { 1278 if (!request) {
1253 this._currentMatchedRequestNode = null; 1279 this._currentMatchedLogEntry = null;
1254 return; 1280 return;
1255 } 1281 }
1256 1282
1257 var request = node.request();
1258 if (reveal) 1283 if (reveal)
1259 Common.Revealer.reveal(request); 1284 Common.Revealer.reveal(request);
1260 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex); 1285 var highlightedSubstringChanges = node.highlightMatchedSubstring(this._searc hRegex);
1261 this._highlightedSubstringChanges.push(highlightedSubstringChanges); 1286 this._highlightedSubstringChanges.push(highlightedSubstringChanges);
1262 1287
1263 this._currentMatchedRequestNode = node; 1288 this._currentMatchedLogEntry = node;
1264 this._currentMatchedRequestIndex = n; 1289 this._currentMatchedLogEntryIndex = n;
1265 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n); 1290 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchIndexUpdat ed, n);
1266 } 1291 }
1267 1292
1268 /** 1293 /**
1269 * @override 1294 * @override
1270 * @param {!UI.SearchableView.SearchConfig} searchConfig 1295 * @param {!UI.SearchableView.SearchConfig} searchConfig
1271 * @param {boolean} shouldJump 1296 * @param {boolean} shouldJump
1272 * @param {boolean=} jumpBackwards 1297 * @param {boolean=} jumpBackwards
1273 */ 1298 */
1274 performSearch(searchConfig, shouldJump, jumpBackwards) { 1299 performSearch(searchConfig, shouldJump, jumpBackwards) {
1275 var query = searchConfig.query; 1300 var query = searchConfig.query;
1276 var currentMatchedRequestNode = this._currentMatchedRequestNode; 1301 var currentMatchedLogEntry = this._currentMatchedLogEntry;
1277 this._clearSearchMatchedList(); 1302 this._clearSearchMatchedList();
1278 this._searchRegex = createPlainTextSearchRegex(query, 'i'); 1303 this._searchRegex = createPlainTextSearchRegex(query, 'i');
1279 1304
1280 /** @type {!Array.<!Network.NetworkDataGridNode>} */ 1305 for (var node of this.flatenChildren())
1281 var nodes = this._dataGrid.rootNode().children; 1306 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matchLog Entry(node);
1282 for (var i = 0; i < nodes.length; ++i) 1307
1283 nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol] = this._matc hRequest(nodes[i].request()); 1308 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current MatchedLogEntry);
1284 var newMatchedRequestIndex = this._updateMatchCountAndFindMatchIndex(current MatchedRequestNode);
1285 if (!newMatchedRequestIndex && jumpBackwards) 1309 if (!newMatchedRequestIndex && jumpBackwards)
1286 newMatchedRequestIndex = this._matchedRequestCount - 1; 1310 newMatchedRequestIndex = this._matchedRequestCount - 1;
1287 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump ); 1311 this._highlightNthMatchedRequestForSearch(newMatchedRequestIndex, shouldJump );
1288 } 1312 }
1289 1313
1290 /** 1314 /**
1291 * @override 1315 * @override
1292 * @return {boolean} 1316 * @return {boolean}
1293 */ 1317 */
1294 supportsCaseSensitiveSearch() { 1318 supportsCaseSensitiveSearch() {
1295 return false; 1319 return false;
1296 } 1320 }
1297 1321
1298 /** 1322 /**
1299 * @override 1323 * @override
1300 * @return {boolean} 1324 * @return {boolean}
1301 */ 1325 */
1302 supportsRegexSearch() { 1326 supportsRegexSearch() {
1303 return true; 1327 return true;
1304 } 1328 }
1305 1329
1306 /** 1330 /**
1307 * @param {?Network.NetworkDataGridNode} node 1331 * @param {?Network.NetworkLogEntry} logEntry
1308 * @return {number} 1332 * @return {number}
1309 */ 1333 */
1310 _updateMatchCountAndFindMatchIndex(node) { 1334 _updateMatchCountAndFindMatchIndex(logEntry) {
1311 /** @type {!Array.<!Network.NetworkDataGridNode>} */
1312 var nodes = this._dataGrid.rootNode().children;
1313 var matchCount = 0; 1335 var matchCount = 0;
1314 var matchIndex = 0; 1336 var matchIndex = 0;
1315 for (var i = 0; i < nodes.length; ++i) { 1337 for (var item of this.flatenChildren()) {
1316 if (!nodes[i][Network.NetworkLogView._isMatchingSearchQuerySymbol]) 1338 if (!item[Network.NetworkLogView._isMatchingSearchQuerySymbol])
1317 continue; 1339 continue;
1318 if (node === nodes[i]) 1340 if (logEntry === item)
1319 matchIndex = matchCount; 1341 matchIndex = matchCount;
1320 matchCount++; 1342 matchCount++;
1321 } 1343 }
1322 if (this._matchedRequestCount !== matchCount) { 1344 if (this._matchedRequestCount !== matchCount) {
1323 this._matchedRequestCount = matchCount; 1345 this._matchedRequestCount = matchCount;
1324 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd ated, matchCount); 1346 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpd ated, matchCount);
1325 } 1347 }
1326 return matchIndex; 1348 return matchIndex;
1327 } 1349 }
1328 1350
1329 /** 1351 /**
1330 * @param {number} index 1352 * @param {number} index
1331 * @return {number} 1353 * @return {number}
1332 */ 1354 */
1333 _normalizeSearchResultIndex(index) { 1355 _normalizeSearchResultIndex(index) {
1334 return (index + this._matchedRequestCount) % this._matchedRequestCount; 1356 return (index + this._matchedRequestCount) % this._matchedRequestCount;
1335 } 1357 }
1336 1358
1337 /** 1359 /**
1338 * @param {!Network.NetworkDataGridNode} node 1360 * @param {!Network.NetworkDataGridNode} node
1339 * @return {boolean} 1361 * @return {boolean}
1340 */ 1362 */
1341 _applyFilter(node) { 1363 _applyFilter(node) {
1342 var request = node.request(); 1364 for (var request of node.requests()) {
1343 if (this._timeFilter && !this._timeFilter(request)) 1365 if (this._timeFilter && !this._timeFilter(request))
1344 return false; 1366 continue;
1345 var categoryName = request.resourceType().category().title; 1367 var categoryName = request.resourceType().category().title;
1346 if (!this._resourceCategoryFilterUI.accept(categoryName)) 1368 if (!this._resourceCategoryFilterUI.accept(categoryName))
1347 return false; 1369 continue;
1348 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL()) 1370 if (this._dataURLFilterUI.checked() && request.parsedURL.isDataURL())
1349 return false; 1371 continue;
1350 if (request.statusText === 'Service Worker Fallback Required') 1372 if (request.statusText === 'Service Worker Fallback Required')
1351 return false; 1373 continue;
1352 for (var i = 0; i < this._filters.length; ++i) { 1374 if (this._filters.some(filter => !filter(request)))
1353 if (!this._filters[i](request)) 1375 continue;
1354 return false; 1376 return true;
1355 } 1377 }
1356 return true; 1378 return false;
1357 } 1379 }
1358 1380
1359 /** 1381 /**
1360 * @param {string} query 1382 * @param {string} query
1361 */ 1383 */
1362 _parseFilterQuery(query) { 1384 _parseFilterQuery(query) {
1363 var parsedQuery; 1385 var parsedQuery;
1364 if (this._textFilterUI.isRegexChecked() && query !== '') 1386 if (this._textFilterUI.isRegexChecked() && query !== '')
1365 parsedQuery = {text: [query], filters: []}; 1387 parsedQuery = {text: [query], filters: []};
1366 else 1388 else
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 this._removeAllHighlights(); 1509 this._removeAllHighlights();
1488 this._invalidateAllItems(); 1510 this._invalidateAllItems();
1489 } 1511 }
1490 1512
1491 /** 1513 /**
1492 * @override 1514 * @override
1493 */ 1515 */
1494 jumpToPreviousSearchResult() { 1516 jumpToPreviousSearchResult() {
1495 if (!this._matchedRequestCount) 1517 if (!this._matchedRequestCount)
1496 return; 1518 return;
1497 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde x - 1); 1519 var index = this._normalizeSearchResultIndex(this._currentMatchedLogEntryInd ex - 1);
1498 this._highlightNthMatchedRequestForSearch(index, true); 1520 this._highlightNthMatchedRequestForSearch(index, true);
1499 } 1521 }
1500 1522
1501 /** 1523 /**
1502 * @override 1524 * @override
1503 */ 1525 */
1504 jumpToNextSearchResult() { 1526 jumpToNextSearchResult() {
1505 if (!this._matchedRequestCount) 1527 if (!this._matchedRequestCount)
1506 return; 1528 return;
1507 var index = this._normalizeSearchResultIndex(this._currentMatchedRequestInde x + 1); 1529 var index = this._normalizeSearchResultIndex(this._currentMatchedLogEntryInd ex + 1);
1508 this._highlightNthMatchedRequestForSearch(index, true); 1530 this._highlightNthMatchedRequestForSearch(index, true);
1509 } 1531 }
1510 1532
1511 /** 1533 /**
1512 * @override 1534 * @override
1513 */ 1535 */
1514 searchCanceled() { 1536 searchCanceled() {
1515 delete this._searchRegex; 1537 delete this._searchRegex;
1516 this._clearSearchMatchedList(); 1538 this._clearSearchMatchedList();
1517 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat ed, 0); 1539 this.dispatchEventToListeners(Network.NetworkLogView.Events.SearchCountUpdat ed, 0);
(...skipping 21 matching lines...) Expand all
1539 1561
1540 /** 1562 /**
1541 * @param {!Network.NetworkDataGridNode} node 1563 * @param {!Network.NetworkDataGridNode} node
1542 */ 1564 */
1543 _highlightNode(node) { 1565 _highlightNode(node) {
1544 UI.runCSSAnimationOnce(node.element(), 'highlighted-row'); 1566 UI.runCSSAnimationOnce(node.element(), 'highlighted-row');
1545 this._highlightedNode = node; 1567 this._highlightedNode = node;
1546 } 1568 }
1547 1569
1548 /** 1570 /**
1571 * @param {string} platform
1549 * @param {!SDK.NetworkRequest} request 1572 * @param {!SDK.NetworkRequest} request
1550 * @param {string} platform
1551 * @return {string} 1573 * @return {string}
1552 */ 1574 */
1553 _generateCurlCommand(request, platform) { 1575 _generateCurlCommand(platform, request) {
1554 var command = ['curl']; 1576 var command = ['curl'];
1555 // These headers are derived from URL (except "version") and would be added by cURL anyway. 1577 // These headers are derived from URL (except "version") and would be added by cURL anyway.
1556 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi on': 1}; 1578 var ignoredHeaders = {'host': 1, 'method': 1, 'path': 1, 'scheme': 1, 'versi on': 1};
1557 1579
1558 function escapeStringWin(str) { 1580 function escapeStringWin(str) {
1559 /* If there are no new line characters do not escape the " characters 1581 /* If there are no new line characters do not escape the " characters
1560 since it only uglifies the command. 1582 since it only uglifies the command.
1561 1583
1562 Because cmd.exe parser and MS Crt arguments parsers use some of t he 1584 Because cmd.exe parser and MS Crt arguments parsers use some of t he
1563 same escape characters, they can interact with each other in 1585 same escape characters, they can interact with each other in
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 Running: 'running', 1736 Running: 'running',
1715 FromCache: 'from-cache' 1737 FromCache: 'from-cache'
1716 }; 1738 };
1717 1739
1718 /** @type {!Array<string>} */ 1740 /** @type {!Array<string>} */
1719 Network.NetworkLogView._searchKeys = 1741 Network.NetworkLogView._searchKeys =
1720 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]); 1742 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]);
1721 1743
1722 /** @typedef {function(!SDK.NetworkRequest): boolean} */ 1744 /** @typedef {function(!SDK.NetworkRequest): boolean} */
1723 Network.NetworkLogView.Filter; 1745 Network.NetworkLogView.Filter;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698