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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 WebInspector.TimelineModel.Events = { | 157 WebInspector.TimelineModel.Events = { |
158 RecordsCleared: "RecordsCleared", | 158 RecordsCleared: "RecordsCleared", |
159 RecordingStarted: "RecordingStarted", | 159 RecordingStarted: "RecordingStarted", |
160 RecordingStopped: "RecordingStopped", | 160 RecordingStopped: "RecordingStopped", |
161 RecordFilterChanged: "RecordFilterChanged", | 161 RecordFilterChanged: "RecordFilterChanged", |
162 BufferUsage: "BufferUsage", | 162 BufferUsage: "BufferUsage", |
163 RetrieveEventsProgress: "RetrieveEventsProgress" | 163 RetrieveEventsProgress: "RetrieveEventsProgress" |
164 } | 164 } |
165 | 165 |
166 WebInspector.TimelineModel.MainThreadName = "main"; | 166 WebInspector.TimelineModel.MainThreadName = "main"; |
167 | |
168 WebInspector.TimelineModel.WorkerThreadName = "DedicatedWorker Thread"; | 167 WebInspector.TimelineModel.WorkerThreadName = "DedicatedWorker Thread"; |
168 WebInspector.TimelineModel.RendererMainThreadName = "CrRendererMain"; | |
169 | 169 |
170 /** | 170 /** |
171 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 171 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
172 * @param {function(!WebInspector.TracingModel.Event)} onStartEvent | 172 * @param {function(!WebInspector.TracingModel.Event)} onStartEvent |
173 * @param {function(!WebInspector.TracingModel.Event)} onEndEvent | 173 * @param {function(!WebInspector.TracingModel.Event)} onEndEvent |
174 * @param {function(!WebInspector.TracingModel.Event,?WebInspector.TracingModel. Event)=} onInstantEvent | 174 * @param {function(!WebInspector.TracingModel.Event,?WebInspector.TracingModel. Event)=} onInstantEvent |
175 */ | 175 */ |
176 WebInspector.TimelineModel.forEachEvent = function(events, onStartEvent, onEndEv ent, onInstantEvent) | 176 WebInspector.TimelineModel.forEachEvent = function(events, onStartEvent, onEndEv ent, onInstantEvent) |
177 { | 177 { |
178 var stack = []; | 178 var stack = []; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 if (postOrderCallback && postOrderCallback(record, depth)) | 217 if (postOrderCallback && postOrderCallback(record, depth)) |
218 return true; | 218 return true; |
219 } | 219 } |
220 return false; | 220 return false; |
221 } | 221 } |
222 return processRecords(recordsArray, 0); | 222 return processRecords(recordsArray, 0); |
223 } | 223 } |
224 | 224 |
225 WebInspector.TimelineModel.TransferChunkLengthBytes = 5000000; | 225 WebInspector.TimelineModel.TransferChunkLengthBytes = 5000000; |
226 | 226 |
227 WebInspector.TimelineModel.DevToolsMetadataEvent = { | |
228 TracingStartedInPage: "TracingStartedInPage", | |
229 TracingSessionIdForWorker: "TracingSessionIdForWorker", | |
230 }; | |
231 | |
227 /** | 232 /** |
228 * @constructor | 233 * @constructor |
229 * @param {string} name | 234 * @param {string} name |
230 */ | 235 */ |
231 WebInspector.TimelineModel.VirtualThread = function(name) | 236 WebInspector.TimelineModel.VirtualThread = function(name) |
232 { | 237 { |
233 this.name = name; | 238 this.name = name; |
234 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 239 /** @type {!Array<!WebInspector.TracingModel.Event>} */ |
235 this.events = []; | 240 this.events = []; |
236 /** @type {!Map<!WebInspector.AsyncEventGroup, !Array<!WebInspector.TracingM odel.AsyncEvent>>} */ | 241 /** @type {!Map<!WebInspector.AsyncEventGroup, !Array<!WebInspector.TracingM odel.AsyncEvent>>} */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 { | 293 { |
289 var initiator = this._event.initiator; | 294 var initiator = this._event.initiator; |
290 return initiator ? initiator._timelineRecord : null; | 295 return initiator ? initiator._timelineRecord : null; |
291 }, | 296 }, |
292 | 297 |
293 /** | 298 /** |
294 * @return {?WebInspector.Target} | 299 * @return {?WebInspector.Target} |
295 */ | 300 */ |
296 target: function() | 301 target: function() |
297 { | 302 { |
298 return this._event.thread.target(); | 303 var threadName = this._event.thread.name(); |
304 //FIXME: correctly specify target | |
305 return threadName === WebInspector.TimelineModel.RendererMainThreadName ? WebInspector.targetManager.targets()[0] : null; | |
alph
2015/09/01 21:11:41
nit: please put back "|| null" part. There might b
| |
299 }, | 306 }, |
300 | 307 |
301 /** | 308 /** |
302 * @return {number} | 309 * @return {number} |
303 */ | 310 */ |
304 selfTime: function() | 311 selfTime: function() |
305 { | 312 { |
306 return this._event.selfTime; | 313 return this._event.selfTime; |
307 }, | 314 }, |
308 | 315 |
(...skipping 11 matching lines...) Expand all Loading... | |
320 startTime: function() | 327 startTime: function() |
321 { | 328 { |
322 return this._event.startTime; | 329 return this._event.startTime; |
323 }, | 330 }, |
324 | 331 |
325 /** | 332 /** |
326 * @return {string} | 333 * @return {string} |
327 */ | 334 */ |
328 thread: function() | 335 thread: function() |
329 { | 336 { |
330 if (this._event.thread.name() === "CrRendererMain") | 337 if (this._event.thread.name() === WebInspector.TimelineModel.RendererMai nThreadName) |
331 return WebInspector.TimelineModel.MainThreadName; | 338 return WebInspector.TimelineModel.MainThreadName; |
332 return this._event.thread.name(); | 339 return this._event.thread.name(); |
333 }, | 340 }, |
334 | 341 |
335 /** | 342 /** |
336 * @return {number} | 343 * @return {number} |
337 */ | 344 */ |
338 endTime: function() | 345 endTime: function() |
339 { | 346 { |
340 return this._endTime || this._event.endTime || this._event.startTime; | 347 return this._endTime || this._event.endTime || this._event.startTime; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 | 448 |
442 /** | 449 /** |
443 * @return {!WebInspector.TimelineModel} | 450 * @return {!WebInspector.TimelineModel} |
444 */ | 451 */ |
445 timelineModel: function() | 452 timelineModel: function() |
446 { | 453 { |
447 return this._model; | 454 return this._model; |
448 } | 455 } |
449 } | 456 } |
450 | 457 |
458 /** @typedef {!{page: !Array<!WebInspector.TracingModel.Event>, workers: !Array< !WebInspector.TracingModel.Event>}} */ | |
459 WebInspector.TimelineModel.MetadataEvents; | |
460 | |
451 WebInspector.TimelineModel.prototype = { | 461 WebInspector.TimelineModel.prototype = { |
452 /** | 462 /** |
453 * @param {boolean} captureCauses | 463 * @param {boolean} captureCauses |
454 * @param {boolean} enableJSSampling | 464 * @param {boolean} enableJSSampling |
455 * @param {boolean} captureMemory | 465 * @param {boolean} captureMemory |
456 * @param {boolean} capturePictures | 466 * @param {boolean} capturePictures |
457 * @param {boolean} captureFilmStrip | 467 * @param {boolean} captureFilmStrip |
458 */ | 468 */ |
459 startRecording: function(captureCauses, enableJSSampling, captureMemory, cap turePictures, captureFilmStrip) | 469 startRecording: function(captureCauses, enableJSSampling, captureMemory, cap turePictures, captureFilmStrip) |
460 { | 470 { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 | 581 |
572 /** | 582 /** |
573 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 583 * @return {!Array.<!WebInspector.TimelineModel.Record>} |
574 */ | 584 */ |
575 records: function() | 585 records: function() |
576 { | 586 { |
577 return this._records; | 587 return this._records; |
578 }, | 588 }, |
579 | 589 |
580 /** | 590 /** |
591 * @return {?string} | |
592 */ | |
593 sessionId: function() | |
594 { | |
595 return this._sessionId; | |
596 }, | |
597 | |
598 /** | |
581 * @return {?WebInspector.Target} | 599 * @return {?WebInspector.Target} |
582 */ | 600 */ |
583 target: function() | 601 target: function() |
584 { | 602 { |
585 // FIXME: Consider returning null for loaded traces. | 603 // FIXME: Consider returning null for loaded traces. |
586 return this._targets[0]; | 604 return this._targets[0]; |
587 }, | 605 }, |
588 | 606 |
589 /** | 607 /** |
590 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | 608 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
750 { | 768 { |
751 if (!cpuProfile) | 769 if (!cpuProfile) |
752 return; | 770 return; |
753 if (!this._cpuProfiles) | 771 if (!this._cpuProfiles) |
754 this._cpuProfiles = new Map(); | 772 this._cpuProfiles = new Map(); |
755 this._cpuProfiles.set(targetId, cpuProfile); | 773 this._cpuProfiles.set(targetId, cpuProfile); |
756 }, | 774 }, |
757 | 775 |
758 _didStopRecordingTraceEvents: function() | 776 _didStopRecordingTraceEvents: function() |
759 { | 777 { |
760 this._injectCpuProfileEvents(); | 778 var metadataEvents = this._processMetadataEvents(); |
779 this._injectCpuProfileEvents(metadataEvents); | |
761 this._tracingModel.tracingComplete(); | 780 this._tracingModel.tracingComplete(); |
762 | 781 |
763 var metaEvents = this._tracingModel.devtoolsPageMetadataEvents(); | |
764 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); | |
765 | |
766 this._resetProcessingState(); | 782 this._resetProcessingState(); |
767 var startTime = 0; | 783 var startTime = 0; |
768 for (var i = 0, length = metaEvents.length; i < length; i++) { | 784 for (var i = 0, length = metadataEvents.page.length; i < length; i++) { |
769 var metaEvent = metaEvents[i]; | 785 var metaEvent = metadataEvents.page[i]; |
770 var process = metaEvent.thread.process(); | 786 var process = metaEvent.thread.process(); |
771 var endTime = i + 1 < length ? metaEvents[i + 1].startTime : Infinit y; | 787 var endTime = i + 1 < length ? metadataEvents.page[i + 1].startTime : Infinity; |
772 this._currentPage = metaEvent.args["data"] && metaEvent.args["data"] ["page"]; | 788 this._currentPage = metaEvent.args["data"] && metaEvent.args["data"] ["page"]; |
773 for (var thread of process.sortedThreads()) { | 789 for (var thread of process.sortedThreads()) { |
774 if (thread.name() === WebInspector.TimelineModel.WorkerThreadNam e && !workerMetadataEvents.some(function(e) { return e.args["data"]["workerThrea dId"] === thread.id(); })) | 790 if (thread.name() === WebInspector.TimelineModel.WorkerThreadNam e && !metadataEvents.workers.some(function(e) { return e.args["data"]["workerThr eadId"] === thread.id(); })) |
775 continue; | 791 continue; |
776 this._processThreadEvents(startTime, endTime, metaEvent.thread, thread); | 792 this._processThreadEvents(startTime, endTime, metaEvent.thread, thread); |
777 } | 793 } |
778 startTime = endTime; | 794 startTime = endTime; |
779 } | 795 } |
780 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | 796 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); |
781 | 797 |
782 this._cpuProfiles = null; | 798 this._cpuProfiles = null; |
783 this._buildTimelineRecords(); | 799 this._buildTimelineRecords(); |
784 this._buildGPUTasks(); | 800 this._buildGPUTasks(); |
785 this._insertFirstPaintEvent(); | 801 this._insertFirstPaintEvent(); |
786 this._resetProcessingState(); | 802 this._resetProcessingState(); |
787 | 803 |
788 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 804 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
789 }, | 805 }, |
790 | 806 |
791 /** | 807 /** |
808 * @return {!WebInspector.TimelineModel.MetadataEvents} | |
809 */ | |
810 _processMetadataEvents: function() | |
811 { | |
812 var metadataEvents = this._tracingModel.devToolsMetadataEvents(); | |
813 | |
814 var pageDevToolsMetadataEvents = []; | |
815 var workersDevToolsMetadataEvents = []; | |
816 for (var event of metadataEvents) { | |
817 if (event.name === WebInspector.TimelineModel.DevToolsMetadataEvent. TracingStartedInPage) | |
818 pageDevToolsMetadataEvents.push(event); | |
819 else if (event.name === WebInspector.TimelineModel.DevToolsMetadataE vent.TracingSessionIdForWorker) | |
820 workersDevToolsMetadataEvents.push(event); | |
821 } | |
822 if (!pageDevToolsMetadataEvents.length) { | |
823 // The trace is probably coming not from DevTools. Make a mock Metad ata event. | |
824 var pageMetaEvent = this._loadedFromFile ? this._makeMockPageMetadat aEvent() : null; | |
825 if (!pageMetaEvent) { | |
826 console.error(WebInspector.TimelineModel.DevToolsMetadataEvent.T racingStartedInPage + " event not found."); | |
827 return {page: [], workers: []}; | |
828 } | |
829 pageDevToolsMetadataEvents.push(pageMetaEvent); | |
830 } | |
831 var sessionId = pageDevToolsMetadataEvents[0].args["sessionId"] || pageD evToolsMetadataEvents[0].args["data"]["sessionId"]; | |
832 this._sessionId = sessionId; | |
833 | |
834 var mismatchingIds = new Set(); | |
835 function checkSessionId(event) | |
alph
2015/09/01 21:11:41
annotate plz
| |
836 { | |
837 var args = event.args; | |
838 // FIXME: put sessionId into args["data"] for TracingStartedInPage e vent. | |
839 if (args["data"]) | |
840 args = args["data"]; | |
841 var id = args["sessionId"]; | |
842 if (id === sessionId) | |
843 return true; | |
844 mismatchingIds.add(id); | |
845 return false; | |
846 } | |
847 var result = { | |
848 page: pageDevToolsMetadataEvents.filter(checkSessionId).sort(WebInsp ector.TracingModel.Event.compareStartTime), | |
849 workers: workersDevToolsMetadataEvents.filter(checkSessionId).sort(W ebInspector.TracingModel.Event.compareStartTime) | |
850 }; | |
851 if (mismatchingIds.size) | |
852 WebInspector.console.error("Timeline recording was started in more t han one page simultaneously. Session id mismatch: " + this._sessionId + " and " + mismatchingIds.valuesArray() + "."); | |
853 return result; | |
854 }, | |
855 | |
856 /** | |
857 * @return {?WebInspector.TracingModel.Event} | |
858 */ | |
859 _makeMockPageMetadataEvent: function() | |
860 { | |
861 var rendererMainThreadName = WebInspector.TimelineModel.RendererMainThre adName; | |
862 // FIXME: pick up the first renderer process for now. | |
863 var process = Object.values(this._tracingModel.sortedProcesses()).filter (function(p) { return p.threadByName(rendererMainThreadName); })[0]; | |
864 var thread = process && process.threadByName(rendererMainThreadName); | |
865 if (!thread) | |
866 return null; | |
867 var pageMetaEvent = new WebInspector.TracingModel.Event( | |
868 WebInspector.TracingModel.DevToolsMetadataEventCategory, | |
869 WebInspector.TimelineModel.DevToolsMetadataEvent.TracingStartedInPag e, | |
870 WebInspector.TracingModel.Phase.Metadata, | |
871 this._tracingModel.minimumRecordTime(), thread); | |
872 pageMetaEvent.addArgs({"data": {"sessionId": "mockSessionId"}}); | |
873 return pageMetaEvent; | |
874 }, | |
875 | |
alph
2015/09/01 21:11:41
nit: extra line
| |
876 | |
877 /** | |
792 * @param {number} pid | 878 * @param {number} pid |
793 * @param {number} tid | 879 * @param {number} tid |
794 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 880 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
795 */ | 881 */ |
796 _injectCpuProfileEvent: function(pid, tid, cpuProfile) | 882 _injectCpuProfileEvent: function(pid, tid, cpuProfile) |
797 { | 883 { |
798 if (!cpuProfile) | 884 if (!cpuProfile) |
799 return; | 885 return; |
800 var cpuProfileEvent = /** @type {!WebInspector.TracingManager.EventPaylo ad} */ ({ | 886 var cpuProfileEvent = /** @type {!WebInspector.TracingManager.EventPaylo ad} */ ({ |
801 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory, | 887 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory, |
802 ph: WebInspector.TracingModel.Phase.Instant, | 888 ph: WebInspector.TracingModel.Phase.Instant, |
803 ts: this._tracingModel.maximumRecordTime() * 1000, | 889 ts: this._tracingModel.maximumRecordTime() * 1000, |
804 pid: pid, | 890 pid: pid, |
805 tid: tid, | 891 tid: tid, |
806 name: WebInspector.TimelineModel.RecordType.CpuProfile, | 892 name: WebInspector.TimelineModel.RecordType.CpuProfile, |
807 args: { data: { cpuProfile: cpuProfile } } | 893 args: { data: { cpuProfile: cpuProfile } } |
808 }); | 894 }); |
809 this._tracingModel.addEvents([cpuProfileEvent]); | 895 this._tracingModel.addEvents([cpuProfileEvent]); |
810 }, | 896 }, |
811 | 897 |
812 _injectCpuProfileEvents: function() | 898 /** |
899 * @param {!WebInspector.TimelineModel.MetadataEvents} metadataEvents | |
900 */ | |
901 _injectCpuProfileEvents: function(metadataEvents) | |
813 { | 902 { |
814 if (!this._cpuProfiles) | 903 if (!this._cpuProfiles) |
815 return; | 904 return; |
816 var mainMetaEvent = this._tracingModel.devtoolsPageMetadataEvents().peek Last(); | 905 var mainMetaEvent = metadataEvents.page.peekLast(); |
817 if (!mainMetaEvent) | 906 if (!mainMetaEvent) |
818 return; | 907 return; |
819 var pid = mainMetaEvent.thread.process().id(); | 908 var pid = mainMetaEvent.thread.process().id(); |
820 var mainTarget = this._targets[0]; | 909 var mainTarget = this._targets[0]; |
821 var mainCpuProfile = this._cpuProfiles.get(mainTarget.id()); | 910 var mainCpuProfile = this._cpuProfiles.get(mainTarget.id()); |
822 this._injectCpuProfileEvent(pid, mainMetaEvent.thread.id(), mainCpuProfi le); | 911 this._injectCpuProfileEvent(pid, mainMetaEvent.thread.id(), mainCpuProfi le); |
823 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); | 912 for (var metaEvent of metadataEvents.workers) { |
824 for (var metaEvent of workerMetadataEvents) { | |
825 var workerId = metaEvent.args["data"]["workerId"]; | 913 var workerId = metaEvent.args["data"]["workerId"]; |
826 var target = mainTarget.workerManager ? mainTarget.workerManager.tar getByWorkerId(workerId) : null; | 914 var target = mainTarget.workerManager ? mainTarget.workerManager.tar getByWorkerId(workerId) : null; |
827 if (!target) | 915 if (!target) |
828 continue; | 916 continue; |
829 var cpuProfile = this._cpuProfiles.get(target.id()); | 917 var cpuProfile = this._cpuProfiles.get(target.id()); |
830 this._injectCpuProfileEvent(pid, metaEvent.args["data"]["workerThrea dId"], cpuProfile); | 918 this._injectCpuProfileEvent(pid, metaEvent.args["data"]["workerThrea dId"], cpuProfile); |
831 } | 919 } |
832 this._cpuProfiles = null; | 920 this._cpuProfiles = null; |
833 }, | 921 }, |
834 | 922 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 /** @type {!Array.<!WebInspector.TracingModel.Event>} */ | 1379 /** @type {!Array.<!WebInspector.TracingModel.Event>} */ |
1292 this._inspectedTargetEvents = []; | 1380 this._inspectedTargetEvents = []; |
1293 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ | 1381 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ |
1294 this._records = []; | 1382 this._records = []; |
1295 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ | 1383 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ |
1296 this._mainThreadTasks = []; | 1384 this._mainThreadTasks = []; |
1297 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ | 1385 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ |
1298 this._gpuTasks = []; | 1386 this._gpuTasks = []; |
1299 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ | 1387 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ |
1300 this._eventDividerRecords = []; | 1388 this._eventDividerRecords = []; |
1389 /** @type {?string} */ | |
1390 this._sessionId = null; | |
1391 this._loadedFromFile = false; | |
1301 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordsC leared); | 1392 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordsC leared); |
1302 }, | 1393 }, |
1303 | 1394 |
1304 /** | 1395 /** |
1305 * @return {number} | 1396 * @return {number} |
1306 */ | 1397 */ |
1307 minimumRecordTime: function() | 1398 minimumRecordTime: function() |
1308 { | 1399 { |
1309 return this._tracingModel.minimumRecordTime(); | 1400 return this._tracingModel.minimumRecordTime(); |
1310 }, | 1401 }, |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 /** | 1970 /** |
1880 * @constructor | 1971 * @constructor |
1881 * @implements {WebInspector.OutputStream} | 1972 * @implements {WebInspector.OutputStream} |
1882 * @param {!WebInspector.TimelineModel} model | 1973 * @param {!WebInspector.TimelineModel} model |
1883 * @param {!WebInspector.Progress} progress | 1974 * @param {!WebInspector.Progress} progress |
1884 * @param {function()=} canceledCallback | 1975 * @param {function()=} canceledCallback |
1885 */ | 1976 */ |
1886 WebInspector.TracingModelLoader = function(model, progress, canceledCallback) | 1977 WebInspector.TracingModelLoader = function(model, progress, canceledCallback) |
1887 { | 1978 { |
1888 this._model = model; | 1979 this._model = model; |
1889 this._loader = new WebInspector.TracingModel.Loader(model._tracingModel); | |
1890 | 1980 |
1891 this._canceledCallback = canceledCallback; | 1981 this._canceledCallback = canceledCallback; |
1892 this._progress = progress; | 1982 this._progress = progress; |
1893 this._progress.setTitle(WebInspector.UIString("Loading")); | 1983 this._progress.setTitle(WebInspector.UIString("Loading")); |
1894 this._progress.setTotalWork(WebInspector.TracingModelLoader._totalProgress); // Unknown, will loop the values. | 1984 this._progress.setTotalWork(WebInspector.TracingModelLoader._totalProgress); // Unknown, will loop the values. |
1895 | 1985 |
1896 this._state = WebInspector.TracingModelLoader.State.Initial; | 1986 this._state = WebInspector.TracingModelLoader.State.Initial; |
1897 this._buffer = ""; | 1987 this._buffer = ""; |
1898 this._firstChunk = true; | 1988 this._firstChunk = true; |
1899 this._wasCanceledOnce = false; | 1989 this._wasCanceledOnce = false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1976 | 2066 |
1977 if (this._firstChunk) { | 2067 if (this._firstChunk) { |
1978 this._firstChunk = false; | 2068 this._firstChunk = false; |
1979 if (this._looksLikeAppVersion(items[0])) { | 2069 if (this._looksLikeAppVersion(items[0])) { |
1980 this._reportErrorAndCancelLoading(WebInspector.UIString("Legacy Timeline format is not supported.")); | 2070 this._reportErrorAndCancelLoading(WebInspector.UIString("Legacy Timeline format is not supported.")); |
1981 return; | 2071 return; |
1982 } | 2072 } |
1983 } | 2073 } |
1984 | 2074 |
1985 try { | 2075 try { |
1986 this._loader.loadNextChunk(items); | 2076 this._model._tracingModel.addEvents(items); |
1987 } catch(e) { | 2077 } catch(e) { |
1988 this._reportErrorAndCancelLoading(WebInspector.UIString("Malformed t imeline data: %s", e.toString())); | 2078 this._reportErrorAndCancelLoading(WebInspector.UIString("Malformed t imeline data: %s", e.toString())); |
1989 return; | 2079 return; |
1990 } | 2080 } |
1991 }, | 2081 }, |
1992 | 2082 |
1993 /** | 2083 /** |
1994 * @param {string=} message | 2084 * @param {string=} message |
1995 */ | 2085 */ |
1996 _reportErrorAndCancelLoading: function(message) | 2086 _reportErrorAndCancelLoading: function(message) |
(...skipping 10 matching lines...) Expand all Loading... | |
2007 _looksLikeAppVersion: function(item) | 2097 _looksLikeAppVersion: function(item) |
2008 { | 2098 { |
2009 return typeof item === "string" && item.indexOf("Chrome") !== -1; | 2099 return typeof item === "string" && item.indexOf("Chrome") !== -1; |
2010 }, | 2100 }, |
2011 | 2101 |
2012 /** | 2102 /** |
2013 * @override | 2103 * @override |
2014 */ | 2104 */ |
2015 close: function() | 2105 close: function() |
2016 { | 2106 { |
2017 this._loader.finish(); | 2107 this._model._loadedFromFile = true; |
2018 this._model.tracingComplete(); | 2108 this._model.tracingComplete(); |
2019 if (this._progress) | 2109 if (this._progress) |
2020 this._progress.done(); | 2110 this._progress.done(); |
2021 } | 2111 } |
2022 } | 2112 } |
2023 | 2113 |
2024 /** | 2114 /** |
2025 * @constructor | 2115 * @constructor |
2026 * @param {!WebInspector.OutputStream} stream | 2116 * @param {!WebInspector.OutputStream} stream |
2027 * @implements {WebInspector.OutputStreamDelegate} | 2117 * @implements {WebInspector.OutputStreamDelegate} |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2363 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ | 2453 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ |
2364 this._invalidations = {}; | 2454 this._invalidations = {}; |
2365 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ | 2455 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ |
2366 this._invalidationsByNodeId = {}; | 2456 this._invalidationsByNodeId = {}; |
2367 | 2457 |
2368 this._lastRecalcStyle = undefined; | 2458 this._lastRecalcStyle = undefined; |
2369 this._lastPaintWithLayer = undefined; | 2459 this._lastPaintWithLayer = undefined; |
2370 this._didPaint = false; | 2460 this._didPaint = false; |
2371 } | 2461 } |
2372 } | 2462 } |
OLD | NEW |