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

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

Issue 2073343002: Timeline addTraceProvider API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: checkbox prototype Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 this._subscriptionStopHandlers = {}; 42 this._subscriptionStopHandlers = {};
43 this._extraHeaders = {}; 43 this._extraHeaders = {};
44 this._requests = {}; 44 this._requests = {};
45 this._lastRequestId = 0; 45 this._lastRequestId = 0;
46 this._registeredExtensions = {}; 46 this._registeredExtensions = {};
47 this._status = new WebInspector.ExtensionStatus(); 47 this._status = new WebInspector.ExtensionStatus();
48 /** @type {!Array.<!WebInspector.ExtensionSidebarPane>} */ 48 /** @type {!Array.<!WebInspector.ExtensionSidebarPane>} */
49 this._sidebarPanes = []; 49 this._sidebarPanes = [];
50 /** @type {!Array.<!WebInspector.ExtensionAuditCategory>} */ 50 /** @type {!Array.<!WebInspector.ExtensionAuditCategory>} */
51 this._auditCategories = []; 51 this._auditCategories = [];
52 /** @type {!Array.<!WebInspector.ExtensionTraceProvider>} */
53 this._traceProviders = [];
54
52 55
53 var commands = WebInspector.extensionAPI.Commands; 56 var commands = WebInspector.extensionAPI.Commands;
54 57
55 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this)); 58 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this));
59 this._registerHandler(commands.AddTraceProvider, this._onAddTraceProvider.bi nd(this));
56 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his)); 60 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his));
57 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this)); 61 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this));
58 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind (this)); 62 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind (this));
59 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this)); 63 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this));
60 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this)); 64 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this));
61 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut ton.bind(this)); 65 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut ton.bind(this));
62 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this)); 66 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this));
63 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this)); 67 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this));
64 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); 68 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this));
65 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this)); 69 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this));
(...skipping 14 matching lines...) Expand all
80 window.addEventListener("message", this._onWindowMessage.bind(this), false); // Only for main window. 84 window.addEventListener("message", this._onWindowMessage.bind(this), false); // Only for main window.
81 85
82 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.AddExtensions, this._addExtensions, this); 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.AddExtensions, this._addExtensions, this);
83 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.SetInspectedTabId, this._setInspectedTabId, this); 87 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.SetInspectedTabId, this._setInspectedTabId, this);
84 88
85 this._initExtensions(); 89 this._initExtensions();
86 } 90 }
87 91
88 WebInspector.ExtensionServer.Events = { 92 WebInspector.ExtensionServer.Events = {
89 SidebarPaneAdded: "SidebarPaneAdded", 93 SidebarPaneAdded: "SidebarPaneAdded",
90 AuditCategoryAdded: "AuditCategoryAdded" 94 AuditCategoryAdded: "AuditCategoryAdded",
95 TraceProviderAdded: "TraceProviderAdded"
91 } 96 }
92 97
93 WebInspector.ExtensionServer.prototype = { 98 WebInspector.ExtensionServer.prototype = {
94 initializeExtensions: function() 99 initializeExtensions: function()
95 { 100 {
96 this._initializeCommandIssued = true; 101 this._initializeCommandIssued = true;
97 if (this._pendingExtensionInfos) { 102 if (this._pendingExtensionInfos) {
98 this._pendingExtensionInfos.forEach(this._addExtension, this); 103 this._pendingExtensionInfos.forEach(this._addExtension, this);
99 delete this._pendingExtensionInfos; 104 delete this._pendingExtensionInfos;
100 } 105 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 168
164 /** 169 /**
165 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults 170 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults
166 */ 171 */
167 stopAuditRun: function(auditResults) 172 stopAuditRun: function(auditResults)
168 { 173 {
169 delete this._clientObjects[auditResults.id()]; 174 delete this._clientObjects[auditResults.id()];
170 }, 175 },
171 176
172 /** 177 /**
178 * @param {string} traceProviderId
179 */
180 startTraceProviderRun: function(traceProviderId)
caseq 2016/06/21 07:29:51 nit: startTraceRecording
181 {
182 this._postNotification("recording-started-" + traceProviderId);
183 },
184
185 /**
173 * @param {string} type 186 * @param {string} type
174 * @return {boolean} 187 * @return {boolean}
175 */ 188 */
176 hasSubscribers: function(type) 189 hasSubscribers: function(type)
177 { 190 {
178 return !!this._subscribers[type]; 191 return !!this._subscribers[type];
179 }, 192 },
180 193
181 /** 194 /**
182 * @param {string} type 195 * @param {string} type
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 }, 588 },
576 589
577 _onAddAuditCategory: function(message, port) 590 _onAddAuditCategory: function(message, port)
578 { 591 {
579 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); 592 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount);
580 this._clientObjects[message.id] = category; 593 this._clientObjects[message.id] = category;
581 this._auditCategories.push(category); 594 this._auditCategories.push(category);
582 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); 595 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category);
583 }, 596 },
584 597
598 _onAddTraceProvider: function(message, port)
599 {
600 var provider = new WebInspector.ExtensionTraceProvider(port._extensionOr igin, message.id, message.categoryName, message.categoryTooltip);
601 this._clientObjects[message.id] = provider;
602 this._traceProviders.push(provider);
603 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.TraceP roviderAdded, message);
caseq 2016/06/21 07:29:51 let's not leak extension messages outside of Exten
604 },
605
606 /**
607 * @return {!Array.<!WebInspector.ExtensionTraceProvider>}
608 */
609 traceProviders: function()
610 {
611 return this._traceProviders;
612 },
613
614
caseq 2016/06/21 07:29:51 nit: nuke extra empty lines
615
585 /** 616 /**
586 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} 617 * @return {!Array.<!WebInspector.ExtensionAuditCategory>}
587 */ 618 */
588 auditCategories: function() 619 auditCategories: function()
589 { 620 {
590 return this._auditCategories; 621 return this._auditCategories;
591 }, 622 },
592 623
593 _onAddAuditResult: function(message) 624 _onAddAuditResult: function(message)
594 { 625 {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 /** 1102 /**
1072 * @typedef {{code: string, description: string, details: !Array.<*>}} 1103 * @typedef {{code: string, description: string, details: !Array.<*>}}
1073 */ 1104 */
1074 WebInspector.ExtensionStatus.Record; 1105 WebInspector.ExtensionStatus.Record;
1075 1106
1076 WebInspector.extensionAPI = {}; 1107 WebInspector.extensionAPI = {};
1077 defineCommonExtensionSymbols(WebInspector.extensionAPI); 1108 defineCommonExtensionSymbols(WebInspector.extensionAPI);
1078 1109
1079 /** @type {!WebInspector.ExtensionServer} */ 1110 /** @type {!WebInspector.ExtensionServer} */
1080 WebInspector.extensionServer; 1111 WebInspector.extensionServer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698