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

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

Issue 212683005: Timeline Trace viewer prototype (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased, extracted model into a file of its own Created 6 years, 8 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
« no previous file with comments | « Source/devtools/front_end/TimelineView.js ('k') | Source/devtools/front_end/TracingModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.Object}
33 */ 34 */
34 WebInspector.TracingAgent = function() 35 WebInspector.TracingAgent = function()
35 { 36 {
37 WebInspector.Object.call(this);
36 this._active = false; 38 this._active = false;
37 InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispatche r(this)); 39 InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispatche r(this));
38 } 40 }
39 41
42 WebInspector.TracingAgent.Events = {
43 EventsCollected: "EventsCollected"
44 };
45
46 /** @typedef {!{
47 cat: string,
48 pid: number,
49 tid: number,
50 ts: number,
51 ph: string,
52 name: string,
53 args: !Object,
54 dur: number,
55 id: number,
56 s: string
57 }}
58 */
59 WebInspector.TracingAgent.Event;
60
61 /**
62 * @enum {string}
63 */
64 WebInspector.TracingAgent.Phase = {
65 Begin: "B",
66 End: "E",
67 Complete: "X",
68 Instant: "i",
69 AsyncBegin: "S",
70 AsyncStepInto: "T",
71 AsyncStepPast: "p",
72 AsyncEnd: "F",
73 FlowBegin: "s",
74 FlowStep: "t",
75 FlowEnd: "f",
76 Metadata: "M",
77 Counter: "C",
78 Sample: "P",
79 CreateObject: "N",
80 SnapshotObject: "O",
81 DeleteObject: "D"
82 };
83
84 WebInspector.TracingAgent.MetadataEvent = {
85 ProcessSortIndex: "process_sort_index",
86 ProcessName: "process_name",
87 ThreadSortIndex: "thread_sort_index",
88 ThreadName: "thread_name"
89 }
90
40 WebInspector.TracingAgent.prototype = { 91 WebInspector.TracingAgent.prototype = {
41 /** 92 /**
42 * @param {string} categoryPatterns 93 * @param {string} categoryPatterns
43 * @param {string} options 94 * @param {string} options
44 * @param {function(?string)=} callback 95 * @param {function(?string)=} callback
45 */ 96 */
46 start: function(categoryPatterns, options, callback) 97 start: function(categoryPatterns, options, callback)
47 { 98 {
48 TracingAgent.start(categoryPatterns, options, callback); 99 TracingAgent.start(categoryPatterns, options, callback);
49 this._active = true; 100 this._active = true;
50 this._events = [];
51 }, 101 },
52 102
53 /** 103 /**
54 * @param {function()} callback 104 * @param {function()} callback
55 */ 105 */
56 stop: function(callback) 106 stop: function(callback)
57 { 107 {
58 if (!this._active) { 108 if (!this._active) {
59 callback(); 109 callback();
60 return; 110 return;
61 } 111 }
62 this._pendingStopCallback = callback; 112 this._pendingStopCallback = callback;
63 TracingAgent.end(); 113 TracingAgent.end();
64 }, 114 },
65 115
66 /**
67 * @return {!Array.<!{cat: string, args: !Object, ph: string, ts: number}>}
68 */
69 events: function()
70 {
71 return this._events;
72 },
73
74 _eventsCollected: function(events) 116 _eventsCollected: function(events)
75 { 117 {
76 Array.prototype.push.apply(this._events, events); 118 this.dispatchEventToListeners(WebInspector.TracingAgent.Events.EventsCol lected, events);
77 }, 119 },
78 120
79 _tracingComplete: function() 121 _tracingComplete: function()
80 { 122 {
81 this._active = false; 123 this._active = false;
82 if (this._pendingStopCallback) { 124 if (!this._pendingStopCallback)
83 this._pendingStopCallback(); 125 return;
84 this._pendingStopCallback = null; 126 this._pendingStopCallback();
85 } 127 this._pendingStopCallback = null;
86 } 128 },
129
130 __proto__: WebInspector.Object.prototype
87 } 131 }
88 132
89 /** 133 /**
90 * @constructor 134 * @constructor
91 * @implements {TracingAgent.Dispatcher} 135 * @implements {TracingAgent.Dispatcher}
92 * @param {!WebInspector.TracingAgent} tracingAgent 136 * @param {!WebInspector.TracingAgent} tracingAgent
93 */ 137 */
94 WebInspector.TracingDispatcher = function(tracingAgent) 138 WebInspector.TracingDispatcher = function(tracingAgent)
95 { 139 {
96 this._tracingAgent = tracingAgent; 140 this._tracingAgent = tracingAgent;
97 } 141 }
98 142
99 WebInspector.TracingDispatcher.prototype = { 143 WebInspector.TracingDispatcher.prototype = {
100 dataCollected: function(data) 144 dataCollected: function(data)
101 { 145 {
102 this._tracingAgent._eventsCollected(data); 146 this._tracingAgent._eventsCollected(data);
103 }, 147 },
104 148
105 tracingComplete: function() 149 tracingComplete: function()
106 { 150 {
107 this._tracingAgent._tracingComplete(); 151 this._tracingAgent._tracingComplete();
108 } 152 }
109 } 153 }
110 154
111 /** 155 /**
112 * @type {!WebInspector.TracingAgent} 156 * @type {!WebInspector.TracingAgent}
113 */ 157 */
114 WebInspector.tracingAgent; 158 WebInspector.tracingAgent;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/TimelineView.js ('k') | Source/devtools/front_end/TracingModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698