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

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

Issue 709423002: DevTools: remove old Timeline front-end implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated LayoutTests/inspector/layers/layer-canvas-log.html Created 6 years, 1 month 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
« no previous file with comments | « Source/devtools/front_end/sdk/Target.js ('k') | Source/devtools/front_end/sdk/module.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /**
32 * @constructor
33 * @extends {WebInspector.SDKModel}
34 * @param {!WebInspector.Target} target
35 */
36 WebInspector.TimelineManager = function(target)
37 {
38 WebInspector.SDKModel.call(this, WebInspector.TimelineManager, target);
39 this._dispatcher = new WebInspector.TimelineDispatcher(this);
40 this._enablementCount = 0;
41 target.timelineAgent().enable();
42 }
43
44 WebInspector.TimelineManager.EventTypes = {
45 TimelineStarted: "TimelineStarted",
46 TimelineStopped: "TimelineStopped",
47 TimelineEventRecorded: "TimelineEventRecorded",
48 TimelineProgress: "TimelineProgress"
49 }
50
51 WebInspector.TimelineManager.prototype = {
52 /**
53 * @return {boolean}
54 */
55 isStarted: function()
56 {
57 return this._dispatcher.isStarted();
58 },
59
60 /**
61 * @param {number=} maxCallStackDepth
62 * @param {string=} liveEvents
63 * @param {boolean=} includeCounters
64 * @param {boolean=} includeGPUEvents
65 * @param {function(?Protocol.Error)=} callback
66 */
67 start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEv ents, callback)
68 {
69 this._enablementCount++;
70 WebInspector.targetManager.suspendAllTargets();
71 if (this._enablementCount === 1)
72 this.target().timelineAgent().start(maxCallStackDepth, true, liveEve nts, includeCounters, includeGPUEvents, callback);
73 else if (callback)
74 callback(null);
75 },
76
77 /**
78 * @param {function(?Protocol.Error)} callback
79 */
80 stop: function(callback)
81 {
82 this._enablementCount--;
83 if (this._enablementCount < 0) {
84 console.error("WebInspector.TimelineManager start/stop calls are unb alanced " + new Error().stack);
85 return;
86 }
87
88 if (!this._enablementCount)
89 this.target().timelineAgent().stop(allDoneCallback);
90
91 /**
92 * @param {?Protocol.Error} error
93 */
94 function allDoneCallback(error)
95 {
96 WebInspector.targetManager.resumeAllTargets();
97 callback(error);
98 }
99 },
100
101 /**
102 * @param {boolean=} consoleTimeline
103 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
104 */
105 _stopped: function(consoleTimeline, events)
106 {
107 var data = {
108 consoleTimeline: consoleTimeline,
109 events: events || []
110 };
111 this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.Ti melineStopped, data);
112 },
113
114 __proto__: WebInspector.SDKModel.prototype
115 }
116
117 /**
118 * @constructor
119 * @implements {TimelineAgent.Dispatcher}
120 */
121 WebInspector.TimelineDispatcher = function(manager)
122 {
123 this._manager = manager;
124 this._manager.target().registerTimelineDispatcher(this);
125 }
126
127 WebInspector.TimelineDispatcher.prototype = {
128 /**
129 * @param {!TimelineAgent.TimelineEvent} record
130 */
131 eventRecorded: function(record)
132 {
133 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineEventRecorded, record);
134 },
135
136 /**
137 * @return {boolean}
138 */
139 isStarted: function()
140 {
141 return !!this._started;
142 },
143
144 /**
145 * @param {boolean=} consoleTimeline
146 */
147 started: function(consoleTimeline)
148 {
149 this._started = true;
150 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStarted, consoleTimeline);
151 },
152
153 /**
154 * @param {boolean=} consoleTimeline
155 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
156 */
157 stopped: function(consoleTimeline, events)
158 {
159 this._started = false;
160 this._manager._stopped(consoleTimeline, events);
161 },
162
163 /**
164 * @param {number} count
165 */
166 progress: function(count)
167 {
168 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineProgress, count);
169 }
170 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/Target.js ('k') | Source/devtools/front_end/sdk/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698