Chromium Code Reviews| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 | 464 |
| 465 /** | 465 /** |
| 466 * @return {?string} | 466 * @return {?string} |
| 467 */ | 467 */ |
| 468 sessionId: function() | 468 sessionId: function() |
| 469 { | 469 { |
| 470 return this._sessionId; | 470 return this._sessionId; |
| 471 }, | 471 }, |
| 472 | 472 |
| 473 /** | 473 /** |
| 474 * @param {!WebInspector.TracingModel.Event} event | |
| 474 * @return {?WebInspector.Target} | 475 * @return {?WebInspector.Target} |
| 475 */ | 476 */ |
| 476 target: function() | 477 targetByEvent: function(event) |
| 477 { | 478 { |
| 478 // FIXME: Consider returning null for loaded traces. | 479 // FIXME: Consider returning null for loaded traces. |
| 479 return WebInspector.targetManager.targets()[0]; | 480 var workerId = this._workerIdByThread.get(event.thread); |
| 481 var mainTarget = WebInspector.targetManager.mainTarget(); | |
| 482 return !workerId ? mainTarget : mainTarget.workerManager.targetByWorkerI d(workerId); | |
|
caseq
2016/07/19 22:48:58
please get rid of negation and swap branches. bett
alph
2016/07/19 23:10:29
reversed the negation. Didn't get the second part
| |
| 480 }, | 483 }, |
| 481 | 484 |
| 482 /** | 485 /** |
| 483 * @param {!WebInspector.TracingModel} tracingModel | 486 * @param {!WebInspector.TracingModel} tracingModel |
| 484 * @param {boolean=} produceTraceStartedInPage | 487 * @param {boolean=} produceTraceStartedInPage |
| 485 */ | 488 */ |
| 486 setEvents: function(tracingModel, produceTraceStartedInPage) | 489 setEvents: function(tracingModel, produceTraceStartedInPage) |
| 487 { | 490 { |
| 488 this.reset(); | 491 this.reset(); |
| 489 this._resetProcessingState(); | 492 this._resetProcessingState(); |
| 490 | 493 |
| 491 this._minimumRecordTime = tracingModel.minimumRecordTime(); | 494 this._minimumRecordTime = tracingModel.minimumRecordTime(); |
| 492 this._maximumRecordTime = tracingModel.maximumRecordTime(); | 495 this._maximumRecordTime = tracingModel.maximumRecordTime(); |
| 493 | 496 |
| 494 var metadataEvents = this._processMetadataEvents(tracingModel, !!produce TraceStartedInPage); | 497 var metadataEvents = this._processMetadataEvents(tracingModel, !!produce TraceStartedInPage); |
| 495 var startTime = 0; | 498 var startTime = 0; |
| 496 for (var i = 0, length = metadataEvents.page.length; i < length; i++) { | 499 for (var i = 0, length = metadataEvents.page.length; i < length; i++) { |
| 497 var metaEvent = metadataEvents.page[i]; | 500 var metaEvent = metadataEvents.page[i]; |
| 498 var process = metaEvent.thread.process(); | 501 var process = metaEvent.thread.process(); |
| 499 var endTime = i + 1 < length ? metadataEvents.page[i + 1].startTime : Infinity; | 502 var endTime = i + 1 < length ? metadataEvents.page[i + 1].startTime : Infinity; |
| 500 this._currentPage = metaEvent.args["data"] && metaEvent.args["data"] ["page"]; | 503 this._currentPage = metaEvent.args["data"] && metaEvent.args["data"] ["page"]; |
| 501 for (var thread of process.sortedThreads()) { | 504 for (var thread of process.sortedThreads()) { |
| 502 if (thread.name() === WebInspector.TimelineModel.WorkerThreadNam e && !metadataEvents.workers.some(function(e) { return e.args["data"]["workerThr eadId"] === thread.id(); })) | 505 if (thread.name() === WebInspector.TimelineModel.WorkerThreadNam e) { |
| 503 continue; | 506 var workerMetaEvent = metadataEvents.workers.find(e => e.arg s["data"]["workerThreadId"] === thread.id()); |
| 504 this._processThreadEvents(startTime, endTime, metaEvent.thread, thread); | 507 if (!workerMetaEvent) |
| 508 continue; | |
| 509 var workerId = workerMetaEvent.args["data"]["workerId"]; | |
| 510 if (workerId) | |
| 511 this._workerIdByThread.set(thread, workerId); | |
| 512 } | |
| 513 this._processThreadEvents(startTime, endTime, thread, thread === metaEvent.thread); | |
| 505 } | 514 } |
| 506 startTime = endTime; | 515 startTime = endTime; |
| 507 } | 516 } |
| 508 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | 517 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); |
| 509 | 518 |
| 510 this._processBrowserEvents(tracingModel); | 519 this._processBrowserEvents(tracingModel); |
| 511 this._buildTimelineRecords(); | 520 this._buildTimelineRecords(); |
| 512 this._buildGPUEvents(tracingModel); | 521 this._buildGPUEvents(tracingModel); |
| 513 this._insertFirstPaintEvent(); | 522 this._insertFirstPaintEvent(); |
| 514 this._resetProcessingState(); | 523 this._resetProcessingState(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 this._hadCommitLoad = false; | 720 this._hadCommitLoad = false; |
| 712 this._firstCompositeLayers = null; | 721 this._firstCompositeLayers = null; |
| 713 /** @type {!Set<string>} */ | 722 /** @type {!Set<string>} */ |
| 714 this._knownInputEvents = new Set(); | 723 this._knownInputEvents = new Set(); |
| 715 this._currentPage = null; | 724 this._currentPage = null; |
| 716 }, | 725 }, |
| 717 | 726 |
| 718 /** | 727 /** |
| 719 * @param {number} startTime | 728 * @param {number} startTime |
| 720 * @param {number} endTime | 729 * @param {number} endTime |
| 721 * @param {!WebInspector.TracingModel.Thread} mainThread | |
| 722 * @param {!WebInspector.TracingModel.Thread} thread | 730 * @param {!WebInspector.TracingModel.Thread} thread |
| 731 * @param {boolean} isMainThread | |
| 723 */ | 732 */ |
| 724 _processThreadEvents: function(startTime, endTime, mainThread, thread) | 733 _processThreadEvents: function(startTime, endTime, thread, isMainThread) |
| 725 { | 734 { |
| 726 var events = thread.events(); | 735 var events = thread.events(); |
| 727 var asyncEvents = thread.asyncEvents(); | 736 var asyncEvents = thread.asyncEvents(); |
| 728 | 737 |
| 729 var jsSamples; | 738 var jsSamples; |
| 730 if (Runtime.experiments.isEnabled("timelineTracingJSProfile")) { | 739 if (Runtime.experiments.isEnabled("timelineTracingJSProfile")) { |
| 731 jsSamples = WebInspector.TimelineJSProfileProcessor.processRawV8Samp les(events); | 740 jsSamples = WebInspector.TimelineJSProfileProcessor.processRawV8Samp les(events); |
| 732 } else { | 741 } else { |
| 733 var cpuProfileEvent = events.peekLast(); | 742 var cpuProfileEvent = events.peekLast(); |
| 734 if (cpuProfileEvent && cpuProfileEvent.name === WebInspector.Timelin eModel.RecordType.CpuProfile) { | 743 if (cpuProfileEvent && cpuProfileEvent.name === WebInspector.Timelin eModel.RecordType.CpuProfile) { |
| 735 var cpuProfile = cpuProfileEvent.args["data"]["cpuProfile"]; | 744 var cpuProfile = cpuProfileEvent.args["data"]["cpuProfile"]; |
| 736 if (cpuProfile) { | 745 if (cpuProfile) { |
| 737 var jsProfileModel = new WebInspector.CPUProfileDataModel(cp uProfile); | 746 var jsProfileModel = new WebInspector.CPUProfileDataModel(cp uProfile); |
| 738 this._cpuProfiles.push(jsProfileModel); | 747 this._cpuProfiles.push(jsProfileModel); |
| 739 jsSamples = WebInspector.TimelineJSProfileProcessor.generate TracingEventsFromCpuProfile(jsProfileModel, thread); | 748 jsSamples = WebInspector.TimelineJSProfileProcessor.generate TracingEventsFromCpuProfile(jsProfileModel, thread); |
| 740 } | 749 } |
| 741 } | 750 } |
| 742 } | 751 } |
| 743 | 752 |
| 744 if (jsSamples && jsSamples.length) | 753 if (jsSamples && jsSamples.length) |
| 745 events = events.mergeOrdered(jsSamples, WebInspector.TracingModel.Ev ent.orderedCompareStartTime); | 754 events = events.mergeOrdered(jsSamples, WebInspector.TracingModel.Ev ent.orderedCompareStartTime); |
| 746 if (jsSamples || events.some(function(e) { return e.name === WebInspecto r.TimelineModel.RecordType.JSSample; })) { | 755 if (jsSamples || events.some(function(e) { return e.name === WebInspecto r.TimelineModel.RecordType.JSSample; })) { |
| 747 var jsFrameEvents = WebInspector.TimelineJSProfileProcessor.generate JSFrameEvents(events); | 756 var jsFrameEvents = WebInspector.TimelineJSProfileProcessor.generate JSFrameEvents(events); |
| 748 if (jsFrameEvents && jsFrameEvents.length) | 757 if (jsFrameEvents && jsFrameEvents.length) |
| 749 events = jsFrameEvents.mergeOrdered(events, WebInspector.Tracing Model.Event.orderedCompareStartTime); | 758 events = jsFrameEvents.mergeOrdered(events, WebInspector.Tracing Model.Event.orderedCompareStartTime); |
| 750 } | 759 } |
| 751 | 760 |
| 752 var threadEvents; | 761 var threadEvents; |
| 753 var threadAsyncEventsByGroup; | 762 var threadAsyncEventsByGroup; |
| 754 if (thread === mainThread) { | 763 if (isMainThread) { |
| 755 threadEvents = this._mainThreadEvents; | 764 threadEvents = this._mainThreadEvents; |
| 756 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; | 765 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; |
| 757 } else { | 766 } else { |
| 758 var virtualThread = new WebInspector.TimelineModel.VirtualThread(thr ead.name()); | 767 var virtualThread = new WebInspector.TimelineModel.VirtualThread(thr ead.name()); |
| 759 this._virtualThreads.push(virtualThread); | 768 this._virtualThreads.push(virtualThread); |
| 760 threadEvents = virtualThread.events; | 769 threadEvents = virtualThread.events; |
| 761 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; | 770 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; |
| 762 } | 771 } |
| 763 | 772 |
| 764 this._eventStack = []; | 773 this._eventStack = []; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 1095 /** @type {!Array<!WebInspector.TracingModel.Event>} */ |
| 1087 this._gpuEvents = []; | 1096 this._gpuEvents = []; |
| 1088 /** @type {!Array<!WebInspector.TimelineModel.Record>} */ | 1097 /** @type {!Array<!WebInspector.TimelineModel.Record>} */ |
| 1089 this._eventDividerRecords = []; | 1098 this._eventDividerRecords = []; |
| 1090 /** @type {?string} */ | 1099 /** @type {?string} */ |
| 1091 this._sessionId = null; | 1100 this._sessionId = null; |
| 1092 /** @type {?number} */ | 1101 /** @type {?number} */ |
| 1093 this._mainFrameNodeId = null; | 1102 this._mainFrameNodeId = null; |
| 1094 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ | 1103 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ |
| 1095 this._cpuProfiles = []; | 1104 this._cpuProfiles = []; |
| 1105 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ | |
| 1106 this._workerIdByThread = new WeakMap(); | |
| 1096 this._minimumRecordTime = 0; | 1107 this._minimumRecordTime = 0; |
| 1097 this._maximumRecordTime = 0; | 1108 this._maximumRecordTime = 0; |
| 1098 }, | 1109 }, |
| 1099 | 1110 |
| 1100 /** | 1111 /** |
| 1101 * @return {number} | 1112 * @return {number} |
| 1102 */ | 1113 */ |
| 1103 minimumRecordTime: function() | 1114 minimumRecordTime: function() |
| 1104 { | 1115 { |
| 1105 return this._minimumRecordTime; | 1116 return this._minimumRecordTime; |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1748 if (!id) | 1759 if (!id) |
| 1749 return; | 1760 return; |
| 1750 /** @type {!Map<string, !WebInspector.TracingModel.Event>|undefined} */ | 1761 /** @type {!Map<string, !WebInspector.TracingModel.Event>|undefined} */ |
| 1751 var initiatorMap = this._initiatorByType.get(initiatorType); | 1762 var initiatorMap = this._initiatorByType.get(initiatorType); |
| 1752 if (isInitiator) | 1763 if (isInitiator) |
| 1753 initiatorMap.set(id, event); | 1764 initiatorMap.set(id, event); |
| 1754 else | 1765 else |
| 1755 event.initiator = initiatorMap.get(id) || null; | 1766 event.initiator = initiatorMap.get(id) || null; |
| 1756 } | 1767 } |
| 1757 } | 1768 } |
| OLD | NEW |