OLD | NEW |
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() |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return event.args["data"]; | 211 return event.args["data"]; |
212 var topFrame = event.stackTrace && event.stackTrace[0]; | 212 var topFrame = event.stackTrace && event.stackTrace[0]; |
213 if (topFrame) | 213 if (topFrame) |
214 return topFrame; | 214 return topFrame; |
215 var initiator = event.initiator; | 215 var initiator = event.initiator; |
216 return initiator && initiator.stackTrace && initiator.stackTrace[0] || null; | 216 return initiator && initiator.stackTrace && initiator.stackTrace[0] || null; |
217 } | 217 } |
218 | 218 |
219 /** | 219 /** |
220 * @constructor | 220 * @constructor |
221 * @param {function(!WebInspector.TracingModel.Event):{title: string, category:
!WebInspector.TimelineCategory}} eventStyleMapper | 221 * @param {function(!WebInspector.TracingModel.Event):string} titleMapper |
| 222 * @param {function(!WebInspector.TracingModel.Event):string} categoryMapper |
222 */ | 223 */ |
223 WebInspector.TimelineAggregator = function(eventStyleMapper) | 224 WebInspector.TimelineAggregator = function(titleMapper, categoryMapper) |
224 { | 225 { |
225 this._eventStyleMapper = eventStyleMapper; | 226 this._titleMapper = titleMapper; |
| 227 this._categoryMapper = categoryMapper; |
226 /** @type {!Map<string, !WebInspector.TimelineProfileTree.Node>} */ | 228 /** @type {!Map<string, !WebInspector.TimelineProfileTree.Node>} */ |
227 this._groupNodes = new Map(); | 229 this._groupNodes = new Map(); |
228 } | 230 } |
229 | 231 |
230 /** | 232 /** |
231 * @enum {string} | 233 * @enum {string} |
232 */ | 234 */ |
233 WebInspector.TimelineAggregator.GroupBy = { | 235 WebInspector.TimelineAggregator.GroupBy = { |
234 None: "None", | 236 None: "None", |
235 EventName: "EventName", | 237 EventName: "EventName", |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (!groupSubdomains) | 332 if (!groupSubdomains) |
331 return parsedURL.host; | 333 return parsedURL.host; |
332 if (/^[.0-9]+$/.test(parsedURL.host)) | 334 if (/^[.0-9]+$/.test(parsedURL.host)) |
333 return parsedURL.host; | 335 return parsedURL.host; |
334 var domainMatch = /([^.]*\.)?[^.]*$/.exec(parsedURL.host); | 336 var domainMatch = /([^.]*\.)?[^.]*$/.exec(parsedURL.host); |
335 return domainMatch && domainMatch[0] || ""; | 337 return domainMatch && domainMatch[0] || ""; |
336 } | 338 } |
337 | 339 |
338 switch (groupBy) { | 340 switch (groupBy) { |
339 case WebInspector.TimelineAggregator.GroupBy.None: return null; | 341 case WebInspector.TimelineAggregator.GroupBy.None: return null; |
340 case WebInspector.TimelineAggregator.GroupBy.EventName: return node => n
ode.event ? this._eventStyleMapper(node.event).title : ""; | 342 case WebInspector.TimelineAggregator.GroupBy.EventName: return node => n
ode.event ? this._titleMapper(node.event) : ""; |
341 case WebInspector.TimelineAggregator.GroupBy.Category: return node => no
de.event ? this._eventStyleMapper(node.event).category.name : ""; | 343 case WebInspector.TimelineAggregator.GroupBy.Category: return node => no
de.event ? this._categoryMapper(node.event) : ""; |
342 case WebInspector.TimelineAggregator.GroupBy.Subdomain: return groupByDo
main.bind(null, false); | 344 case WebInspector.TimelineAggregator.GroupBy.Subdomain: return groupByDo
main.bind(null, false); |
343 case WebInspector.TimelineAggregator.GroupBy.Domain: return groupByDomai
n.bind(null, true); | 345 case WebInspector.TimelineAggregator.GroupBy.Domain: return groupByDomai
n.bind(null, true); |
344 case WebInspector.TimelineAggregator.GroupBy.URL: return groupByURL; | 346 case WebInspector.TimelineAggregator.GroupBy.URL: return groupByURL; |
345 default: return null; | 347 default: return null; |
346 } | 348 } |
347 }, | 349 }, |
348 | 350 |
349 /** | 351 /** |
350 * @param {string} id | 352 * @param {string} id |
351 * @param {!WebInspector.TracingModel.Event} event | 353 * @param {!WebInspector.TracingModel.Event} event |
(...skipping 16 matching lines...) Expand all Loading... |
368 * @param {function(!WebInspector.TimelineProfileTree.Node):string} nodeToGr
oupId | 370 * @param {function(!WebInspector.TimelineProfileTree.Node):string} nodeToGr
oupId |
369 * @param {!WebInspector.TimelineProfileTree.Node} node | 371 * @param {!WebInspector.TimelineProfileTree.Node} node |
370 * @return {!WebInspector.TimelineProfileTree.Node} | 372 * @return {!WebInspector.TimelineProfileTree.Node} |
371 */ | 373 */ |
372 _nodeToGroupNode: function(nodeToGroupId, node) | 374 _nodeToGroupNode: function(nodeToGroupId, node) |
373 { | 375 { |
374 var id = nodeToGroupId(node); | 376 var id = nodeToGroupId(node); |
375 return this._groupNodes.get(id) || this._buildGroupNode(id, node.event); | 377 return this._groupNodes.get(id) || this._buildGroupNode(id, node.event); |
376 }, | 378 }, |
377 } | 379 } |
OLD | NEW |