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

Side by Side Diff: Source/devtools/front_end/TimelineManager.js

Issue 24027002: DevTools: implement console.timeline/timelineEnd. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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) 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 TimelineStarted: "TimelineStarted", 43 TimelineStarted: "TimelineStarted",
44 TimelineStopped: "TimelineStopped", 44 TimelineStopped: "TimelineStopped",
45 TimelineEventRecorded: "TimelineEventRecorded" 45 TimelineEventRecorded: "TimelineEventRecorded"
46 } 46 }
47 47
48 WebInspector.TimelineManager.prototype = { 48 WebInspector.TimelineManager.prototype = {
49 /** 49 /**
50 * @param {number=} maxCallStackDepth 50 * @param {number=} maxCallStackDepth
51 * @param {boolean=} includeDomCounters 51 * @param {boolean=} includeDomCounters
52 * @param {boolean=} includeNativeMemoryStatistics 52 * @param {boolean=} includeNativeMemoryStatistics
53 * @param {function(?Protocol.Error)=} callback
53 */ 54 */
54 start: function(maxCallStackDepth, includeDomCounters, includeNativeMemorySt atistics) 55 start: function(maxCallStackDepth, includeDomCounters, includeNativeMemorySt atistics, callback)
55 { 56 {
56 this._enablementCount++; 57 this._enablementCount++;
57 if (this._enablementCount === 1) 58 if (this._enablementCount === 1)
58 TimelineAgent.start(maxCallStackDepth, includeDomCounters, includeNa tiveMemoryStatistics, this._started.bind(this)); 59 TimelineAgent.start(maxCallStackDepth, includeDomCounters, includeNa tiveMemoryStatistics, callback);
60 else if (callback)
61 callback(null);
59 }, 62 },
60 63
61 stop: function() 64 /**
65 * @param {function(?Protocol.Error)=} callback
66 */
67 stop: function(callback)
62 { 68 {
63 if (!this._enablementCount) { 69 if (!this._enablementCount) {
64 console.error("WebInspector.TimelineManager start/stop calls are unb alanced"); 70 console.error("WebInspector.TimelineManager start/stop calls are unb alanced");
65 return; 71 return;
66 } 72 }
67 this._enablementCount--; 73 this._enablementCount--;
68 if (!this._enablementCount) 74 if (!this._enablementCount)
69 TimelineAgent.stop(this._stopped.bind(this)); 75 TimelineAgent.stop(callback);
70 }, 76 else if (callback)
71 77 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 }, 78 },
81 79
82 __proto__: WebInspector.Object.prototype 80 __proto__: WebInspector.Object.prototype
83 } 81 }
84 82
85 /** 83 /**
86 * @constructor 84 * @constructor
87 * @implements {TimelineAgent.Dispatcher} 85 * @implements {TimelineAgent.Dispatcher}
88 */ 86 */
89 WebInspector.TimelineDispatcher = function(manager) 87 WebInspector.TimelineDispatcher = function(manager)
90 { 88 {
91 this._manager = manager; 89 this._manager = manager;
92 InspectorBackend.registerTimelineDispatcher(this); 90 InspectorBackend.registerTimelineDispatcher(this);
93 } 91 }
94 92
95 WebInspector.TimelineDispatcher.prototype = { 93 WebInspector.TimelineDispatcher.prototype = {
94 /**
95 * @param {TimelineAgent.TimelineEvent} record
96 */
96 eventRecorded: function(record) 97 eventRecorded: function(record)
97 { 98 {
98 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineEventRecorded, record); 99 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineEventRecorded, record);
100 },
101
102 /**
103 * @param {boolean=} consoleTimeline
104 */
105 started: function(consoleTimeline)
106 {
107 if (consoleTimeline)
108 this._manager._enablementCount++;
caseq 2013/09/06 09:25:46 So what happens if pages does console.timeline() a
pfeldman 2013/09/06 16:10:30 Good catch. InspectorTimelineAgent::restore is now
109 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStarted, consoleTimeline);
110 },
111
112 /**
113 * @param {boolean=} consoleTimeline
114 */
115 stopped: function(consoleTimeline)
116 {
117 if (consoleTimeline)
118 this._manager._enablementCount--;
119 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStopped, consoleTimeline);
99 } 120 }
100 } 121 }
101 122
102 /** 123 /**
103 * @type {WebInspector.TimelineManager} 124 * @type {WebInspector.TimelineManager}
104 */ 125 */
105 WebInspector.timelineManager; 126 WebInspector.timelineManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698