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

Unified Diff: third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js

Issue 2563383003: DevTools: add extension API to contribute trace events to timeline (Closed)
Patch Set: lint + new compiler warnings Created 4 years 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/extensions/ExtensionServer.js
diff --git a/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js b/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js
index 1410c0baacd554e0b202ba894a602c85aa7effd1..2511fdb296f05c712c03d63c64c34d47fed400a7 100644
--- a/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js
+++ b/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js
@@ -47,12 +47,14 @@ Extensions.ExtensionServer = class extends Common.Object {
this._lastRequestId = 0;
this._registeredExtensions = {};
this._status = new Extensions.ExtensionStatus();
- /** @type {!Array.<!Extensions.ExtensionSidebarPane>} */
+ /** @type {!Array<!Extensions.ExtensionSidebarPane>} */
this._sidebarPanes = [];
- /** @type {!Array.<!Extensions.ExtensionAuditCategory>} */
+ /** @type {!Array<!Extensions.ExtensionAuditCategory>} */
this._auditCategories = [];
- /** @type {!Array.<!Extensions.ExtensionTraceProvider>} */
+ /** @type {!Array<!Extensions.ExtensionTraceProvider>} */
this._traceProviders = [];
+ /** @type {!Map<string, !Extensions.TracingSession>} */
+ this._traceSessions = new Map();
var commands = Extensions.extensionAPI.Commands;
@@ -61,6 +63,7 @@ Extensions.ExtensionServer = class extends Common.Object {
this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders.bind(this));
this._registerHandler(commands.AddTraceProvider, this._onAddTraceProvider.bind(this));
this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind(this));
+ this._registerHandler(commands.CompleteTraceSession, this._onCompleteTraceSession.bind(this));
this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this));
this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane.bind(this));
this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarButton.bind(this));
@@ -164,17 +167,20 @@ Extensions.ExtensionServer = class extends Common.Object {
}
/**
- * @param {string} traceProviderId
+ * @param {string} providerId
+ * @param {string} sessionId
+ * @param {!Extensions.TracingSession} session
*/
- startTraceRecording(traceProviderId) {
- this._postNotification('trace-recording-started-' + traceProviderId);
+ startTraceRecording(providerId, sessionId, session) {
+ this._traceSessions.set(sessionId, session);
+ this._postNotification('trace-recording-started-' + providerId, sessionId);
}
/**
- * @param {string} traceProviderId
+ * @param {string} providerId
*/
- stopTraceRecording(traceProviderId) {
- this._postNotification('trace-recording-stopped-' + traceProviderId);
+ stopTraceRecording(providerId) {
+ this._postNotification('trace-recording-stopped-' + providerId);
}
/**
@@ -310,6 +316,17 @@ Extensions.ExtensionServer = class extends Common.Object {
return this._status.OK();
}
+ /**
+ * @param {!Object} message
+ */
+ _onCompleteTraceSession(message) {
+ var session = this._traceSessions.get(message.id);
+ if (!session)
+ return this._status.E_NOTFOUND(message.id);
+ this._traceSessions.delete(message.id);
+ session.complete(message.url, message.timeOffset);
+ }
+
_onCreateSidebarPane(message) {
if (message.panel !== 'elements' && message.panel !== 'sources')
return this._status.E_NOTFOUND(message.panel);
@@ -560,6 +577,7 @@ Extensions.ExtensionServer = class extends Common.Object {
port._extensionOrigin, message.id, message.categoryName, message.categoryTooltip);
this._clientObjects[message.id] = provider;
this._traceProviders.push(provider);
+ this.dispatchEventToListeners(Extensions.ExtensionServer.Events.TraceProviderAdded);
}
/**
@@ -964,7 +982,8 @@ Extensions.ExtensionServer = class extends Common.Object {
/** @enum {symbol} */
Extensions.ExtensionServer.Events = {
SidebarPaneAdded: Symbol('SidebarPaneAdded'),
- AuditCategoryAdded: Symbol('AuditCategoryAdded')
+ AuditCategoryAdded: Symbol('AuditCategoryAdded'),
+ TraceProviderAdded: Symbol('TraceProviderAdded')
};
/**

Powered by Google App Engine
This is Rietveld 408576698