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

Side by Side Diff: Source/devtools/front_end/timeline/TimelineFrameModel.js

Issue 301593002: DevTools: process events from all threads in TimelineTraceEventBindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 records = this._mergingBuffer.process(record.thread(), /** type {Arr ay.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record])); 135 records = this._mergingBuffer.process(record.thread(), /** type {Arr ay.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record]));
136 for (var i = 0; i < records.length; ++i) { 136 for (var i = 0; i < records.length; ++i) {
137 if (records[i].thread()) 137 if (records[i].thread())
138 this._addBackgroundRecord(records[i]); 138 this._addBackgroundRecord(records[i]);
139 else 139 else
140 this._addMainThreadRecord(programRecord, records[i]); 140 this._addMainThreadRecord(programRecord, records[i]);
141 } 141 }
142 }, 142 },
143 143
144 /** 144 /**
145 * @param {!WebInspector.TracingModel} tracingModel 145 * @param {!Array.<!WebInspector.TracingModel.Event>} events
146 * @param {string} sessionId
146 */ 147 */
147 addTraceEvents: function(tracingModel) 148 addTraceEvents: function(events, sessionId)
148 { 149 {
149 // FIXME: we also need to process main thread events, so we can assign t ime spent by categories 150 this._sessionId = sessionId;
150 // to frames. However, this requires that we can map trace event names t o Timeline categories.
151 var events = tracingModel.frameLifecycleEvents();
152 for (var i = 0; i < events.length; ++i) 151 for (var i = 0; i < events.length; ++i)
153 this._addTraceEvent(events[i]); 152 this._addTraceEvent(events[i]);
154 }, 153 },
155 154
156 /** 155 /**
157 * @param {!WebInspector.TracingModel.Event} event 156 * @param {!WebInspector.TracingModel.Event} event
158 */ 157 */
159 _addTraceEvent: function(event) 158 _addTraceEvent: function(event)
160 { 159 {
160 var eventNames = WebInspector.TimelineTraceEventBindings.RecordType;
161
162 if (event.name === eventNames.SetLayerTreeId) {
163 if (this._sessionId === event.args["sessionId"])
164 this._layerTreeId = event.args["layerTreeId"];
165 return;
166 }
167 if (event.phase === WebInspector.TracingModel.Phase.SnapshotObject && ev ent.name === eventNames.LayerTreeHostImplSnapshot && parseInt(event.id, 0) === t his._layerTreeId) {
168 this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTr ee(this.target(), event.args["snapshot"]["active_tree"]["root_layer"]));
169 return;
170 }
171
172 if (event.args["layerTreeId"] !== this._layerTreeId)
173 return;
174
161 var timestamp = event.startTime / 1000; 175 var timestamp = event.startTime / 1000;
162 var eventNames = WebInspector.TracingModel.TraceEventName;
163
164 if (event.name === eventNames.BeginFrame) 176 if (event.name === eventNames.BeginFrame)
165 this.handleBeginFrame(timestamp); 177 this.handleBeginFrame(timestamp);
166 else if (event.name === eventNames.DrawFrame) 178 else if (event.name === eventNames.DrawFrame)
167 this.handleDrawFrame(timestamp); 179 this.handleDrawFrame(timestamp);
168 else if (event.name === eventNames.ActivateLayerTree) 180 else if (event.name === eventNames.ActivateLayerTree)
169 this.handleActivateLayerTree(); 181 this.handleActivateLayerTree();
170 else if (event.name === eventNames.RequestMainThreadFrame) 182 else if (event.name === eventNames.RequestMainThreadFrame)
171 this.handleRequestMainThreadFrame(); 183 this.handleRequestMainThreadFrame();
172 else if (event.name === eventNames.CompositeLayers) 184 else if (event.name === eventNames.CompositeLayers)
173 this.handleCompositeLayers(); 185 this.handleCompositeLayers();
174 else if (event.name === eventNames.LayerTreeHostImplSnapshot) 186
175 this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTr ee(this.target(), event.args["snapshot"]["active_tree"]["root_layer"])); 187 // FIXME: we also need to process main thread events, so we can assign t ime spent by categories
188 // to frames. However, this requires that we can map trace event names t o Timeline categories.
176 }, 189 },
177 190
178 /** 191 /**
179 * @param {number} startTime 192 * @param {number} startTime
180 */ 193 */
181 handleBeginFrame: function(startTime) 194 handleBeginFrame: function(startTime)
182 { 195 {
183 if (!this._lastFrame) 196 if (!this._lastFrame)
184 this._startBackgroundFrame(startTime); 197 this._startBackgroundFrame(startTime);
185 }, 198 },
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 this._updateCpuTime(); 459 this._updateCpuTime();
447 }, 460 },
448 461
449 _updateCpuTime: function() 462 _updateCpuTime: function()
450 { 463 {
451 this.cpuTime = 0; 464 this.cpuTime = 0;
452 for (var key in this.timeByCategory) 465 for (var key in this.timeByCategory)
453 this.cpuTime += this.timeByCategory[key]; 466 this.cpuTime += this.timeByCategory[key];
454 } 467 }
455 } 468 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineFlameChart.js ('k') | Source/devtools/front_end/timeline/TimelineModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698