| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 /** | 555 /** |
| 556 * @param {!WebInspector.TracingModel} tracingModel | 556 * @param {!WebInspector.TracingModel} tracingModel |
| 557 * @param {number} startTime | 557 * @param {number} startTime |
| 558 * @param {number} endTime | 558 * @param {number} endTime |
| 559 * @param {!WebInspector.TracingModel.Thread} thread | 559 * @param {!WebInspector.TracingModel.Thread} thread |
| 560 * @param {boolean} isMainThread | 560 * @param {boolean} isMainThread |
| 561 */ | 561 */ |
| 562 _processThreadEvents(tracingModel, startTime, endTime, thread, isMainThread) { | 562 _processThreadEvents(tracingModel, startTime, endTime, thread, isMainThread) { |
| 563 var events = this._injectJSFrameEvents(tracingModel, thread); | 563 var events = this._injectJSFrameEvents(tracingModel, thread); |
| 564 var asyncEvents = thread.asyncEvents(); | 564 var asyncEvents = thread.asyncEvents(); |
| 565 var groupByFrame = isMainThread && Runtime.experiments.isEnabled('timelinePe
rFrameTrack'); |
| 565 | 566 |
| 566 var threadEvents; | 567 var threadEvents; |
| 567 var threadAsyncEventsByGroup; | 568 var threadAsyncEventsByGroup; |
| 568 if (isMainThread) { | 569 if (isMainThread) { |
| 569 threadEvents = this._mainThreadEvents; | 570 threadEvents = this._mainThreadEvents; |
| 570 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; | 571 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; |
| 571 } else { | 572 } else { |
| 572 var virtualThread = new WebInspector.TimelineModel.VirtualThread(thread.na
me()); | 573 var virtualThread = new WebInspector.TimelineModel.VirtualThread(thread.na
me()); |
| 573 this._virtualThreads.push(virtualThread); | 574 this._virtualThreads.push(virtualThread); |
| 574 threadEvents = virtualThread.events; | 575 threadEvents = virtualThread.events; |
| 575 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; | 576 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; |
| 576 } | 577 } |
| 577 | 578 |
| 578 this._eventStack = []; | 579 this._eventStack = []; |
| 579 var i = events.lowerBound(startTime, (time, event) => time - event.startTime
); | 580 var i = events.lowerBound(startTime, (time, event) => time - event.startTime
); |
| 580 var length = events.length; | 581 var length = events.length; |
| 581 for (; i < length; i++) { | 582 for (; i < length; i++) { |
| 582 var event = events[i]; | 583 var event = events[i]; |
| 583 if (endTime && event.startTime >= endTime) | 584 if (endTime && event.startTime >= endTime) |
| 584 break; | 585 break; |
| 585 if (!this._processEvent(event)) | 586 if (!this._processEvent(event)) |
| 586 continue; | 587 continue; |
| 588 if (groupByFrame) { |
| 589 var frameId = WebInspector.TimelineData.forEvent(event).frameId; |
| 590 var pageFrame = frameId && this._pageFrames.get(frameId); |
| 591 var isMainFrame = !frameId || !pageFrame || !pageFrame.parent; |
| 592 if (isMainFrame) |
| 593 frameId = WebInspector.TimelineModel.PageFrame.mainFrameId; |
| 594 var frameEvents = this._eventsByFrame.get(frameId); |
| 595 if (!frameEvents) { |
| 596 frameEvents = []; |
| 597 this._eventsByFrame.set(frameId, frameEvents); |
| 598 } |
| 599 frameEvents.push(event); |
| 600 } |
| 587 threadEvents.push(event); | 601 threadEvents.push(event); |
| 588 this._inspectedTargetEvents.push(event); | 602 this._inspectedTargetEvents.push(event); |
| 589 } | 603 } |
| 590 this._processAsyncEvents(threadAsyncEventsByGroup, asyncEvents, startTime, e
ndTime); | 604 this._processAsyncEvents(threadAsyncEventsByGroup, asyncEvents, startTime, e
ndTime); |
| 591 // Pretend the compositor's async events are on the main thread. | 605 // Pretend the compositor's async events are on the main thread. |
| 592 if (thread.name() === 'Compositor') { | 606 if (thread.name() === 'Compositor') { |
| 593 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, threadAsyncEven
tsByGroup); | 607 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, threadAsyncEven
tsByGroup); |
| 594 threadAsyncEventsByGroup.clear(); | 608 threadAsyncEventsByGroup.clear(); |
| 595 } | 609 } |
| 596 } | 610 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // TraceEvents come with 1-based line & column numbers. The frontend code | 657 // TraceEvents come with 1-based line & column numbers. The frontend code |
| 644 // requires 0-based ones. Adjust the values. | 658 // requires 0-based ones. Adjust the values. |
| 645 for (var i = 0; i < timelineData.stackTrace.length; ++i) { | 659 for (var i = 0; i < timelineData.stackTrace.length; ++i) { |
| 646 --timelineData.stackTrace[i].lineNumber; | 660 --timelineData.stackTrace[i].lineNumber; |
| 647 --timelineData.stackTrace[i].columnNumber; | 661 --timelineData.stackTrace[i].columnNumber; |
| 648 } | 662 } |
| 649 } | 663 } |
| 650 var pageFrameId = WebInspector.TimelineModel.eventFrameId(event); | 664 var pageFrameId = WebInspector.TimelineModel.eventFrameId(event); |
| 651 if (!pageFrameId && eventStack.length) | 665 if (!pageFrameId && eventStack.length) |
| 652 pageFrameId = WebInspector.TimelineData.forEvent(eventStack.peekLast()).fr
ameId; | 666 pageFrameId = WebInspector.TimelineData.forEvent(eventStack.peekLast()).fr
ameId; |
| 653 timelineData.frameId = pageFrameId || WebInspector.TimelineData.mainFrameId; | 667 timelineData.frameId = pageFrameId || WebInspector.TimelineModel.PageFrame.m
ainFrameId; |
| 654 this._asyncEventTracker.processEvent(event); | 668 this._asyncEventTracker.processEvent(event); |
| 655 switch (event.name) { | 669 switch (event.name) { |
| 656 case recordTypes.ResourceSendRequest: | 670 case recordTypes.ResourceSendRequest: |
| 657 case recordTypes.WebSocketCreate: | 671 case recordTypes.WebSocketCreate: |
| 658 timelineData.setInitiator(eventStack.peekLast() || null); | 672 timelineData.setInitiator(eventStack.peekLast() || null); |
| 659 timelineData.url = eventData['url']; | 673 timelineData.url = eventData['url']; |
| 660 break; | 674 break; |
| 661 | 675 |
| 662 case recordTypes.ScheduleStyleRecalculation: | 676 case recordTypes.ScheduleStyleRecalculation: |
| 663 this._lastScheduleStyleRecalculation[eventData['frame']] = event; | 677 this._lastScheduleStyleRecalculation[eventData['frame']] = event; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 timelineData.backendNodeId = paintImageData.backendNodeId; | 788 timelineData.backendNodeId = paintImageData.backendNodeId; |
| 775 timelineData.url = paintImageData.url; | 789 timelineData.url = paintImageData.url; |
| 776 break; | 790 break; |
| 777 | 791 |
| 778 case recordTypes.DrawLazyPixelRef: | 792 case recordTypes.DrawLazyPixelRef: |
| 779 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); | 793 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); |
| 780 if (!paintImageEvent) | 794 if (!paintImageEvent) |
| 781 break; | 795 break; |
| 782 this._paintImageEventByPixelRefId[event.args['LazyPixelRef']] = paintIma
geEvent; | 796 this._paintImageEventByPixelRefId[event.args['LazyPixelRef']] = paintIma
geEvent; |
| 783 var paintImageData = WebInspector.TimelineData.forEvent(paintImageEvent)
; | 797 var paintImageData = WebInspector.TimelineData.forEvent(paintImageEvent)
; |
| 784 event.backendNodeId = paintImageData.backendNodeId; | 798 timelineData.backendNodeId = paintImageData.backendNodeId; |
| 785 event.url = paintImageData.url; | 799 timelineData.url = paintImageData.url; |
| 786 break; | 800 break; |
| 787 | 801 |
| 788 case recordTypes.MarkDOMContent: | 802 case recordTypes.MarkDOMContent: |
| 789 case recordTypes.MarkLoad: | 803 case recordTypes.MarkLoad: |
| 790 var page = eventData['page']; | 804 var page = eventData['page']; |
| 791 if (page && page !== this._currentPage) | 805 if (page && page !== this._currentPage) |
| 792 return false; | 806 return false; |
| 793 break; | 807 break; |
| 794 | 808 |
| 795 case recordTypes.CommitLoad: | 809 case recordTypes.CommitLoad: |
| 796 var frameId = WebInspector.TimelineModel.eventFrameId(event); | 810 var frameId = WebInspector.TimelineModel.eventFrameId(event); |
| 797 var pageFrame = this._pageFrames.get(frameId); | 811 var pageFrame = this._pageFrames.get(frameId); |
| 798 if (pageFrame) { | 812 if (pageFrame) |
| 799 pageFrame.url = eventData.url || ''; | 813 pageFrame.update(eventData.name || '', eventData.url || ''); |
| 800 pageFrame.name = eventData.name || ''; | 814 else |
| 801 } else { | |
| 802 this._addPageFrame(event, eventData); | 815 this._addPageFrame(event, eventData); |
| 803 } | |
| 804 var page = eventData['page']; | 816 var page = eventData['page']; |
| 805 if (page && page !== this._currentPage) | 817 if (page && page !== this._currentPage) |
| 806 return false; | 818 return false; |
| 807 if (!eventData['isMainFrame']) | 819 if (!eventData['isMainFrame']) |
| 808 break; | 820 break; |
| 809 this._hadCommitLoad = true; | 821 this._hadCommitLoad = true; |
| 810 this._firstCompositeLayers = null; | 822 this._firstCompositeLayers = null; |
| 811 break; | 823 break; |
| 812 | 824 |
| 813 case recordTypes.CompositeLayers: | 825 case recordTypes.CompositeLayers: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 /** @type {?string} */ | 959 /** @type {?string} */ |
| 948 this._sessionId = null; | 960 this._sessionId = null; |
| 949 /** @type {?number} */ | 961 /** @type {?number} */ |
| 950 this._mainFrameNodeId = null; | 962 this._mainFrameNodeId = null; |
| 951 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ | 963 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ |
| 952 this._cpuProfiles = []; | 964 this._cpuProfiles = []; |
| 953 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ | 965 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ |
| 954 this._workerIdByThread = new WeakMap(); | 966 this._workerIdByThread = new WeakMap(); |
| 955 /** @type {!Map<string, !WebInspector.TimelineModel.PageFrame>} */ | 967 /** @type {!Map<string, !WebInspector.TimelineModel.PageFrame>} */ |
| 956 this._pageFrames = new Map(); | 968 this._pageFrames = new Map(); |
| 969 /** @type {!Map<string, !Array<!WebInspector.TracingModel.Event>>} */ |
| 970 this._eventsByFrame = new Map(); |
| 957 | 971 |
| 958 this._minimumRecordTime = 0; | 972 this._minimumRecordTime = 0; |
| 959 this._maximumRecordTime = 0; | 973 this._maximumRecordTime = 0; |
| 960 } | 974 } |
| 961 | 975 |
| 962 /** | 976 /** |
| 963 * @return {number} | 977 * @return {number} |
| 964 */ | 978 */ |
| 965 minimumRecordTime() { | 979 minimumRecordTime() { |
| 966 return this._minimumRecordTime; | 980 return this._minimumRecordTime; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 } | 1044 } |
| 1031 | 1045 |
| 1032 /** | 1046 /** |
| 1033 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 1047 * @return {!Array.<!WebInspector.TimelineModel.Record>} |
| 1034 */ | 1048 */ |
| 1035 eventDividerRecords() { | 1049 eventDividerRecords() { |
| 1036 return this._eventDividerRecords; | 1050 return this._eventDividerRecords; |
| 1037 } | 1051 } |
| 1038 | 1052 |
| 1039 /** | 1053 /** |
| 1054 * @return {!Array<!WebInspector.TimelineModel.PageFrame>} |
| 1055 */ |
| 1056 rootFrames() { |
| 1057 return Array.from(this._pageFrames.values()).filter(frame => !frame.parent); |
| 1058 } |
| 1059 |
| 1060 /** |
| 1040 * @param {string} frameId | 1061 * @param {string} frameId |
| 1041 * @return {?WebInspector.TimelineModel.PageFrame} | 1062 * @return {?WebInspector.TimelineModel.PageFrame} |
| 1042 */ | 1063 */ |
| 1043 pageFrameById(frameId) { | 1064 pageFrameById(frameId) { |
| 1044 return frameId ? this._pageFrames.get(frameId) || null : null; | 1065 return frameId ? this._pageFrames.get(frameId) || null : null; |
| 1045 } | 1066 } |
| 1046 | 1067 |
| 1047 /** | 1068 /** |
| 1069 * @param {string} frameId |
| 1070 * @return {!Array<!WebInspector.TracingModel.Event>} |
| 1071 */ |
| 1072 eventsForFrame(frameId) { |
| 1073 return this._eventsByFrame.get(frameId) || []; |
| 1074 } |
| 1075 |
| 1076 /** |
| 1048 * @return {!Array<!WebInspector.TimelineModel.NetworkRequest>} | 1077 * @return {!Array<!WebInspector.TimelineModel.NetworkRequest>} |
| 1049 */ | 1078 */ |
| 1050 networkRequests() { | 1079 networkRequests() { |
| 1051 /** @type {!Map<string,!WebInspector.TimelineModel.NetworkRequest>} */ | 1080 /** @type {!Map<string,!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1052 var requests = new Map(); | 1081 var requests = new Map(); |
| 1053 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1082 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1054 var requestsList = []; | 1083 var requestsList = []; |
| 1055 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1084 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1056 var zeroStartRequestsList = []; | 1085 var zeroStartRequestsList = []; |
| 1057 var types = WebInspector.TimelineModel.RecordType; | 1086 var types = WebInspector.TimelineModel.RecordType; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 | 1387 |
| 1359 | 1388 |
| 1360 WebInspector.TimelineModel.PageFrame = class { | 1389 WebInspector.TimelineModel.PageFrame = class { |
| 1361 /** | 1390 /** |
| 1362 * @param {?WebInspector.Target} target | 1391 * @param {?WebInspector.Target} target |
| 1363 * @param {number} pid | 1392 * @param {number} pid |
| 1364 * @param {!Object} payload | 1393 * @param {!Object} payload |
| 1365 */ | 1394 */ |
| 1366 constructor(target, pid, payload) { | 1395 constructor(target, pid, payload) { |
| 1367 this.frameId = payload['frame']; | 1396 this.frameId = payload['frame']; |
| 1368 this.url = payload['url']; | 1397 this.url = payload['url'] || ''; |
| 1369 this.name = payload['name']; | 1398 this.name = payload['name']; |
| 1370 this.processId = pid; | 1399 this.processId = pid; |
| 1371 this.children = []; | 1400 this.children = []; |
| 1372 /** @type {?WebInspector.TimelineModel.PageFrame} */ | 1401 /** @type {?WebInspector.TimelineModel.PageFrame} */ |
| 1373 this.parent = null; | 1402 this.parent = null; |
| 1374 this.id = `${this.processId}.${this.frameId}`; | 1403 this.id = `${this.processId}.${this.frameId}`; |
| 1375 this.ownerNode = target && payload['nodeId'] ? new WebInspector.DeferredDOMN
ode(target, payload['nodeId']) : null; | 1404 this.ownerNode = target && payload['nodeId'] ? new WebInspector.DeferredDOMN
ode(target, payload['nodeId']) : null; |
| 1376 } | 1405 } |
| 1377 | 1406 |
| 1378 /** | 1407 /** |
| 1408 * @param {string} name |
| 1409 * @param {string} url |
| 1410 */ |
| 1411 update(name, url) { |
| 1412 this.name = name; |
| 1413 this.url = url; |
| 1414 } |
| 1415 |
| 1416 /** |
| 1379 * @param {!WebInspector.TimelineModel.PageFrame} child | 1417 * @param {!WebInspector.TimelineModel.PageFrame} child |
| 1380 */ | 1418 */ |
| 1381 addChild(child) { | 1419 addChild(child) { |
| 1382 this.children.push(child); | 1420 this.children.push(child); |
| 1383 child.parent = this; | 1421 child.parent = this; |
| 1384 } | 1422 } |
| 1385 }; | 1423 }; |
| 1386 | 1424 |
| 1425 WebInspector.TimelineModel.PageFrame.mainFrameId = ''; |
| 1426 |
| 1427 |
| 1387 /** | 1428 /** |
| 1388 * @unrestricted | 1429 * @unrestricted |
| 1389 */ | 1430 */ |
| 1390 WebInspector.TimelineModel.NetworkRequest = class { | 1431 WebInspector.TimelineModel.NetworkRequest = class { |
| 1391 /** | 1432 /** |
| 1392 * @param {!WebInspector.TracingModel.Event} event | 1433 * @param {!WebInspector.TracingModel.Event} event |
| 1393 */ | 1434 */ |
| 1394 constructor(event) { | 1435 constructor(event) { |
| 1395 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; | 1436 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; |
| 1396 this.endTime = Infinity; | 1437 this.endTime = Infinity; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 static forEvent(event) { | 1986 static forEvent(event) { |
| 1946 var data = event[WebInspector.TimelineData._symbol]; | 1987 var data = event[WebInspector.TimelineData._symbol]; |
| 1947 if (!data) { | 1988 if (!data) { |
| 1948 data = new WebInspector.TimelineData(); | 1989 data = new WebInspector.TimelineData(); |
| 1949 event[WebInspector.TimelineData._symbol] = data; | 1990 event[WebInspector.TimelineData._symbol] = data; |
| 1950 } | 1991 } |
| 1951 return data; | 1992 return data; |
| 1952 } | 1993 } |
| 1953 }; | 1994 }; |
| 1954 | 1995 |
| 1955 WebInspector.TimelineData.mainFrameId = ''; | |
| 1956 WebInspector.TimelineData._symbol = Symbol('timelineData'); | 1996 WebInspector.TimelineData._symbol = Symbol('timelineData'); |
| OLD | NEW |