Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js

Issue 2262303002: DevTooos: Profiler domain refactoring: Make deoptReason and positionTicks fields optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing caseq comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.ProfileNode} 7 * @extends {WebInspector.ProfileNode}
8 * @param {!ProfilerAgent.CPUProfileNode} node 8 * @param {!ProfilerAgent.CPUProfileNode} node
9 * @param {number} sampleTime 9 * @param {number} sampleTime
10 */ 10 */
11 WebInspector.CPUProfileNode = function(node, sampleTime) 11 WebInspector.CPUProfileNode = function(node, sampleTime)
12 { 12 {
13 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({ 13 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({
14 // Backward compatibility for old SamplingHeapProfileNode format. 14 // Backward compatibility for old SamplingHeapProfileNode format.
15 functionName: node["functionName"], 15 functionName: node["functionName"],
16 scriptId: node["scriptId"], 16 scriptId: node["scriptId"],
17 url: node["url"], 17 url: node["url"],
18 lineNumber: node["lineNumber"] - 1, 18 lineNumber: node["lineNumber"] - 1,
19 columnNumber: node["columnNumber"] - 1 19 columnNumber: node["columnNumber"] - 1
20 }); 20 });
21 WebInspector.ProfileNode.call(this, callFrame); 21 WebInspector.ProfileNode.call(this, callFrame);
22 this.id = node.id; 22 this.id = node.id;
23 this.self = node.hitCount * sampleTime; 23 this.self = node.hitCount * sampleTime;
24 this.positionTicks = node.positionTicks; 24 this.positionTicks = node.positionTicks;
25 this.deoptReason = node.deoptReason; 25 // Compatibility: legacy backends could provide "no reason" for optimized fu nctions.
26 this.deoptReason = node.deoptReason && node.deoptReason !== "no reason" ? no de.deoptReason : null;
26 } 27 }
27 28
28 WebInspector.CPUProfileNode.prototype = { 29 WebInspector.CPUProfileNode.prototype = {
29 __proto__: WebInspector.ProfileNode.prototype 30 __proto__: WebInspector.ProfileNode.prototype
30 } 31 }
31 32
32 /** 33 /**
33 * @constructor 34 * @constructor
34 * @extends {WebInspector.ProfileTreeModel} 35 * @extends {WebInspector.ProfileTreeModel}
35 * @param {!ProfilerAgent.CPUProfile} profile 36 * @param {!ProfilerAgent.CPUProfile} profile
36 */ 37 */
37 WebInspector.CPUProfileDataModel = function(profile) 38 WebInspector.CPUProfileDataModel = function(profile)
38 { 39 {
39 var isLegacyFormat = !!profile.head; 40 var isLegacyFormat = !!profile["head"];
40 if (isLegacyFormat) { 41 if (isLegacyFormat) {
41 // Legacy format contains raw timestamps and start/stop times are in sec onds. 42 // Legacy format contains raw timestamps and start/stop times are in sec onds.
42 this.profileStartTime = profile.startTime * 1000; 43 this.profileStartTime = profile.startTime * 1000;
43 this.profileEndTime = profile.endTime * 1000; 44 this.profileEndTime = profile.endTime * 1000;
44 this.timestamps = profile.timestamps; 45 this.timestamps = profile.timestamps;
45 this._compatibilityConversionHeadToNodes(profile); 46 this._compatibilityConversionHeadToNodes(profile);
46 } else { 47 } else {
47 // Current format encodes timestamps as deltas. Start/stop times are in microseconds. 48 // Current format encodes timestamps as deltas. Start/stop times are in microseconds.
48 this.profileStartTime = profile.startTime / 1000; 49 this.profileStartTime = profile.startTime / 1000;
49 this.profileEndTime = profile.endTime / 1000; 50 this.profileEndTime = profile.endTime / 1000;
(...skipping 16 matching lines...) Expand all
66 * @param {!ProfilerAgent.CPUProfile} profile 67 * @param {!ProfilerAgent.CPUProfile} profile
67 */ 68 */
68 _compatibilityConversionHeadToNodes: function(profile) 69 _compatibilityConversionHeadToNodes: function(profile)
69 { 70 {
70 if (!profile.head || profile.nodes) 71 if (!profile.head || profile.nodes)
71 return; 72 return;
72 /** @type {!Array<!ProfilerAgent.CPUProfileNode>} */ 73 /** @type {!Array<!ProfilerAgent.CPUProfileNode>} */
73 var nodes = []; 74 var nodes = [];
74 convertNodesTree(profile.head); 75 convertNodesTree(profile.head);
75 profile.nodes = nodes; 76 profile.nodes = nodes;
76 profile.head = null; 77 delete profile.head;
77 /** 78 /**
78 * @param {!ProfilerAgent.CPUProfileNode} node 79 * @param {!ProfilerAgent.CPUProfileNode} node
79 * @return {number} 80 * @return {number}
80 */ 81 */
81 function convertNodesTree(node) 82 function convertNodesTree(node)
82 { 83 {
83 nodes.push(node); 84 nodes.push(node);
84 node.children = (/** @type {!Array<!ProfilerAgent.CPUProfileNode>} * /(node.children)).map(convertNodesTree); 85 node.children = (/** @type {!Array<!ProfilerAgent.CPUProfileNode>} * /(node.children)).map(convertNodesTree);
85 return node.id; 86 return node.id;
86 } 87 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 * @param {number} index 350 * @param {number} index
350 * @return {?WebInspector.CPUProfileNode} 351 * @return {?WebInspector.CPUProfileNode}
351 */ 352 */
352 nodeByIndex: function(index) 353 nodeByIndex: function(index)
353 { 354 {
354 return this._idToNode.get(this.samples[index]) || null; 355 return this._idToNode.get(this.samples[index]) || null;
355 }, 356 },
356 357
357 __proto__: WebInspector.ProfileTreeModel.prototype 358 __proto__: WebInspector.ProfileTreeModel.prototype
358 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698