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

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

Issue 563463003: DevTools: extract TracingManager from TracingModel, step 2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * @constructor 8 * @constructor
9 * @extends {WebInspector.Object}
10 * @implements {WebInspector.TargetManager.Observer}
11 */
12 WebInspector.TracingManager = function()
13 {
14 WebInspector.Object.call(this);
15 this._active = false;
16 WebInspector.targetManager.observeTargets(this);
17 }
18
19 WebInspector.TracingManager.Events = {
20 "BufferUsage": "BufferUsage",
21 "TracingStarted": "TracingStarted",
22 "EventsCollected": "EventsCollected",
23 "TracingStopped": "TracingStopped",
24 "TracingComplete": "TracingComplete"
25 }
26
27 /** @typedef {!{
28 cat: string,
29 pid: number,
30 tid: number,
31 ts: number,
32 ph: string,
33 name: string,
34 args: !Object,
35 dur: number,
36 id: number,
37 s: string
38 }}
39 */
40 WebInspector.TracingManager.EventPayload;
41
42
43 WebInspector.TracingManager.prototype = {
44 /**
45 * @param {!WebInspector.Target} target
46 */
47 targetAdded: function(target)
48 {
49 if (this._target)
50 return;
51 this._target = target;
52 InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispa tcher(this));
53 },
54
55 /**
56 * @param {!WebInspector.Target} target
57 */
58 targetRemoved: function(target)
59 {
60 if (this._target !== target)
61 return;
62 delete this._target;
63 },
64
65 /**
66 * @param {number} usage
67 */
68 _bufferUsage: function(usage)
69 {
70 this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferU sage, usage);
71 },
72
73 /**
74 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
75 */
76 _eventsCollected: function(events)
77 {
78 this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsC ollected, events);
79 },
80
81 _tracingComplete: function()
82 {
83 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Complete);
84 },
85
86 _tracingStarted: function()
87 {
88 if (this._active)
89 return;
90 this._active = true;
91 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Started);
92 },
93
94 /**
95 * @param {string} categoryFilter
96 * @param {string} options
97 * @param {function(?string)=} callback
98 */
99 start: function(categoryFilter, options, callback)
100 {
101 if (this._active)
102 return;
103 WebInspector.profilingLock().acquire();
104 this._shouldReleaseLock = true;
105 var bufferUsageReportingIntervalMs = 500;
106 TracingAgent.start(categoryFilter, options, bufferUsageReportingInterval Ms, callback);
107 this._tracingStarted();
108 this._active = true;
109 },
110
111 stop: function()
112 {
113 if (!this._active)
114 return;
115 TracingAgent.end(this._onStop.bind(this));
116 if (this._shouldReleaseLock) {
117 this._shouldReleaseLock = false;
118 WebInspector.profilingLock().release();
119 }
120 },
121
122 _onStop: function()
123 {
124 if (!this._active)
125 return;
126 this.dispatchEventToListeners(WebInspector.TracingManager.Events.Tracing Stopped);
127 this._active = false;
128 },
129
130 __proto__: WebInspector.Object.prototype
131 }
132
133 /**
134 * @constructor
135 */ 9 */
136 WebInspector.TracingModel = function() 10 WebInspector.TracingModel = function()
137 { 11 {
138 this.reset(); 12 this.reset();
139 } 13 }
140 14
141 /** 15 /**
142 * @enum {string} 16 * @enum {string}
143 */ 17 */
144 WebInspector.TracingModel.Phase = { 18 WebInspector.TracingModel.Phase = {
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 /** 662 /**
789 * @return {!Array.<!WebInspector.TracingModel.Event>} 663 * @return {!Array.<!WebInspector.TracingModel.Event>}
790 */ 664 */
791 asyncEvents: function() 665 asyncEvents: function()
792 { 666 {
793 return this._asyncEvents; 667 return this._asyncEvents;
794 }, 668 },
795 669
796 __proto__: WebInspector.TracingModel.NamedObject.prototype 670 __proto__: WebInspector.TracingModel.NamedObject.prototype
797 } 671 }
798
799
800 /**
801 * @constructor
802 * @implements {TracingAgent.Dispatcher}
803 * @param {!WebInspector.TracingManager} tracingManager
804 */
805 WebInspector.TracingDispatcher = function(tracingManager)
806 {
807 this._tracingManager = tracingManager;
808 }
809
810 WebInspector.TracingDispatcher.prototype = {
811 /**
812 * @param {number} usage
813 */
814 bufferUsage: function(usage)
815 {
816 this._tracingManager._bufferUsage(usage);
817 },
818
819 /**
820 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
821 */
822 dataCollected: function(data)
823 {
824 this._tracingManager._eventsCollected(data);
825 },
826
827 tracingComplete: function()
828 {
829 this._tracingManager._tracingComplete();
830 },
831
832 started: function()
833 {
834 this._tracingManager._tracingStarted();
835 }
836 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698