Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 24 matching lines...) Expand all Loading... | |
| 35 WebInspector.TimelineModel = function() | 35 WebInspector.TimelineModel = function() |
| 36 { | 36 { |
| 37 this._records = []; | 37 this._records = []; |
| 38 this._stringPool = new StringPool(); | 38 this._stringPool = new StringPool(); |
| 39 this._minimumRecordTime = -1; | 39 this._minimumRecordTime = -1; |
| 40 this._maximumRecordTime = -1; | 40 this._maximumRecordTime = -1; |
| 41 | 41 |
| 42 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineEventRecorded, this._onRecordAdded, this); | 42 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineEventRecorded, this._onRecordAdded, this); |
| 43 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineStarted, this._onStarted, this); | 43 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineStarted, this._onStarted, this); |
| 44 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineStopped, this._onStopped, this); | 44 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineStopped, this._onStopped, this); |
| 45 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.Event Types.PowerEventRecorded, this._onPowerEventAdded, this); | |
|
pfeldman
2014/01/09 11:38:52
Timeline model should not depend on any of the pro
Pan
2014/02/13 06:01:40
Hi @pfeldman, @qsr,
I'm thinking the first soluti
| |
| 45 } | 46 } |
| 46 | 47 |
| 47 WebInspector.TimelineModel.TransferChunkLengthBytes = 5000000; | 48 WebInspector.TimelineModel.TransferChunkLengthBytes = 5000000; |
| 48 | 49 |
| 49 WebInspector.TimelineModel.RecordType = { | 50 WebInspector.TimelineModel.RecordType = { |
| 50 Root: "Root", | 51 Root: "Root", |
| 51 Program: "Program", | 52 Program: "Program", |
| 52 EventDispatch: "EventDispatch", | 53 EventDispatch: "EventDispatch", |
| 53 | 54 |
| 54 GPUTask: "GPUTask", | 55 GPUTask: "GPUTask", |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 GCEvent: "GCEvent", | 96 GCEvent: "GCEvent", |
| 96 | 97 |
| 97 RequestAnimationFrame: "RequestAnimationFrame", | 98 RequestAnimationFrame: "RequestAnimationFrame", |
| 98 CancelAnimationFrame: "CancelAnimationFrame", | 99 CancelAnimationFrame: "CancelAnimationFrame", |
| 99 FireAnimationFrame: "FireAnimationFrame", | 100 FireAnimationFrame: "FireAnimationFrame", |
| 100 | 101 |
| 101 WebSocketCreate : "WebSocketCreate", | 102 WebSocketCreate : "WebSocketCreate", |
| 102 WebSocketSendHandshakeRequest : "WebSocketSendHandshakeRequest", | 103 WebSocketSendHandshakeRequest : "WebSocketSendHandshakeRequest", |
| 103 WebSocketReceiveHandshakeResponse : "WebSocketReceiveHandshakeResponse", | 104 WebSocketReceiveHandshakeResponse : "WebSocketReceiveHandshakeResponse", |
| 104 WebSocketDestroy : "WebSocketDestroy", | 105 WebSocketDestroy : "WebSocketDestroy", |
| 106 | |
| 107 SoC_Package : "SoC_Package", | |
| 105 } | 108 } |
| 106 | 109 |
| 107 WebInspector.TimelineModel.Events = { | 110 WebInspector.TimelineModel.Events = { |
| 108 RecordAdded: "RecordAdded", | 111 RecordAdded: "RecordAdded", |
| 109 RecordsCleared: "RecordsCleared", | 112 RecordsCleared: "RecordsCleared", |
| 110 RecordingStarted: "RecordingStarted", | 113 RecordingStarted: "RecordingStarted", |
| 111 RecordingStopped: "RecordingStopped" | 114 RecordingStopped: "RecordingStopped" |
| 112 } | 115 } |
| 113 | 116 |
| 114 WebInspector.TimelineModel.startTimeInSeconds = function(record) | 117 WebInspector.TimelineModel.startTimeInSeconds = function(record) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 } | 157 } |
| 155 | 158 |
| 156 WebInspector.TimelineModel.prototype = { | 159 WebInspector.TimelineModel.prototype = { |
| 157 /** | 160 /** |
| 158 * @param {boolean=} includeDomCounters | 161 * @param {boolean=} includeDomCounters |
| 159 */ | 162 */ |
| 160 startRecording: function(includeDomCounters) | 163 startRecording: function(includeDomCounters) |
| 161 { | 164 { |
| 162 this._clientInitiatedRecording = true; | 165 this._clientInitiatedRecording = true; |
| 163 this.reset(); | 166 this.reset(); |
| 167 | |
| 168 if (WebInspector.experimentsSettings.powerProfile.isEnabled()) | |
| 169 WebInspector.powerProfiler.startProfile(); | |
| 170 | |
| 164 var maxStackFrames = WebInspector.settings.timelineCaptureStacks.get() ? 30 : 0; | 171 var maxStackFrames = WebInspector.settings.timelineCaptureStacks.get() ? 30 : 0; |
| 165 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn abled(); | 172 var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEn abled(); |
| 166 WebInspector.timelineManager.start(maxStackFrames, includeDomCounters, i ncludeGPUEvents, this._fireRecordingStarted.bind(this)); | 173 WebInspector.timelineManager.start(maxStackFrames, includeDomCounters, i ncludeGPUEvents, this._fireRecordingStarted.bind(this)); |
| 167 }, | 174 }, |
| 168 | 175 |
| 169 stopRecording: function() | 176 stopRecording: function() |
| 170 { | 177 { |
| 171 if (!this._clientInitiatedRecording) { | 178 if (!this._clientInitiatedRecording) { |
| 172 // Console started this one and we are just sniffing it. Initiate re cording so that we | 179 // Console started this one and we are just sniffing it. Initiate re cording so that we |
| 173 // could stop it. | 180 // could stop it. |
| 174 function stopTimeline() | 181 function stopTimeline() |
| 175 { | 182 { |
| 176 WebInspector.timelineManager.stop(this._fireRecordingStopped.bin d(this)); | 183 WebInspector.timelineManager.stop(this._fireRecordingStopped.bin d(this)); |
| 177 } | 184 } |
| 178 | 185 |
| 179 WebInspector.timelineManager.start(undefined, undefined, undefined, stopTimeline.bind(this)); | 186 WebInspector.timelineManager.start(undefined, undefined, undefined, stopTimeline.bind(this)); |
| 180 return; | 187 return; |
| 181 } | 188 } |
| 182 this._clientInitiatedRecording = false; | 189 this._clientInitiatedRecording = false; |
| 183 WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this)) ; | 190 WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this)) ; |
| 191 | |
| 192 if (WebInspector.experimentsSettings.powerProfile.isEnabled()) | |
| 193 WebInspector.powerProfiler.stopProfile(); | |
| 184 }, | 194 }, |
| 185 | 195 |
| 186 get records() | 196 get records() |
| 187 { | 197 { |
| 188 return this._records; | 198 return this._records; |
| 189 }, | 199 }, |
| 190 | 200 |
| 191 /** | 201 /** |
| 192 * @param {WebInspector.Event} event | 202 * @param {WebInspector.Event} event |
| 193 */ | 203 */ |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 224 this._collectionEnabled = true; | 234 this._collectionEnabled = true; |
| 225 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStarted); | 235 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStarted); |
| 226 }, | 236 }, |
| 227 | 237 |
| 228 _fireRecordingStopped: function() | 238 _fireRecordingStopped: function() |
| 229 { | 239 { |
| 230 this._collectionEnabled = false; | 240 this._collectionEnabled = false; |
| 231 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 241 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
| 232 }, | 242 }, |
| 233 | 243 |
| 244 _onPowerEventAdded: function(event) | |
| 245 { | |
| 246 if (this._collectionEnabled) { | |
| 247 var records = event.data; | |
| 248 for(var item in records) { | |
| 249 records[item]["startTime"] = records[item].timestamp; | |
| 250 delete records[item].timestamp; | |
| 251 } | |
| 252 this._stringPool.internObjectStrings(records); | |
| 253 this._records = this._records.concat(records); | |
| 254 records.forEach(this._updateBoundaries.bind(this)); // shall we upda te boundary here? | |
| 255 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Reco rdAdded, records); | |
| 256 } | |
| 257 }, | |
| 258 | |
| 234 /** | 259 /** |
| 235 * @param {TimelineAgent.TimelineEvent} record | 260 * @param {TimelineAgent.TimelineEvent} record |
| 236 */ | 261 */ |
| 237 _addRecord: function(record) | 262 _addRecord: function(record) |
| 238 { | 263 { |
| 239 this._stringPool.internObjectStrings(record); | 264 this._stringPool.internObjectStrings(record); |
| 240 this._records.push(record); | 265 this._records.push(record); |
| 241 this._updateBoundaries(record); | 266 this._updateBoundaries(record); |
| 242 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAd ded, record); | 267 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAd ded, record); |
| 243 }, | 268 }, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 break; | 538 break; |
| 514 length += itemLength; | 539 length += itemLength; |
| 515 data.push(item); | 540 data.push(item); |
| 516 ++this._recordIndex; | 541 ++this._recordIndex; |
| 517 } | 542 } |
| 518 if (this._recordIndex === this._records.length) | 543 if (this._recordIndex === this._records.length) |
| 519 data.push(data.pop() + "]"); | 544 data.push(data.pop() + "]"); |
| 520 stream.write(data.join(separator), this._writeNextChunk.bind(this)); | 545 stream.write(data.join(separator), this._writeNextChunk.bind(this)); |
| 521 } | 546 } |
| 522 } | 547 } |
| OLD | NEW |