| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 /** @type {?string} */ | 961 /** @type {?string} */ |
| 948 this._sessionId = null; | 962 this._sessionId = null; |
| 949 /** @type {?number} */ | 963 /** @type {?number} */ |
| 950 this._mainFrameNodeId = null; | 964 this._mainFrameNodeId = null; |
| 951 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ | 965 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ |
| 952 this._cpuProfiles = []; | 966 this._cpuProfiles = []; |
| 953 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ | 967 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ |
| 954 this._workerIdByThread = new WeakMap(); | 968 this._workerIdByThread = new WeakMap(); |
| 955 /** @type {!Map<string, !WebInspector.TimelineModel.PageFrame>} */ | 969 /** @type {!Map<string, !WebInspector.TimelineModel.PageFrame>} */ |
| 956 this._pageFrames = new Map(); | 970 this._pageFrames = new Map(); |
| 971 /** @type {!Map<string, !Array<!WebInspector.TracingModel.Event>>} */ |
| 972 this._eventsByFrame = new Map(); |
| 957 | 973 |
| 958 this._minimumRecordTime = 0; | 974 this._minimumRecordTime = 0; |
| 959 this._maximumRecordTime = 0; | 975 this._maximumRecordTime = 0; |
| 960 } | 976 } |
| 961 | 977 |
| 962 /** | 978 /** |
| 963 * @return {number} | 979 * @return {number} |
| 964 */ | 980 */ |
| 965 minimumRecordTime() { | 981 minimumRecordTime() { |
| 966 return this._minimumRecordTime; | 982 return this._minimumRecordTime; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 } | 1046 } |
| 1031 | 1047 |
| 1032 /** | 1048 /** |
| 1033 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 1049 * @return {!Array.<!WebInspector.TimelineModel.Record>} |
| 1034 */ | 1050 */ |
| 1035 eventDividerRecords() { | 1051 eventDividerRecords() { |
| 1036 return this._eventDividerRecords; | 1052 return this._eventDividerRecords; |
| 1037 } | 1053 } |
| 1038 | 1054 |
| 1039 /** | 1055 /** |
| 1056 * @return {!Array<!WebInspector.TimelineModel.PageFrame>} |
| 1057 */ |
| 1058 rootFrames() { |
| 1059 return Array.from(this._pageFrames.values()).filter(frame => !frame.parent); |
| 1060 } |
| 1061 |
| 1062 /** |
| 1040 * @param {string} frameId | 1063 * @param {string} frameId |
| 1041 * @return {?WebInspector.TimelineModel.PageFrame} | 1064 * @return {?WebInspector.TimelineModel.PageFrame} |
| 1042 */ | 1065 */ |
| 1043 pageFrameById(frameId) { | 1066 pageFrameById(frameId) { |
| 1044 return frameId ? this._pageFrames.get(frameId) || null : null; | 1067 return frameId ? this._pageFrames.get(frameId) || null : null; |
| 1045 } | 1068 } |
| 1046 | 1069 |
| 1047 /** | 1070 /** |
| 1071 * @param {string} frameId |
| 1072 * @return {!Array<!WebInspector.TracingModel.Event>} |
| 1073 */ |
| 1074 eventsForFrame(frameId) { |
| 1075 return this._eventsByFrame.get(frameId) || []; |
| 1076 } |
| 1077 |
| 1078 /** |
| 1048 * @return {!Array<!WebInspector.TimelineModel.NetworkRequest>} | 1079 * @return {!Array<!WebInspector.TimelineModel.NetworkRequest>} |
| 1049 */ | 1080 */ |
| 1050 networkRequests() { | 1081 networkRequests() { |
| 1051 /** @type {!Map<string,!WebInspector.TimelineModel.NetworkRequest>} */ | 1082 /** @type {!Map<string,!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1052 var requests = new Map(); | 1083 var requests = new Map(); |
| 1053 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1084 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1054 var requestsList = []; | 1085 var requestsList = []; |
| 1055 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1086 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ |
| 1056 var zeroStartRequestsList = []; | 1087 var zeroStartRequestsList = []; |
| 1057 var types = WebInspector.TimelineModel.RecordType; | 1088 var types = WebInspector.TimelineModel.RecordType; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 | 1408 |
| 1378 /** | 1409 /** |
| 1379 * @param {!WebInspector.TimelineModel.PageFrame} child | 1410 * @param {!WebInspector.TimelineModel.PageFrame} child |
| 1380 */ | 1411 */ |
| 1381 addChild(child) { | 1412 addChild(child) { |
| 1382 this.children.push(child); | 1413 this.children.push(child); |
| 1383 child.parent = this; | 1414 child.parent = this; |
| 1384 } | 1415 } |
| 1385 }; | 1416 }; |
| 1386 | 1417 |
| 1418 WebInspector.TimelineModel.PageFrame.mainFrameId = ''; |
| 1419 |
| 1420 |
| 1387 /** | 1421 /** |
| 1388 * @unrestricted | 1422 * @unrestricted |
| 1389 */ | 1423 */ |
| 1390 WebInspector.TimelineModel.NetworkRequest = class { | 1424 WebInspector.TimelineModel.NetworkRequest = class { |
| 1391 /** | 1425 /** |
| 1392 * @param {!WebInspector.TracingModel.Event} event | 1426 * @param {!WebInspector.TracingModel.Event} event |
| 1393 */ | 1427 */ |
| 1394 constructor(event) { | 1428 constructor(event) { |
| 1395 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; | 1429 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; |
| 1396 this.endTime = Infinity; | 1430 this.endTime = Infinity; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 static forEvent(event) { | 1979 static forEvent(event) { |
| 1946 var data = event[WebInspector.TimelineData._symbol]; | 1980 var data = event[WebInspector.TimelineData._symbol]; |
| 1947 if (!data) { | 1981 if (!data) { |
| 1948 data = new WebInspector.TimelineData(); | 1982 data = new WebInspector.TimelineData(); |
| 1949 event[WebInspector.TimelineData._symbol] = data; | 1983 event[WebInspector.TimelineData._symbol] = data; |
| 1950 } | 1984 } |
| 1951 return data; | 1985 return data; |
| 1952 } | 1986 } |
| 1953 }; | 1987 }; |
| 1954 | 1988 |
| 1955 WebInspector.TimelineData.mainFrameId = ''; | |
| 1956 WebInspector.TimelineData._symbol = Symbol('timelineData'); | 1989 WebInspector.TimelineData._symbol = Symbol('timelineData'); |
| OLD | NEW |