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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline_model/TimelineProfileTree.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 WebInspector.TimelineProfileTree = { }; 5 WebInspector.TimelineProfileTree = { };
6 6
7 /** 7 /**
8 * @constructor 8 * @constructor
9 */ 9 */
10 WebInspector.TimelineProfileTree.Node = function() 10 WebInspector.TimelineProfileTree.Node = function()
11 { 11 {
12 /** @type {number} */ 12 /** @type {number} */
13 this.totalTime; 13 this.totalTime;
14 /** @type {number} */ 14 /** @type {number} */
15 this.selfTime; 15 this.selfTime;
16 /** @type {string} */ 16 /** @type {string} */
17 this.id; 17 this.id;
18 /** @type {!WebInspector.TracingModel.Event} */ 18 /** @type {!WebInspector.TracingModel.Event} */
19 this.event; 19 this.event;
20 /** @type {?Map<string|symbol,!WebInspector.TimelineProfileTree.Node>} */ 20 /** @type {?Map<string|symbol,!WebInspector.TimelineProfileTree.Node>} */
21 this.children; 21 this.children;
22 /** @type {?WebInspector.TimelineProfileTree.Node} */ 22 /** @type {?WebInspector.TimelineProfileTree.Node} */
23 this.parent; 23 this.parent;
24 this._isGroupNode = false; 24 this._isGroupNode = false;
25 } 25 };
26 26
27 WebInspector.TimelineProfileTree.Node.prototype = { 27 WebInspector.TimelineProfileTree.Node.prototype = {
28 /** 28 /**
29 * @return {boolean} 29 * @return {boolean}
30 */ 30 */
31 isGroupNode: function() 31 isGroupNode: function()
32 { 32 {
33 return this._isGroupNode; 33 return this._isGroupNode;
34 } 34 }
35 } 35 };
36 36
37 /** 37 /**
38 * @param {!Array<!WebInspector.TracingModel.Event>} events 38 * @param {!Array<!WebInspector.TracingModel.Event>} events
39 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters 39 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters
40 * @param {number} startTime 40 * @param {number} startTime
41 * @param {number} endTime 41 * @param {number} endTime
42 * @param {function(!WebInspector.TracingModel.Event):(string|symbol)=} eventIdC allback 42 * @param {function(!WebInspector.TracingModel.Event):(string|symbol)=} eventIdC allback
43 * @return {!WebInspector.TimelineProfileTree.Node} 43 * @return {!WebInspector.TimelineProfileTree.Node}
44 */ 44 */
45 WebInspector.TimelineProfileTree.buildTopDown = function(events, filters, startT ime, endTime, eventIdCallback) 45 WebInspector.TimelineProfileTree.buildTopDown = function(events, filters, startT ime, endTime, eventIdCallback)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!WebInspector.TimelineModel.isVisible(filters, e)) 93 if (!WebInspector.TimelineModel.isVisible(filters, e))
94 return; 94 return;
95 parent = parent.parent; 95 parent = parent.parent;
96 } 96 }
97 97
98 var instantEventCallback = eventIdCallback ? undefined : onStartEvent; // Ig nore instant events when aggregating. 98 var instantEventCallback = eventIdCallback ? undefined : onStartEvent; // Ig nore instant events when aggregating.
99 WebInspector.TimelineModel.forEachEvent(events, onStartEvent, onEndEvent, in stantEventCallback, startTime, endTime); 99 WebInspector.TimelineModel.forEachEvent(events, onStartEvent, onEndEvent, in stantEventCallback, startTime, endTime);
100 root.totalTime -= root.selfTime; 100 root.totalTime -= root.selfTime;
101 root.selfTime = 0; 101 root.selfTime = 0;
102 return root; 102 return root;
103 } 103 };
104 104
105 /** 105 /**
106 * @param {!WebInspector.TimelineProfileTree.Node} topDownTree 106 * @param {!WebInspector.TimelineProfileTree.Node} topDownTree
107 * @param {?function(!WebInspector.TimelineProfileTree.Node):!WebInspector.Timel ineProfileTree.Node=} groupingCallback 107 * @param {?function(!WebInspector.TimelineProfileTree.Node):!WebInspector.Timel ineProfileTree.Node=} groupingCallback
108 * @return {!WebInspector.TimelineProfileTree.Node} 108 * @return {!WebInspector.TimelineProfileTree.Node}
109 */ 109 */
110 WebInspector.TimelineProfileTree.buildBottomUp = function(topDownTree, groupingC allback) 110 WebInspector.TimelineProfileTree.buildBottomUp = function(topDownTree, groupingC allback)
111 { 111 {
112 var buRoot = new WebInspector.TimelineProfileTree.Node(); 112 var buRoot = new WebInspector.TimelineProfileTree.Node();
113 buRoot.selfTime = 0; 113 buRoot.selfTime = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 // Purge zero self time nodes. 175 // Purge zero self time nodes.
176 var rootChildren = buRoot.children; 176 var rootChildren = buRoot.children;
177 for (var item of rootChildren.entries()) { 177 for (var item of rootChildren.entries()) {
178 if (item[1].selfTime === 0) 178 if (item[1].selfTime === 0)
179 rootChildren.delete(/** @type {string} */(item[0])); 179 rootChildren.delete(/** @type {string} */(item[0]));
180 } 180 }
181 181
182 return buRoot; 182 return buRoot;
183 } 183 };
184 184
185 /** 185 /**
186 * @param {!WebInspector.TracingModel.Event} event 186 * @param {!WebInspector.TracingModel.Event} event
187 * @return {?string} 187 * @return {?string}
188 */ 188 */
189 WebInspector.TimelineProfileTree.eventURL = function(event) 189 WebInspector.TimelineProfileTree.eventURL = function(event)
190 { 190 {
191 var data = event.args["data"] || event.args["beginData"]; 191 var data = event.args["data"] || event.args["beginData"];
192 if (data && data["url"]) 192 if (data && data["url"])
193 return data["url"]; 193 return data["url"];
194 var frame = WebInspector.TimelineProfileTree.eventStackFrame(event); 194 var frame = WebInspector.TimelineProfileTree.eventStackFrame(event);
195 while (frame) { 195 while (frame) {
196 var url = frame["url"]; 196 var url = frame["url"];
197 if (url) 197 if (url)
198 return url; 198 return url;
199 frame = frame.parent; 199 frame = frame.parent;
200 } 200 }
201 return null; 201 return null;
202 } 202 };
203 203
204 /** 204 /**
205 * @param {!WebInspector.TracingModel.Event} event 205 * @param {!WebInspector.TracingModel.Event} event
206 * @return {?RuntimeAgent.CallFrame} 206 * @return {?RuntimeAgent.CallFrame}
207 */ 207 */
208 WebInspector.TimelineProfileTree.eventStackFrame = function(event) 208 WebInspector.TimelineProfileTree.eventStackFrame = function(event)
209 { 209 {
210 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) 210 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame)
211 return /** @type {?RuntimeAgent.CallFrame} */ (event.args["data"] || nul l); 211 return /** @type {?RuntimeAgent.CallFrame} */ (event.args["data"] || nul l);
212 var topFrame = event.stackTrace && event.stackTrace[0]; 212 var topFrame = event.stackTrace && event.stackTrace[0];
213 if (topFrame) 213 if (topFrame)
214 return /** @type {!RuntimeAgent.CallFrame} */ (topFrame); 214 return /** @type {!RuntimeAgent.CallFrame} */ (topFrame);
215 var initiator = event.initiator; 215 var initiator = event.initiator;
216 return /** @type {?RuntimeAgent.CallFrame} */ (initiator && initiator.stackT race && initiator.stackTrace[0] || null); 216 return /** @type {?RuntimeAgent.CallFrame} */ (initiator && initiator.stackT race && initiator.stackTrace[0] || null);
217 } 217 };
218 218
219 /** 219 /**
220 * @constructor 220 * @constructor
221 * @param {function(!WebInspector.TracingModel.Event):string} titleMapper 221 * @param {function(!WebInspector.TracingModel.Event):string} titleMapper
222 * @param {function(!WebInspector.TracingModel.Event):string} categoryMapper 222 * @param {function(!WebInspector.TracingModel.Event):string} categoryMapper
223 */ 223 */
224 WebInspector.TimelineAggregator = function(titleMapper, categoryMapper) 224 WebInspector.TimelineAggregator = function(titleMapper, categoryMapper)
225 { 225 {
226 this._titleMapper = titleMapper; 226 this._titleMapper = titleMapper;
227 this._categoryMapper = categoryMapper; 227 this._categoryMapper = categoryMapper;
228 /** @type {!Map<string, !WebInspector.TimelineProfileTree.Node>} */ 228 /** @type {!Map<string, !WebInspector.TimelineProfileTree.Node>} */
229 this._groupNodes = new Map(); 229 this._groupNodes = new Map();
230 } 230 };
231 231
232 /** 232 /**
233 * @enum {string} 233 * @enum {string}
234 */ 234 */
235 WebInspector.TimelineAggregator.GroupBy = { 235 WebInspector.TimelineAggregator.GroupBy = {
236 None: "None", 236 None: "None",
237 EventName: "EventName", 237 EventName: "EventName",
238 Category: "Category", 238 Category: "Category",
239 Domain: "Domain", 239 Domain: "Domain",
240 Subdomain: "Subdomain", 240 Subdomain: "Subdomain",
241 URL: "URL" 241 URL: "URL"
242 } 242 };
243 243
244 /** 244 /**
245 * @param {!WebInspector.TracingModel.Event} event 245 * @param {!WebInspector.TracingModel.Event} event
246 * @return {string} 246 * @return {string}
247 */ 247 */
248 WebInspector.TimelineAggregator.eventId = function(event) 248 WebInspector.TimelineAggregator.eventId = function(event)
249 { 249 {
250 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) { 250 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) {
251 var data = event.args["data"]; 251 var data = event.args["data"];
252 return "f:" + data["functionName"] + "@" + (data["scriptId"] || data["ur l"] || ""); 252 return "f:" + data["functionName"] + "@" + (data["scriptId"] || data["ur l"] || "");
253 } 253 }
254 return event.name + ":@" + WebInspector.TimelineProfileTree.eventURL(event); 254 return event.name + ":@" + WebInspector.TimelineProfileTree.eventURL(event);
255 } 255 };
256 256
257 WebInspector.TimelineAggregator._extensionInternalPrefix = "extensions::"; 257 WebInspector.TimelineAggregator._extensionInternalPrefix = "extensions::";
258 WebInspector.TimelineAggregator._groupNodeFlag = Symbol("groupNode"); 258 WebInspector.TimelineAggregator._groupNodeFlag = Symbol("groupNode");
259 259
260 /** 260 /**
261 * @param {string} url 261 * @param {string} url
262 * @return {boolean} 262 * @return {boolean}
263 */ 263 */
264 WebInspector.TimelineAggregator.isExtensionInternalURL = function(url) 264 WebInspector.TimelineAggregator.isExtensionInternalURL = function(url)
265 { 265 {
266 return url.startsWith(WebInspector.TimelineAggregator._extensionInternalPref ix); 266 return url.startsWith(WebInspector.TimelineAggregator._extensionInternalPref ix);
267 } 267 };
268 268
269 WebInspector.TimelineAggregator.prototype = { 269 WebInspector.TimelineAggregator.prototype = {
270 /** 270 /**
271 * @param {!WebInspector.TimelineAggregator.GroupBy} groupBy 271 * @param {!WebInspector.TimelineAggregator.GroupBy} groupBy
272 * @return {?function(!WebInspector.TimelineProfileTree.Node):!WebInspector. TimelineProfileTree.Node} 272 * @return {?function(!WebInspector.TimelineProfileTree.Node):!WebInspector. TimelineProfileTree.Node}
273 */ 273 */
274 groupFunction: function(groupBy) 274 groupFunction: function(groupBy)
275 { 275 {
276 var idMapper = this._nodeToGroupIdFunction(groupBy); 276 var idMapper = this._nodeToGroupIdFunction(groupBy);
277 return idMapper && this._nodeToGroupNode.bind(this, idMapper); 277 return idMapper && this._nodeToGroupNode.bind(this, idMapper);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 /** 369 /**
370 * @param {function(!WebInspector.TimelineProfileTree.Node):string} nodeToGr oupId 370 * @param {function(!WebInspector.TimelineProfileTree.Node):string} nodeToGr oupId
371 * @param {!WebInspector.TimelineProfileTree.Node} node 371 * @param {!WebInspector.TimelineProfileTree.Node} node
372 * @return {!WebInspector.TimelineProfileTree.Node} 372 * @return {!WebInspector.TimelineProfileTree.Node}
373 */ 373 */
374 _nodeToGroupNode: function(nodeToGroupId, node) 374 _nodeToGroupNode: function(nodeToGroupId, node)
375 { 375 {
376 var id = nodeToGroupId(node); 376 var id = nodeToGroupId(node);
377 return this._groupNodes.get(id) || this._buildGroupNode(id, node.event); 377 return this._groupNodes.get(id) || this._buildGroupNode(id, node.event);
378 }, 378 },
379 } 379 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698