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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js
index e617a0c6edb598a6435c4d612a6778ffd53e1e85..30afcc6cdb379805c2522cee0602374587fb4a71 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TracingManager.js
@@ -3,37 +3,36 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
/**
* @interface
*/
-WebInspector.TracingManagerClient = function()
-{
-};
+WebInspector.TracingManagerClient = function() {};
WebInspector.TracingManagerClient.prototype = {
- tracingStarted: function() { },
- /**
- * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
- */
- traceEventsCollected: function(events) { },
- tracingComplete: function() { },
- /**
- * @param {number} usage
- */
- tracingBufferUsage: function(usage) { },
- /**
- * @param {number} progress
- */
- eventsRetrievalProgress: function(progress) { }
+ tracingStarted: function() {},
+ /**
+ * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
+ */
+ traceEventsCollected: function(events) {},
+ tracingComplete: function() {},
+ /**
+ * @param {number} usage
+ */
+ tracingBufferUsage: function(usage) {},
+ /**
+ * @param {number} progress
+ */
+ eventsRetrievalProgress: function(progress) {}
};
/**
- * @constructor
- * @param {!WebInspector.Target} target
+ * @unrestricted
*/
-WebInspector.TracingManager = function(target)
-{
+WebInspector.TracingManager = class {
+ /**
+ * @param {!WebInspector.Target} target
+ */
+ constructor(target) {
this._target = target;
target.registerTracingDispatcher(new WebInspector.TracingDispatcher(this));
@@ -41,6 +40,71 @@ WebInspector.TracingManager = function(target)
this._activeClient = null;
this._eventBufferSize = 0;
this._eventsRetrieved = 0;
+ }
+
+ /**
+ * @return {?WebInspector.Target}
+ */
+ target() {
+ return this._target;
+ }
+
+ /**
+ * @param {number=} usage
+ * @param {number=} eventCount
+ * @param {number=} percentFull
+ */
+ _bufferUsage(usage, eventCount, percentFull) {
+ this._eventBufferSize = eventCount;
+ this._activeClient.tracingBufferUsage(usage || percentFull || 0);
+ }
+
+ /**
+ * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
+ */
+ _eventsCollected(events) {
+ this._activeClient.traceEventsCollected(events);
+ this._eventsRetrieved += events.length;
+ if (!this._eventBufferSize)
+ return;
+ if (this._eventsRetrieved > this._eventBufferSize)
+ this._eventsRetrieved = this._eventBufferSize;
+ this._activeClient.eventsRetrievalProgress(this._eventsRetrieved / this._eventBufferSize);
+ }
+
+ _tracingComplete() {
+ this._eventBufferSize = 0;
+ this._eventsRetrieved = 0;
+ this._activeClient.tracingComplete();
+ this._activeClient = null;
+ this._finishing = false;
+ }
+
+ /**
+ * @param {!WebInspector.TracingManagerClient} client
+ * @param {string} categoryFilter
+ * @param {string} options
+ * @param {function(?string)=} callback
+ */
+ start(client, categoryFilter, options, callback) {
+ if (this._activeClient)
+ throw new Error('Tracing is already started');
+ var bufferUsageReportingIntervalMs = 500;
+ this._activeClient = client;
+ this._target.tracingAgent().start(
+ categoryFilter, options, bufferUsageReportingIntervalMs, WebInspector.TracingManager.TransferMode.ReportEvents,
+ callback);
+ this._activeClient.tracingStarted();
+ }
+
+ stop() {
+ if (!this._activeClient)
+ throw new Error('Tracing is not started');
+ if (this._finishing)
+ throw new Error('Tracing is already being stopped');
+ this._finishing = true;
+ this._target.tracingAgent().end();
+ }
};
/** @typedef {!{
@@ -62,116 +126,44 @@ WebInspector.TracingManager = function(target)
WebInspector.TracingManager.EventPayload;
WebInspector.TracingManager.TransferMode = {
- ReportEvents: "ReportEvents",
- ReturnAsStream: "ReturnAsStream"
-};
-
-WebInspector.TracingManager.prototype = {
- /**
- * @return {?WebInspector.Target}
- */
- target: function()
- {
- return this._target;
- },
-
- /**
- * @param {number=} usage
- * @param {number=} eventCount
- * @param {number=} percentFull
- */
- _bufferUsage: function(usage, eventCount, percentFull)
- {
- this._eventBufferSize = eventCount;
- this._activeClient.tracingBufferUsage(usage || percentFull || 0);
- },
-
- /**
- * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
- */
- _eventsCollected: function(events)
- {
- this._activeClient.traceEventsCollected(events);
- this._eventsRetrieved += events.length;
- if (!this._eventBufferSize)
- return;
- if (this._eventsRetrieved > this._eventBufferSize)
- this._eventsRetrieved = this._eventBufferSize;
- this._activeClient.eventsRetrievalProgress(this._eventsRetrieved / this._eventBufferSize);
- },
-
- _tracingComplete: function()
- {
- this._eventBufferSize = 0;
- this._eventsRetrieved = 0;
- this._activeClient.tracingComplete();
- this._activeClient = null;
- this._finishing = false;
- },
-
- /**
- * @param {!WebInspector.TracingManagerClient} client
- * @param {string} categoryFilter
- * @param {string} options
- * @param {function(?string)=} callback
- */
- start: function(client, categoryFilter, options, callback)
- {
- if (this._activeClient)
- throw new Error("Tracing is already started");
- var bufferUsageReportingIntervalMs = 500;
- this._activeClient = client;
- this._target.tracingAgent().start(categoryFilter, options, bufferUsageReportingIntervalMs, WebInspector.TracingManager.TransferMode.ReportEvents, callback);
- this._activeClient.tracingStarted();
- },
-
- stop: function()
- {
- if (!this._activeClient)
- throw new Error("Tracing is not started");
- if (this._finishing)
- throw new Error("Tracing is already being stopped");
- this._finishing = true;
- this._target.tracingAgent().end();
- }
+ ReportEvents: 'ReportEvents',
+ ReturnAsStream: 'ReturnAsStream'
};
/**
- * @constructor
* @implements {TracingAgent.Dispatcher}
- * @param {!WebInspector.TracingManager} tracingManager
+ * @unrestricted
*/
-WebInspector.TracingDispatcher = function(tracingManager)
-{
+WebInspector.TracingDispatcher = class {
+ /**
+ * @param {!WebInspector.TracingManager} tracingManager
+ */
+ constructor(tracingManager) {
this._tracingManager = tracingManager;
-};
-
-WebInspector.TracingDispatcher.prototype = {
- /**
- * @override
- * @param {number=} usage
- * @param {number=} eventCount
- * @param {number=} percentFull
- */
- bufferUsage: function(usage, eventCount, percentFull)
- {
- this._tracingManager._bufferUsage(usage, eventCount, percentFull);
- },
-
- /**
- * @override
- * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
- */
- dataCollected: function(data)
- {
- this._tracingManager._eventsCollected(data);
- },
-
- /**
- * @override
- */
- tracingComplete: function()
- {
- this._tracingManager._tracingComplete();
- }
+ }
+
+ /**
+ * @override
+ * @param {number=} usage
+ * @param {number=} eventCount
+ * @param {number=} percentFull
+ */
+ bufferUsage(usage, eventCount, percentFull) {
+ this._tracingManager._bufferUsage(usage, eventCount, percentFull);
+ }
+
+ /**
+ * @override
+ * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
+ */
+ dataCollected(data) {
+ this._tracingManager._eventsCollected(data);
+ }
+
+ /**
+ * @override
+ */
+ tracingComplete() {
+ this._tracingManager._tracingComplete();
+ }
};

Powered by Google App Engine
This is Rietveld 408576698