Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
| 34 */ | 34 */ |
| 35 WebInspector.TimelineManager = function() | 35 WebInspector.TimelineManager = function() |
| 36 { | 36 { |
| 37 WebInspector.Object.call(this); | 37 WebInspector.Object.call(this); |
| 38 this._dispatcher = new WebInspector.TimelineDispatcher(this); | 38 this._dispatcher = new WebInspector.TimelineDispatcher(this); |
| 39 this._enablementCount = 0; | 39 this._enablementCount = 0; |
| 40 TimelineAgent.enable(); | |
| 40 } | 41 } |
| 41 | 42 |
| 42 WebInspector.TimelineManager.EventTypes = { | 43 WebInspector.TimelineManager.EventTypes = { |
| 43 TimelineStarted: "TimelineStarted", | 44 TimelineStarted: "TimelineStarted", |
| 44 TimelineStopped: "TimelineStopped", | 45 TimelineStopped: "TimelineStopped", |
| 45 TimelineEventRecorded: "TimelineEventRecorded" | 46 TimelineEventRecorded: "TimelineEventRecorded" |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebInspector.TimelineManager.prototype = { | 49 WebInspector.TimelineManager.prototype = { |
| 49 /** | 50 /** |
| 50 * @param {number=} maxCallStackDepth | 51 * @param {number=} maxCallStackDepth |
| 51 * @param {boolean=} includeDomCounters | 52 * @param {boolean=} includeDomCounters |
| 52 * @param {boolean=} includeNativeMemoryStatistics | 53 * @param {boolean=} includeNativeMemoryStatistics |
| 54 * @param {function(?Protocol.Error)=} callback | |
| 53 */ | 55 */ |
| 54 start: function(maxCallStackDepth, includeDomCounters, includeNativeMemorySt atistics) | 56 start: function(maxCallStackDepth, includeDomCounters, includeNativeMemorySt atistics, callback) |
| 55 { | 57 { |
| 56 this._enablementCount++; | 58 this._enablementCount++; |
| 57 if (this._enablementCount === 1) | 59 if (this._enablementCount === 1) |
| 58 TimelineAgent.start(maxCallStackDepth, includeDomCounters, includeNa tiveMemoryStatistics, this._started.bind(this)); | 60 TimelineAgent.start(maxCallStackDepth, includeDomCounters, includeNa tiveMemoryStatistics, callback); |
| 61 else if (callback) | |
| 62 callback(null); | |
| 59 }, | 63 }, |
| 60 | 64 |
| 61 stop: function() | 65 /** |
| 66 * @param {function(?Protocol.Error)=} callback | |
| 67 */ | |
| 68 stop: function(callback) | |
| 62 { | 69 { |
| 63 if (!this._enablementCount) { | 70 this._enablementCount--; |
| 64 console.error("WebInspector.TimelineManager start/stop calls are unb alanced"); | 71 if (this._enablementCount < 0) { |
|
caseq
2013/09/13 15:00:23
So if we actually hit this, we now let enablemenet
pfeldman
2013/09/13 15:21:03
Yes, it is anyways impossible to recover from the
| |
| 72 console.error("WebInspector.TimelineManager start/stop calls are unb alanced " + new Error().stack); | |
| 65 return; | 73 return; |
| 66 } | 74 } |
| 67 this._enablementCount--; | |
| 68 if (!this._enablementCount) | 75 if (!this._enablementCount) |
| 69 TimelineAgent.stop(this._stopped.bind(this)); | 76 TimelineAgent.stop(callback); |
| 70 }, | 77 else if (callback) |
| 71 | 78 callback(null); |
| 72 _started: function() | |
| 73 { | |
| 74 this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.Ti melineStarted); | |
| 75 }, | |
| 76 | |
| 77 _stopped: function() | |
| 78 { | |
| 79 this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.Ti melineStopped); | |
| 80 }, | 79 }, |
| 81 | 80 |
| 82 __proto__: WebInspector.Object.prototype | 81 __proto__: WebInspector.Object.prototype |
| 83 } | 82 } |
| 84 | 83 |
| 85 /** | 84 /** |
| 86 * @constructor | 85 * @constructor |
| 87 * @implements {TimelineAgent.Dispatcher} | 86 * @implements {TimelineAgent.Dispatcher} |
| 88 */ | 87 */ |
| 89 WebInspector.TimelineDispatcher = function(manager) | 88 WebInspector.TimelineDispatcher = function(manager) |
| 90 { | 89 { |
| 91 this._manager = manager; | 90 this._manager = manager; |
| 92 InspectorBackend.registerTimelineDispatcher(this); | 91 InspectorBackend.registerTimelineDispatcher(this); |
| 93 } | 92 } |
| 94 | 93 |
| 95 WebInspector.TimelineDispatcher.prototype = { | 94 WebInspector.TimelineDispatcher.prototype = { |
| 95 /** | |
| 96 * @param {TimelineAgent.TimelineEvent} record | |
| 97 */ | |
| 96 eventRecorded: function(record) | 98 eventRecorded: function(record) |
| 97 { | 99 { |
| 98 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineEventRecorded, record); | 100 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineEventRecorded, record); |
| 101 }, | |
| 102 | |
| 103 /** | |
| 104 * @param {boolean=} consoleTimeline | |
| 105 */ | |
| 106 started: function(consoleTimeline) | |
| 107 { | |
| 108 if (consoleTimeline) { | |
| 109 // Wake up timeline panel module. | |
| 110 WebInspector.panel("timeline"); | |
| 111 } | |
| 112 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStarted, consoleTimeline); | |
| 113 }, | |
| 114 | |
| 115 /** | |
| 116 * @param {boolean=} consoleTimeline | |
| 117 */ | |
| 118 stopped: function(consoleTimeline) | |
| 119 { | |
| 120 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStopped, consoleTimeline); | |
| 99 } | 121 } |
| 100 } | 122 } |
| 101 | 123 |
| 102 /** | 124 /** |
| 103 * @type {WebInspector.TimelineManager} | 125 * @type {WebInspector.TimelineManager} |
| 104 */ | 126 */ |
| 105 WebInspector.timelineManager; | 127 WebInspector.timelineManager; |
| OLD | NEW |