Index: third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js b/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js |
index 7a9b305fbc76abcc0829e3ba5893acbb4068899f..41a8d6e8dfdc77c2244c31ca014a60199f4ab6cf 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js |
+++ b/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js |
@@ -51,6 +51,8 @@ function defineCommonExtensionSymbols(apiPrivate) |
apiPrivate.Events = { |
AuditStarted: "audit-started-", |
+ RecordingStarted: "trace-recording-started-", |
+ RecordingStopped: "trace-recording-stopped-", |
ButtonClicked: "button-clicked-", |
PanelObjectSelected: "panel-objectSelected-", |
NetworkRequestFinished: "network-request-finished", |
@@ -66,6 +68,8 @@ function defineCommonExtensionSymbols(apiPrivate) |
AddAuditCategory: "addAuditCategory", |
AddAuditResult: "addAuditResult", |
AddRequestHeaders: "addRequestHeaders", |
+ AddTraceProvider: "addTraceProvider", |
+ AddTraceData: "addTraceData", |
ApplyStyleSheet: "applyStyleSheet", |
CreatePanel: "createPanel", |
CreateSidebarPane: "createSidebarPane", |
@@ -174,6 +178,7 @@ EventSinkImpl.prototype = { |
function InspectorExtensionAPI() |
{ |
this.audits = new Audits(); |
+ this.timeline = new Timeline(); |
this.inspectedWindow = new InspectedWindow(); |
this.panels = new Panels(); |
this.network = new Network(); |
@@ -411,6 +416,7 @@ function extractCallbackArgument(args) |
var AuditCategory = declareInterfaceClass(AuditCategoryImpl); |
var AuditResult = declareInterfaceClass(AuditResultImpl); |
+var TraceData = declareInterfaceClass(TraceDataImpl); |
var Button = declareInterfaceClass(ButtonImpl); |
var EventSink = declareInterfaceClass(EventSinkImpl); |
var ExtensionPanel = declareInterfaceClass(ExtensionPanelImpl); |
@@ -553,6 +559,71 @@ ButtonImpl.prototype = { |
/** |
* @constructor |
*/ |
+function Timeline() |
+{ |
+} |
+ |
+Timeline.prototype = { |
+ /** |
+ * @param {string} categoryName |
+ * @param {string} categoryTooltip |
+ * @return {!TraceProvider} |
+ */ |
+ addTraceProvider: function(categoryName, categoryTooltip) |
+ { |
+ var id = "extension-timeline-category-" + extensionServer.nextObjectId(); |
+ extensionServer.sendRequest({ command: commands.AddTraceProvider, id: id, categoryName: categoryName, categoryTooltip: categoryTooltip}); |
+ return new TraceProvider(id); |
+ } |
+} |
+ |
+/** |
+ * @constructor |
+ */ |
+function TraceProvider(id) |
+{ |
+ /** |
+ * @this {EventSinkImpl} |
+ */ |
+ function dispatchRecordingStoppedEvent(request) |
+ { |
+ var traceData = new TraceData(request.arguments[0], id); |
+ try { |
+ this._fire(traceData); |
+ } catch (e) { |
+ console.error("Uncaught exception in extension recording stopped event handler: " + e); |
+ } |
+ } |
+ this.onRecordingStarted = new EventSink(events.RecordingStarted + id); |
+ this.onRecordingStopped = new EventSink(events.RecordingStopped + id, dispatchRecordingStoppedEvent); |
+} |
+ |
+/** |
+ * @constructor |
+ */ |
+function TraceDataImpl(id, traceProviderId) |
+{ |
+ this._id = id; |
+ this._traceProviderId = traceProviderId; |
+} |
+ |
+TraceDataImpl.prototype = { |
+ addTraceData: function(threadName, events) |
+ { |
+ var request = { |
+ command: commands.AddTraceData, |
+ dataId: this._id, |
+ threadName: threadName, |
+ events: events, |
+ traceProviderId: this._traceProviderId, |
+ }; |
+ extensionServer.sendRequest(request); |
+ } |
+} |
+ |
+/** |
+ * @constructor |
+ */ |
function Audits() |
{ |
} |