Chromium Code Reviews| Index: Source/devtools/front_end/sdk/TracingModel.js |
| diff --git a/Source/devtools/front_end/sdk/TracingModel.js b/Source/devtools/front_end/sdk/TracingModel.js |
| index e5e1d7cdd0e40fa2c491873f76cc39c6d663ad05..ad71127197d48ed807fe5610a82c0d90286bb4a0 100644 |
| --- a/Source/devtools/front_end/sdk/TracingModel.js |
| +++ b/Source/devtools/front_end/sdk/TracingModel.js |
| @@ -122,8 +122,8 @@ WebInspector.TracingModel.isFlowPhase = function(phase) |
| */ |
| WebInspector.TracingModel.isTopLevelEvent = function(event) |
| { |
| - return event.category === WebInspector.TracingModel.TopLevelEventCategory || |
| - event.category === WebInspector.TracingModel.DevToolsMetadataEventCategory && event.name === "Program"; // Older timelines may have this instead of toplevel. |
| + return event.hasCategory(WebInspector.TracingModel.TopLevelEventCategory) || |
| + event.hasCategory(WebInspector.TracingModel.DevToolsMetadataEventCategory) && event.name === "Program"; // Older timelines may have this instead of toplevel. |
| } |
| /** |
| @@ -225,6 +225,8 @@ WebInspector.TracingModel.prototype = { |
| this._openAsyncEvents = new Map(); |
| /** @type {!Map<string, !Array<!WebInspector.TracingModel.AsyncEvent>>} */ |
| this._openNestableAsyncEvents = new Map(); |
| + /** @type {!Map<string, !Array<string>>} */ |
| + this._parsedCategories = new Map(); |
| }, |
| /** |
| @@ -234,7 +236,7 @@ WebInspector.TracingModel.prototype = { |
| { |
| var process = this._processById[payload.pid]; |
| if (!process) { |
| - process = new WebInspector.TracingModel.Process(payload.pid); |
| + process = new WebInspector.TracingModel.Process(this, payload.pid); |
| this._processById[payload.pid] = process; |
| } |
| @@ -269,11 +271,11 @@ WebInspector.TracingModel.prototype = { |
| this._asyncEvents.push(event); |
| event._setBackingStorage(backingStorage); |
| if (event.name === WebInspector.TracingModel.DevToolsMetadataEvent.TracingStartedInPage && |
| - event.category === WebInspector.TracingModel.DevToolsMetadataEventCategory) { |
| + event.hasCategory(WebInspector.TracingModel.DevToolsMetadataEventCategory)) { |
| this._devtoolsPageMetadataEvents.push(event); |
| } |
| if (event.name === WebInspector.TracingModel.DevToolsMetadataEvent.TracingSessionIdForWorker && |
| - event.category === WebInspector.TracingModel.DevToolsMetadataEventCategory) { |
| + event.hasCategory(WebInspector.TracingModel.DevToolsMetadataEventCategory)) { |
| this._devtoolsWorkerMetadataEvents.push(event); |
| } |
| return; |
| @@ -422,7 +424,7 @@ WebInspector.TracingModel.prototype = { |
| _addNestableAsyncEvent: function(event) |
| { |
| var phase = WebInspector.TracingModel.Phase; |
| - var key = event.category + "." + event.id; |
| + var key = event.categoriesString + "." + event.id; |
| var openEventsStack = this._openNestableAsyncEvents.get(key); |
| switch (event.phase) { |
| @@ -459,7 +461,7 @@ WebInspector.TracingModel.prototype = { |
| _addAsyncEvent: function(event) |
| { |
| var phase = WebInspector.TracingModel.Phase; |
| - var key = event.category + "." + event.name + "." + event.id; |
| + var key = event.categoriesString + "." + event.name + "." + event.id; |
| var asyncEvent = this._openAsyncEvents.get(key); |
| if (event.phase === phase.AsyncBegin) { |
| @@ -492,6 +494,20 @@ WebInspector.TracingModel.prototype = { |
| } |
| console.assert(false, "Invalid async event phase"); |
| }, |
| + |
| + /** |
| + * @param {string} str |
| + * @return {!Array<string>} |
| + */ |
| + _parsedCategoriesForString: function(str) |
| + { |
| + var parsedCategories = this._parsedCategories.get(str); |
| + if (!parsedCategories) { |
| + parsedCategories = str.split(","); |
| + this._parsedCategories.set(str, parsedCategories); |
| + } |
| + return parsedCategories; |
| + } |
| } |
| /** |
| @@ -527,16 +543,18 @@ WebInspector.TracingModel.Loader.prototype = { |
| /** |
| * @constructor |
| - * @param {string} category |
| + * @param {string} categories |
| * @param {string} name |
| * @param {!WebInspector.TracingModel.Phase} phase |
| * @param {number} startTime |
| * @param {!WebInspector.TracingModel.Thread} thread |
| */ |
| -WebInspector.TracingModel.Event = function(category, name, phase, startTime, thread) |
| +WebInspector.TracingModel.Event = function(categories, name, phase, startTime, thread) |
| { |
| /** @type {string} */ |
| - this.category = category; |
| + this.categoriesString = categories; |
| + /** @type {!Array<string>} */ |
| + this._parsedCategories = thread._model._parsedCategoriesForString(categories); |
| /** @type {string} */ |
| this.name = name; |
| /** @type {!WebInspector.TracingModel.Phase} */ |
| @@ -586,6 +604,15 @@ WebInspector.TracingModel.Event.fromPayload = function(payload, thread) |
| WebInspector.TracingModel.Event.prototype = { |
| /** |
| + * @param {string} categoryName |
| + * @return {boolean} |
| + */ |
| + hasCategory: function(categoryName) |
| + { |
| + return this._parsedCategories.indexOf(categoryName) >= 0; |
|
alph
2015/06/25 09:50:14
I'd expect it to be a Set.
|
| + }, |
| + |
| + /** |
| * @param {number} endTime |
| */ |
| setEndTime: function(endTime) |
| @@ -749,7 +776,7 @@ WebInspector.TracingModel.ObjectSnapshot.prototype = { |
| */ |
| WebInspector.TracingModel.AsyncEvent = function(startEvent) |
| { |
| - WebInspector.TracingModel.Event.call(this, startEvent.category, startEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread) |
| + WebInspector.TracingModel.Event.call(this, startEvent.categoriesString, startEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread) |
| this.addArgs(startEvent.args); |
| this.steps = [startEvent]; |
| } |
| @@ -825,9 +852,10 @@ WebInspector.TracingModel.NamedObject._sort = function(array) |
| /** |
| * @constructor |
| * @extends {WebInspector.TracingModel.NamedObject} |
| + * @param {!WebInspector.TracingModel} model |
| * @param {number} id |
| */ |
| -WebInspector.TracingModel.Process = function(id) |
| +WebInspector.TracingModel.Process = function(model, id) |
| { |
| WebInspector.TracingModel.NamedObject.call(this); |
| this._setName("Process " + id); |
| @@ -835,6 +863,7 @@ WebInspector.TracingModel.Process = function(id) |
| /** @type {!Object.<number, !WebInspector.TracingModel.Thread>} */ |
| this._threads = {}; |
| this._threadByName = new Map(); |
| + this._model = model; |
| } |
| WebInspector.TracingModel.Process.prototype = { |
| @@ -912,6 +941,7 @@ WebInspector.TracingModel.Thread = function(process, id) |
| this._events = []; |
| this._asyncEvents = []; |
| this._id = id; |
| + this._model = process._model; |
| } |
| WebInspector.TracingModel.Thread.prototype = { |
| @@ -943,7 +973,7 @@ WebInspector.TracingModel.Thread.prototype = { |
| if (!stack.length) |
| continue; |
| var top = stack.pop(); |
| - if (top.name !== e.name || top.category !== e.category) |
| + if (top.name !== e.name || top.categoriesString !== e.categoriesString) |
| console.error("B/E events mismatch at " + top.startTime + " (" + top.name + ") vs. " + e.startTime + " (" + e.name + ")"); |
| else |
| top._complete(e); |