<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163141] trunk/Source/WebInspectorUI</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163141">163141</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2014-01-30 17:35:01 -0800 (Thu, 30 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add the model objects for the new Web Inspector profile data.

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

Reviewed by Joseph Pecoraro.

* UserInterface/Main.html:
* UserInterface/Profile.js: Added.
(WebInspector.Profile):
(WebInspector.Profile.prototype.get idleTime):
(WebInspector.Profile.prototype.get topDownRootNodes):
(WebInspector.Profile.prototype.get bottomUpRootNodes):
* UserInterface/ProfileNode.js: Added.
(WebInspector.ProfileNode):
(WebInspector.ProfileNode.prototype.get id):
(WebInspector.ProfileNode.prototype.get type):
(WebInspector.ProfileNode.prototype.get functionName):
(WebInspector.ProfileNode.prototype.get sourceCodeLocation):
(WebInspector.ProfileNode.prototype.get startTime):
(WebInspector.ProfileNode.prototype.get endTime):
(WebInspector.ProfileNode.prototype.get selfTime):
(WebInspector.ProfileNode.prototype.get totalTime):
(WebInspector.ProfileNode.prototype.get calls):
(WebInspector.ProfileNode.prototype.get previousSibling):
(WebInspector.ProfileNode.prototype.get nextSibling):
(WebInspector.ProfileNode.prototype.get parentNode):
(WebInspector.ProfileNode.prototype.get childNodes):
(WebInspector.ProfileNode.prototype.totalTimeInRange):
(WebInspector.ProfileNode.prototype.computeCallInfoForTimeRange):
(WebInspector.ProfileNode.prototype.traverseNextProfileNode):
(WebInspector.ProfileNode.prototype.saveIdentityToCookie):
(WebInspector.ProfileNode.prototype.establishRelationships):
* UserInterface/ProfileNodeCall.js: Added.
(WebInspector.ProfileNodeCall):
(WebInspector.ProfileNodeCall.prototype.get startTime):
(WebInspector.ProfileNodeCall.prototype.get totalTime):
(WebInspector.ProfileNodeCall.prototype.get endTime):
(WebInspector.ProfileNodeCall.prototype.establishRelationships):
* UserInterface/TimelineManager.js:
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
(WebInspector.TimelineManager.prototype.eventRecorded):
(WebInspector.TimelineManager.prototype._profileFromPayload.profileNodeFromPayload):
(WebInspector.TimelineManager.prototype._profileFromPayload.profileNodeCallFromPayload):
(WebInspector.TimelineManager.prototype._profileFromPayload):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTimelineManagerjs">trunk/Source/WebInspectorUI/UserInterface/TimelineManager.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProfilejs">trunk/Source/WebInspectorUI/UserInterface/Profile.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProfileNodejs">trunk/Source/WebInspectorUI/UserInterface/ProfileNode.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProfileNodeCalljs">trunk/Source/WebInspectorUI/UserInterface/ProfileNodeCall.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (163140 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2014-01-31 01:34:54 UTC (rev 163140)
+++ trunk/Source/WebInspectorUI/ChangeLog        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2014-01-30  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
+        Add the model objects for the new Web Inspector profile data.
+
+        https://bugs.webkit.org/show_bug.cgi?id=127899
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Main.html:
+        * UserInterface/Profile.js: Added.
+        (WebInspector.Profile):
+        (WebInspector.Profile.prototype.get idleTime):
+        (WebInspector.Profile.prototype.get topDownRootNodes):
+        (WebInspector.Profile.prototype.get bottomUpRootNodes):
+        * UserInterface/ProfileNode.js: Added.
+        (WebInspector.ProfileNode):
+        (WebInspector.ProfileNode.prototype.get id):
+        (WebInspector.ProfileNode.prototype.get type):
+        (WebInspector.ProfileNode.prototype.get functionName):
+        (WebInspector.ProfileNode.prototype.get sourceCodeLocation):
+        (WebInspector.ProfileNode.prototype.get startTime):
+        (WebInspector.ProfileNode.prototype.get endTime):
+        (WebInspector.ProfileNode.prototype.get selfTime):
+        (WebInspector.ProfileNode.prototype.get totalTime):
+        (WebInspector.ProfileNode.prototype.get calls):
+        (WebInspector.ProfileNode.prototype.get previousSibling):
+        (WebInspector.ProfileNode.prototype.get nextSibling):
+        (WebInspector.ProfileNode.prototype.get parentNode):
+        (WebInspector.ProfileNode.prototype.get childNodes):
+        (WebInspector.ProfileNode.prototype.totalTimeInRange):
+        (WebInspector.ProfileNode.prototype.computeCallInfoForTimeRange):
+        (WebInspector.ProfileNode.prototype.traverseNextProfileNode):
+        (WebInspector.ProfileNode.prototype.saveIdentityToCookie):
+        (WebInspector.ProfileNode.prototype.establishRelationships):
+        * UserInterface/ProfileNodeCall.js: Added.
+        (WebInspector.ProfileNodeCall):
+        (WebInspector.ProfileNodeCall.prototype.get startTime):
+        (WebInspector.ProfileNodeCall.prototype.get totalTime):
+        (WebInspector.ProfileNodeCall.prototype.get endTime):
+        (WebInspector.ProfileNodeCall.prototype.establishRelationships):
+        * UserInterface/TimelineManager.js:
+        (WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
+        (WebInspector.TimelineManager.prototype.eventRecorded):
+        (WebInspector.TimelineManager.prototype._profileFromPayload.profileNodeFromPayload):
+        (WebInspector.TimelineManager.prototype._profileFromPayload.profileNodeCallFromPayload):
+        (WebInspector.TimelineManager.prototype._profileFromPayload):
+
</ins><span class="cx"> 2014-01-26  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Prefix existing Web Inspector profiler classes with &quot;Legacy&quot;.
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (163140 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html        2014-01-31 01:34:54 UTC (rev 163140)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -201,6 +201,9 @@
</span><span class="cx">     &lt;script src=&quot;TimelineRecord.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;TimelineMarker.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;ResourceTimelineRecord.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;Profile.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;ProfileNode.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;ProfileNodeCall.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;FrameResourceManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;IssueManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;RuntimeManager.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProfilejs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/Profile.js (0 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Profile.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Profile.js        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.Profile = function(topDownRootNodes, idleTime)
+{
+    WebInspector.Object.call(this);
+
+    topDownRootNodes = topDownRootNodes || [];
+
+    console.assert(topDownRootNodes instanceof Array);
+    console.assert(topDownRootNodes.reduce(function(previousValue, node) { return previousValue &amp;&amp; node instanceof WebInspector.ProfileNode; }, true));
+
+    this._topDownRootNodes = topDownRootNodes;
+    this._idleTime = idleTime || 0;
+};
+
+WebInspector.Profile.prototype = {
+    constructor: WebInspector.Profile,
+    __proto__: WebInspector.Object.prototype,
+
+    // Public
+
+    get idleTime()
+    {
+        return this._idleTime;
+    },
+
+    get topDownRootNodes()
+    {
+        return this._topDownRootNodes;
+    },
+
+    get bottomUpRootNodes()
+    {
+        // FIXME: Implement.
+        return [];
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProfileNodejs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/ProfileNode.js (0 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/ProfileNode.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/ProfileNode.js        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -0,0 +1,220 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.ProfileNode = function(id, type, functionName, sourceCodeLocation, calls, childNodes)
+{
+    WebInspector.Object.call(this);
+
+    childNodes = childNodes || [];
+
+    console.assert(id);
+    console.assert(calls instanceof Array);
+    console.assert(calls.length &gt;= 1);
+    console.assert(calls.reduce(function(previousValue, call) { return previousValue &amp;&amp; call instanceof WebInspector.ProfileNodeCall; }, true));
+    console.assert(childNodes instanceof Array);
+    console.assert(childNodes.reduce(function(previousValue, node) { return previousValue &amp;&amp; node instanceof WebInspector.ProfileNode; }, true));
+
+    this._id = id;
+    this._type = type || WebInspector.ProfileNode.Type.Function;
+    this._functionName = functionName || null;
+    this._sourceCodeLocation = sourceCodeLocation || null;
+    this._calls = calls;
+    this._childNodes = childNodes;
+    this._parentNode = null;
+    this._previousSibling = null;
+    this._nextSibling = null;
+
+    for (var i = 0; i &lt; this._childNodes.length; ++i)
+        this._childNodes[i].establishRelationships(this, this._childNodes[i - 1], this._childNodes[i + 1]);
+
+    for (var i = 0; i &lt; this._calls.length; ++i)
+        this._calls[i].establishRelationships(this, this._calls[i - 1], this._calls[i + 1]);
+
+    var info = this.computeCallInfoForTimeRange(0, Infinity);
+    this._startTime = info.startTime;
+    this._endTime = info.endTime;
+    this._selfTime = info.selfTime;
+    this._totalTime = info.totalTime;
+};
+
+WebInspector.ProfileNode.Type = {
+    Function: &quot;profile-node-type-function&quot;,
+    Program: &quot;profile-node-type-program&quot;
+};
+
+WebInspector.ProfileNode.TypeIdentifier = &quot;profile-node&quot;;
+WebInspector.ProfileNode.TypeCookieKey = &quot;profile-node-type&quot;;
+WebInspector.ProfileNode.FunctionNameCookieKey = &quot;profile-node-function-name&quot;;
+WebInspector.ProfileNode.SourceCodeURLCookieKey = &quot;profile-node-source-code-url&quot;;
+WebInspector.ProfileNode.SourceCodeLocationLineCookieKey = &quot;profile-node-source-code-location-line&quot;;
+WebInspector.ProfileNode.SourceCodeLocationColumnCookieKey = &quot;profile-node-source-code-location-column&quot;;
+
+WebInspector.ProfileNode.prototype = {
+    constructor: WebInspector.ProfileNode,
+    __proto__: WebInspector.Object.prototype,
+
+    // Public
+
+    get id()
+    {
+        return this._id;
+    },
+
+    get type()
+    {
+        return this._type;
+    },
+
+    get functionName()
+    {
+        return this._functionName;
+    },
+
+    get sourceCodeLocation()
+    {
+        return this._sourceCodeLocation;
+    },
+
+    get startTime()
+    {
+        return this._startTime;
+    },
+
+    get endTime()
+    {
+        return this._endTime;
+    },
+
+    get selfTime()
+    {
+        return this._selfTime;
+    },
+
+    get totalTime()
+    {
+        return this._totalTime;
+    },
+
+    get calls()
+    {
+        return this._calls;
+    },
+
+    get previousSibling()
+    {
+        return this._previousSibling;
+    },
+
+    get nextSibling()
+    {
+        return this._nextSibling;
+    },
+
+    get parentNode()
+    {
+        return this._parentNode;
+    },
+
+    get childNodes()
+    {
+        return this._childNodes;
+    },
+
+    computeCallInfoForTimeRange: function(rangeStartTime, rangeEndTime)
+    {
+        rangeStartTime = !isNaN(rangeStartTime) ? rangeStartTime : 0;
+        rangeEndTime = !isNaN(rangeEndTime) ? rangeEndTime : Infinity;
+
+        var recordCallCount = true;
+        var callCount = 0;
+
+        function totalTimeInRange(previousValue, call)
+        {
+            if (rangeStartTime &gt; call.endTime || rangeEndTime &lt; call.startTime)
+                return previousValue;
+
+            if (recordCallCount)
+                ++callCount;
+
+            return previousValue + Math.min(call.endTime, rangeEndTime) - Math.max(rangeStartTime, call.startTime);
+        }
+
+        var startTime = Math.max(rangeStartTime, this._calls[0].startTime);
+        var endTime = Math.min(this._calls.lastValue.endTime, rangeEndTime);
+        var totalTime = this._calls.reduce(totalTimeInRange, 0);
+
+        recordCallCount = false;
+
+        var childNodesTotalTime = 0;
+        for (var childNode of this._childNodes)
+            childNodesTotalTime += childNode.calls.reduce(totalTimeInRange, 0);
+
+        var selfTime = totalTime - childNodesTotalTime;
+        var averageTime = selfTime / callCount;
+
+        return {startTime: startTime, endTime: endTime, totalTime: totalTime, selfTime: selfTime, callCount: callCount, averageTime: averageTime};
+    },
+
+    traverseNextProfileNode: function(stayWithin)
+    {
+        var profileNode = this._childNodes[0];
+        if (profileNode)
+            return profileNode;
+
+        if (this === stayWithin)
+            return null;
+
+        profileNode = this._nextSibling;
+        if (profileNode)
+            return profileNode;
+
+        profileNode = this;
+        while (profileNode &amp;&amp; !profileNode.nextSibling &amp;&amp; profileNode.parentNode !== stayWithin)
+            profileNode = profileNode.parentNode;
+
+        if (!profileNode)
+            return null;
+
+        return profileNode.nextSibling;
+    },
+
+    saveIdentityToCookie: function(cookie)
+    {
+        cookie[WebInspector.ProfileNode.TypeCookieKey] = this._type || null;
+        cookie[WebInspector.ProfileNode.FunctionNameCookieKey] = this._functionName || null;
+        cookie[WebInspector.ProfileNode.SourceCodeURLCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.sourceCode.url ? this._sourceCodeLocation.sourceCode.url.hash : null : null;
+        cookie[WebInspector.ProfileNode.SourceCodeLocationLineCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.lineNumber : null;
+        cookie[WebInspector.ProfileNode.SourceCodeLocationColumnCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.columnNumber : null;
+    },
+
+    // Protected
+
+    establishRelationships: function(parentNode, previousSibling, nextSibling)
+    {
+        this._parentNode = parentNode || null;
+        this._previousSibling = previousSibling || null;
+        this._nextSibling = nextSibling || null;
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProfileNodeCalljs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/ProfileNodeCall.js (0 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/ProfileNodeCall.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/ProfileNodeCall.js        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.ProfileNodeCall = function(startTime, totalTime)
+{
+    WebInspector.Object.call(this);
+
+    console.assert(startTime);
+
+    this._startTime = startTime;
+    this._totalTime = totalTime || 0;
+    this._parentNode = null;
+    this._previousSibling = null;
+    this._nextSibling = null;
+};
+
+WebInspector.ProfileNodeCall.prototype = {
+    constructor: WebInspector.ProfileNodeCall,
+    __proto__: WebInspector.Object.prototype,
+
+    // Public
+
+    get startTime()
+    {
+        return this._startTime;
+    },
+
+    get totalTime()
+    {
+        return this._totalTime;
+    },
+
+    get endTime()
+    {
+        return this._startTime + this._totalTime;
+    },
+
+    // Protected
+
+    establishRelationships: function(parentNode, previousSibling, nextSibling)
+    {
+        this._parentNode = parentNode || null;
+        this._previousSibling = previousSibling || null;
+        this._nextSibling = nextSibling || null;
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTimelineManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/TimelineManager.js (163140 => 163141)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/TimelineManager.js        2014-01-31 01:34:54 UTC (rev 163140)
+++ trunk/Source/WebInspectorUI/UserInterface/TimelineManager.js        2014-01-31 01:35:01 UTC (rev 163141)
</span><span class="lines">@@ -207,12 +207,16 @@
</span><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                var profile = null;
+                if (recordPayload.data.profile)
+                    profile = this._profileFromPayload(recordPayload.data.profile);
+
</ins><span class="cx">                 switch (parentRecordPayload &amp;&amp; parentRecordPayload.type) {
</span><span class="cx">                 case TimelineAgent.EventType.TimerFire:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 default:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.ScriptEvaluated, startTime, endTime, callFrames, sourceCodeLocation, null));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.ScriptEvaluated, startTime, endTime, callFrames, sourceCodeLocation, null, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -229,6 +233,10 @@
</span><span class="cx">                 if (!parentRecordPayload)
</span><span class="cx">                     break;
</span><span class="cx"> 
</span><ins>+                var profile = null;
+                if (recordPayload.data.profile)
+                    profile = this._profileFromPayload(recordPayload.data.profile);
+
</ins><span class="cx">                 if (!sourceCodeLocation) {
</span><span class="cx">                     var mainFrame = WebInspector.frameResourceManager.mainFrame;
</span><span class="cx">                     var scriptResource = mainFrame.url === recordPayload.data.scriptName ? mainFrame.mainResource : mainFrame.resourceForURL(recordPayload.data.scriptName, true);
</span><span class="lines">@@ -243,19 +251,19 @@
</span><span class="cx"> 
</span><span class="cx">                 switch (parentRecordPayload.type) {
</span><span class="cx">                 case TimelineAgent.EventType.TimerFire:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 case TimelineAgent.EventType.EventDispatch:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 case TimelineAgent.EventType.XHRLoad:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, &quot;load&quot;));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, &quot;load&quot;, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 case TimelineAgent.EventType.XHRReadyStateChange:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, &quot;readystatechange&quot;));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, &quot;readystatechange&quot;, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 case TimelineAgent.EventType.FireAnimationFrame:
</span><del>-                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.id));
</del><ins>+                    this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.id, profile));
</ins><span class="cx">                     break;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -320,6 +328,74 @@
</span><span class="cx"> 
</span><span class="cx">     // Private
</span><span class="cx"> 
</span><ins>+    _profileFromPayload: function(payload)
+    {
+        if (!payload)
+            return null;
+
+        console.assert(payload.rootNodes instanceof Array);
+
+        function profileNodeFromPayload(nodePayload)
+        {
+            console.assert(&quot;id&quot; in nodePayload);
+            console.assert(nodePayload.calls instanceof Array);
+
+            if (nodePayload.url) {
+                var sourceCode = WebInspector.frameResourceManager.resourceForURL(nodePayload.url);
+                if (!sourceCode)
+                    sourceCode = WebInspector.debuggerManager.scriptsForURL(nodePayload.url)[0];
+
+                // The lineNumber is 1-based, but we expect 0-based.
+                var lineNumber = nodePayload.lineNumber - 1;
+
+                var sourceCodeLocation = sourceCode ? sourceCode.createSourceCodeLocation(lineNumber, nodePayload.columnNumber) : null;
+            }
+
+            var isProgramCode = nodePayload.functionName === &quot;(program)&quot;;
+            var isAnonymousFunction = nodePayload.functionName === &quot;(anonymous function)&quot;;
+
+            var type = isProgramCode ? WebInspector.ProfileNode.Type.Program : WebInspector.ProfileNode.Type.Function;
+            var functionName = !isProgramCode &amp;&amp; !isAnonymousFunction &amp;&amp; nodePayload.functionName !== &quot;(unknown)&quot; ? nodePayload.functionName : null;
+            var calls = nodePayload.calls.map(profileNodeCallFromPayload);
+
+            return new WebInspector.ProfileNode(nodePayload.id, type, functionName, sourceCodeLocation, calls, nodePayload.children);
+        }
+
+        function profileNodeCallFromPayload(nodeCallPayload)
+        {
+            console.assert(&quot;startTime&quot; in nodeCallPayload);
+            console.assert(&quot;totalTime&quot; in nodeCallPayload);
+
+            return new WebInspector.ProfileNodeCall(nodeCallPayload.startTime, nodeCallPayload.totalTime);
+        }
+
+        var rootNodes = payload.rootNodes;
+
+        // Iterate over the node tree using a stack. Doing this recursively can easily cause a stack overflow.
+        // We traverse the profile in post-order and convert the payloads in place until we get back to the root.
+        var stack = [{parent: {children: rootNodes}, index: 0, root: true}];
+        while (stack.length) {
+            var entry = stack.lastValue;
+
+            if (entry.index &lt; entry.parent.children.length) {
+                var childNodePayload = entry.parent.children[entry.index];
+                if (childNodePayload.children &amp;&amp; childNodePayload.children.length)
+                    stack.push({parent: childNodePayload, index: 0});
+
+                ++entry.index;
+            } else {
+                if (!entry.root)
+                    entry.parent.children = entry.parent.children.map(profileNodeFromPayload);
+                else
+                    rootNodes = rootNodes.map(profileNodeFromPayload);
+
+                stack.pop();
+            }
+        }
+
+        return new WebInspector.Profile(rootNodes, payload.idleTime);
+    },
+
</ins><span class="cx">     _callFramesFromPayload: function(payload)
</span><span class="cx">     {
</span><span class="cx">         if (!payload)
</span></span></pre>
</div>
</div>

</body>
</html>