Commit bde56d6d authored by timothy@apple.com's avatar timothy@apple.com

Add support for multiple Timeline recordings.

We also don't explicitly add ResourceTimelineRecords anymore. These will be tracked automatically in a later patch.

https://bugs.webkit.org/show_bug.cgi?id=123366

Reviewed by Joseph Pecoraro.

* UserInterface/DashboardManager.js:
(WebInspector.DashboardManager.prototype._mainResourceDidChange): Check for currentRecording.
* UserInterface/InspectorFrontendAPI.js:
(InspectorFrontendAPI.isTimelineProfilingEnabled): Check for currentRecording.
* UserInterface/Main.html:
* UserInterface/TimelineManager.js:
(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype.get currentRecording): Added.
(WebInspector.TimelineManager.prototype.startRecording): Make a new recording and push it onto the recording array.
Add the current recording to the event.
(WebInspector.TimelineManager.prototype.stopRecording): Add the current recording to the event.
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord): Check for currentRecording. Add the markers
to the current recording.
(WebInspector.TimelineManager.prototype._addRecord): Add the record to the current recording.
(WebInspector.TimelineManager.prototype._startAutoRecording): Clean up. Don't add ResourceTimelineRecord. Clear recordings.
(WebInspector.TimelineManager.prototype._stopAutoRecordingSoon): Check for _currentRecording.
(WebInspector.TimelineManager.prototype._resetAutoRecordingDeadTimeTimeout): Ditto.
(WebInspector.TimelineManager.prototype._mainResourceDidChange): Don't add ResourceTimelineRecord anymore.
(WebInspector.TimelineManager.prototype._resourceWasAdded): Removed.
* UserInterface/TimelineRecording.js: Added.
(WebInspector.TimelineRecording): Added.
(WebInspector.TimelineRecording.prototype.addEventMarker): Added.
(WebInspector.TimelineRecording.prototype.addRecord): Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d002bcf3
2013-10-25 Timothy Hatcher <timothy@apple.com>
Add support for multiple Timeline recordings.
We also don't explicitly add ResourceTimelineRecords anymore. These will be tracked automatically in a later patch.
https://bugs.webkit.org/show_bug.cgi?id=123366
Reviewed by Joseph Pecoraro.
* UserInterface/DashboardManager.js:
(WebInspector.DashboardManager.prototype._mainResourceDidChange): Check for currentRecording.
* UserInterface/InspectorFrontendAPI.js:
(InspectorFrontendAPI.isTimelineProfilingEnabled): Check for currentRecording.
* UserInterface/Main.html:
* UserInterface/TimelineManager.js:
(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype.get currentRecording): Added.
(WebInspector.TimelineManager.prototype.startRecording): Make a new recording and push it onto the recording array.
Add the current recording to the event.
(WebInspector.TimelineManager.prototype.stopRecording): Add the current recording to the event.
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord): Check for currentRecording. Add the markers
to the current recording.
(WebInspector.TimelineManager.prototype._addRecord): Add the record to the current recording.
(WebInspector.TimelineManager.prototype._startAutoRecording): Clean up. Don't add ResourceTimelineRecord. Clear recordings.
(WebInspector.TimelineManager.prototype._stopAutoRecordingSoon): Check for _currentRecording.
(WebInspector.TimelineManager.prototype._resetAutoRecordingDeadTimeTimeout): Ditto.
(WebInspector.TimelineManager.prototype._mainResourceDidChange): Don't add ResourceTimelineRecord anymore.
(WebInspector.TimelineManager.prototype._resourceWasAdded): Removed.
* UserInterface/TimelineRecording.js: Added.
(WebInspector.TimelineRecording): Added.
(WebInspector.TimelineRecording.prototype.addEventMarker): Added.
(WebInspector.TimelineRecording.prototype.addRecord): Added.
2013-10-25 Timothy Hatcher <timothy@apple.com>
Track callFrames and sourceCodeLocation per TimelineRecord.
......
......@@ -61,7 +61,7 @@ WebInspector.DashboardManager.prototype = {
this._view.resourcesSize = WebInspector.frameResourceManager.mainFrame.mainResource.size || 0;
// Only update the time if we are recording the timeline.
if (!WebInspector.timelineManager.recording) {
if (!WebInspector.timelineManager.recordingEnabled) {
this._view.time = 0;
return;
}
......
......@@ -51,7 +51,7 @@ InspectorFrontendAPI = {
isTimelineProfilingEnabled: function()
{
return WebInspector.timelineManager.recording;
return WebInspector.timelineManager.recordingEnabled;
},
setTimelineProfilingEnabled: function(enabled)
......
......@@ -186,6 +186,7 @@
<script src="ApplicationCacheObserver.js"></script>
<script src="TimelineObserver.js"></script>
<script src="TimelineManager.js"></script>
<script src="TimelineRecording.js"></script>
<script src="TimelineRecord.js"></script>
<script src="TimelineEventMarker.js"></script>
<script src="ResourceTimelineRecord.js"></script>
......
......@@ -31,15 +31,13 @@ WebInspector.TimelineManager = function()
WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
this._recording = false;
this._recording = new WebInspector.TimelineRecording;
this._recordingEnabled = false;
};
WebInspector.TimelineManager.Event = {
RecordsCleared: "timeline-manager-records-cleared",
RecordingStarted: "timeline-manager-recording-started",
RecordingStopped: "timeline-manager-recording-stopped",
RecordAdded: "timeline-manager-record-added",
RecordedEventMarker: "timeline-manager-recorded-event-marker",
RecordingStopped: "timeline-manager-recording-stopped"
};
WebInspector.TimelineManager.MaximumAutoRecordDuration = 90000; // 90 seconds
......@@ -56,12 +54,17 @@ WebInspector.TimelineManager.prototype = {
return this._recording;
},
get recordingEnabled()
{
return this._recordingEnabled;
},
startRecording: function()
{
if (this._recording)
if (this._recordingEnabled)
return;
this._recording = true;
this._recordingEnabled = true;
TimelineAgent.start();
......@@ -70,7 +73,7 @@ WebInspector.TimelineManager.prototype = {
stopRecording: function()
{
if (!this._recording)
if (!this._recordingEnabled)
return;
if (this._stopRecordingTimeout) {
......@@ -85,7 +88,7 @@ WebInspector.TimelineManager.prototype = {
TimelineAgent.stop();
this._recording = false;
this._recordingEnabled = false;
this._autoRecordingMainResource = null;
this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordingStopped);
......@@ -95,7 +98,7 @@ WebInspector.TimelineManager.prototype = {
{
// Called from WebInspector.TimelineObserver.
if (!this._recording)
if (!this._recordingEnabled)
return;
function processRecord(recordPayload, parentRecordPayload)
......@@ -133,8 +136,8 @@ WebInspector.TimelineManager.prototype = {
break;
var eventMarker = new WebInspector.TimelineEventMarker(startTime, WebInspector.TimelineEventMarker.Type.LoadEvent);
this._eventMarkers.push(eventMarker);
this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordedEventMarker, {eventMarker: eventMarker});
this._recording.addEventMarker(eventMarker);
this._stopAutoRecordingSoon();
break;
......@@ -152,8 +155,7 @@ WebInspector.TimelineManager.prototype = {
break;
var eventMarker = new WebInspector.TimelineEventMarker(startTime, WebInspector.TimelineEventMarker.Type.DOMContentEvent);
this._eventMarkers.push(eventMarker);
this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordedEventMarker, {eventMarker: eventMarker});
this._recording.addEventMarker(eventMarker);
break;
case TimelineAgent.EventType.ScheduleStyleRecalculation:
......@@ -200,6 +202,7 @@ WebInspector.TimelineManager.prototype = {
// The lineNumber is 1-based, but we expect 0-based.
var lineNumber = recordPayload.data.lineNumber - 1;
// FIXME: No column number is provided.
sourceCodeLocation = scriptResource.createSourceCodeLocation(lineNumber, 0);
}
}
......@@ -217,8 +220,7 @@ WebInspector.TimelineManager.prototype = {
case TimelineAgent.EventType.TimeStamp:
var eventMarker = new WebInspector.TimelineEventMarker(startTime, WebInspector.TimelineEventMarker.Type.TimeStamp);
this._eventMarkers.push(eventMarker);
this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordedEventMarker, {eventMarker: eventMarker});
this._recording.addEventMarker(eventMarker);
break;
case TimelineAgent.EventType.FunctionCall:
......@@ -227,6 +229,18 @@ WebInspector.TimelineManager.prototype = {
if (!parentRecordPayload)
break;
if (!sourceCodeLocation) {
var mainFrame = WebInspector.frameResourceManager.mainFrame;
var scriptResource = mainFrame.url === recordPayload.data.scriptName ? mainFrame.mainResource : mainFrame.resourceForURL(recordPayload.data.scriptName, true);
if (scriptResource) {
// The lineNumber is 1-based, but we expect 0-based.
var lineNumber = recordPayload.data.scriptLine - 1;
// FIXME: No column number is provided.
sourceCodeLocation = scriptResource.createSourceCodeLocation(lineNumber, 0);
}
}
switch (parentRecordPayload.type) {
case TimelineAgent.EventType.TimerFire:
this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId));
......@@ -248,12 +262,17 @@ WebInspector.TimelineManager.prototype = {
break;
case TimelineAgent.EventType.TimerInstall:
console.assert(isNaN(endTime));
// Pass the startTime as the endTime since this record type has no duration.
this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerInstalled, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.timerId));
break;
case TimelineAgent.EventType.TimerRemove:
if (recordPayload.type === TimelineAgent.EventType.TimerInstall)
this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerInstalled, startTime, endTime, callFrames, sourceCodeLocation, recordPayload.data.timerId));
else
this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerRemoved, startTime, endTime, callFrames, sourceCodeLocation, recordPayload.data.timerId));
console.assert(isNaN(endTime));
// Pass the startTime as the endTime since this record type has no duration.
this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerRemoved, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.timerId));
break;
}
}
......@@ -320,7 +339,7 @@ WebInspector.TimelineManager.prototype = {
_addRecord: function(record)
{
// FIXME: Implement.
this._recording.addRecord(record);
// Only worry about dead time after the load event.
if (!isNaN(WebInspector.frameResourceManager.mainFrame.loadEventTimestamp))
......@@ -329,7 +348,7 @@ WebInspector.TimelineManager.prototype = {
_startAutoRecording: function(event)
{
if (!event.target.isMainFrame() || (this._recording && !this._autoRecordingMainResource))
if (!event.target.isMainFrame() || (this._recordingEnabled && !this._autoRecordingMainResource))
return false;
var mainResource = event.target.provisionalMainResource || event.target.mainResource;
......@@ -340,6 +359,8 @@ WebInspector.TimelineManager.prototype = {
this._autoRecordingMainResource = mainResource;
this._recording.reset();
this.startRecording();
this._addRecord(new WebInspector.ResourceTimelineRecord(mainResource));
......@@ -354,7 +375,7 @@ WebInspector.TimelineManager.prototype = {
_stopAutoRecordingSoon: function()
{
// Only auto stop when auto recording.
if (!this._recording || !this._autoRecordingMainResource)
if (!this._recordingEnabled || !this._autoRecordingMainResource)
return;
if (this._stopRecordingTimeout)
......@@ -365,7 +386,7 @@ WebInspector.TimelineManager.prototype = {
_resetAutoRecordingDeadTimeTimeout: function()
{
// Only monitor dead time when auto recording.
if (!this._recording || !this._autoRecordingMainResource)
if (!this._recordingEnabled || !this._autoRecordingMainResource)
return;
if (this._deadTimeTimeout)
......@@ -383,7 +404,7 @@ WebInspector.TimelineManager.prototype = {
if (this._startAutoRecording(event))
return;
if (!this._recording)
if (!this._recordingEnabled)
return;
var mainResource = event.target.mainResource;
......@@ -400,7 +421,7 @@ WebInspector.TimelineManager.prototype = {
if (!WebInspector.frameResourceManager.mainFrame)
return;
if (!this._recording)
if (!this._recordingEnabled)
return;
this._addRecord(new WebInspector.ResourceTimelineRecord(event.data.resource));
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
WebInspector.TimelineRecording = function()
{
WebInspector.Object.call(this);
};
WebInspector.TimelineRecording.prototype = {
constructor: WebInspector.TimelineRecording,
__proto__: WebInspector.Object.prototype,
// Public
addEventMarker: function(eventMarker)
{
// FIXME: Implement.
},
addRecord: function(record)
{
// FIXME: Implement.
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment