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

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

Issue 2375653003: DevTools: add an API for extension-supplied trace providers (Closed)
Patch Set: review comments addressed Created 4 years, 2 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 = [];
52 54
53 var commands = WebInspector.extensionAPI.Commands; 55 var commands = WebInspector.extensionAPI.Commands;
54 56
55 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this)); 57 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this));
56 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his)); 58 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his));
57 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this)); 59 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this));
60 this._registerHandler(commands.AddTraceProvider, this._onAddTraceProvider.bi nd(this));
58 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind (this)); 61 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind (this));
59 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this)); 62 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this));
60 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this)); 63 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this));
61 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut ton.bind(this)); 64 this._registerHandler(commands.CreateToolbarButton, this._onCreateToolbarBut ton.bind(this));
62 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this)); 65 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this));
63 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this)); 66 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this));
64 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); 67 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this));
65 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this)); 68 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this));
66 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent. bind(this)); 69 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent. bind(this));
67 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten t.bind(this)); 70 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten t.bind(this));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 150
148 _inspectedURLChanged: function(event) 151 _inspectedURLChanged: function(event)
149 { 152 {
150 if (event.data !== WebInspector.targetManager.mainTarget()) 153 if (event.data !== WebInspector.targetManager.mainTarget())
151 return; 154 return;
152 this._requests = {}; 155 this._requests = {};
153 var url = event.data.inspectedURL(); 156 var url = event.data.inspectedURL();
154 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url); 157 this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChan ged, url);
155 }, 158 },
156 159
157
158 /** 160 /**
159 * @param {string} categoryId 161 * @param {string} categoryId
160 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults 162 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults
161 */ 163 */
162 startAuditRun: function(categoryId, auditResults) 164 startAuditRun: function(categoryId, auditResults)
163 { 165 {
164 this._clientObjects[auditResults.id()] = auditResults; 166 this._clientObjects[auditResults.id()] = auditResults;
165 this._postNotification("audit-started-" + categoryId, auditResults.id()) ; 167 this._postNotification("audit-started-" + categoryId, auditResults.id()) ;
166 }, 168 },
167 169
168 /** 170 /**
169 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults 171 * @param {!WebInspector.ExtensionAuditCategoryResults} auditResults
170 */ 172 */
171 stopAuditRun: function(auditResults) 173 stopAuditRun: function(auditResults)
172 { 174 {
173 delete this._clientObjects[auditResults.id()]; 175 delete this._clientObjects[auditResults.id()];
174 }, 176 },
175 177
176 /** 178 /**
179 * @param {string} traceProviderId
180 */
181 startTraceRecording: function(traceProviderId)
182 {
183 this._postNotification("trace-recording-started-" + traceProviderId);
184 },
185
186 /**
187 * @param {string} traceProviderId
188 */
189 stopTraceRecording: function(traceProviderId)
190 {
191 this._postNotification("trace-recording-stopped-" + traceProviderId);
192 },
193
194 /**
177 * @param {string} type 195 * @param {string} type
178 * @return {boolean} 196 * @return {boolean}
179 */ 197 */
180 hasSubscribers: function(type) 198 hasSubscribers: function(type)
181 { 199 {
182 return !!this._subscribers[type]; 200 return !!this._subscribers[type];
183 }, 201 },
184 202
185 /** 203 /**
186 * @param {string} type 204 * @param {string} type
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 608
591 _onAddAuditCategory: function(message, port) 609 _onAddAuditCategory: function(message, port)
592 { 610 {
593 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount); 611 var category = new WebInspector.ExtensionAuditCategory(port._extensionOr igin, message.id, message.displayName, message.resultCount);
594 this._clientObjects[message.id] = category; 612 this._clientObjects[message.id] = category;
595 this._auditCategories.push(category); 613 this._auditCategories.push(category);
596 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category); 614 this.dispatchEventToListeners(WebInspector.ExtensionServer.Events.AuditC ategoryAdded, category);
597 }, 615 },
598 616
599 /** 617 /**
618 * @param {!Object} message
619 * @param {!MessagePort} port
620 */
621 _onAddTraceProvider: function(message, port)
622 {
623 var provider = new WebInspector.ExtensionTraceProvider(port._extensionOr igin, message.id, message.categoryName, message.categoryTooltip);
624 this._clientObjects[message.id] = provider;
625 this._traceProviders.push(provider);
626 },
627
628 /**
629 * @return {!Array<!WebInspector.ExtensionTraceProvider>}
630 */
631 traceProviders: function()
632 {
633 return this._traceProviders;
634 },
635
636 /**
600 * @return {!Array.<!WebInspector.ExtensionAuditCategory>} 637 * @return {!Array.<!WebInspector.ExtensionAuditCategory>}
601 */ 638 */
602 auditCategories: function() 639 auditCategories: function()
603 { 640 {
604 return this._auditCategories; 641 return this._auditCategories;
605 }, 642 },
606 643
607 _onAddAuditResult: function(message) 644 _onAddAuditResult: function(message)
608 { 645 {
609 var auditResult = /** {!WebInspector.ExtensionAuditCategoryResults} */ ( this._clientObjects[message.resultId]); 646 var auditResult = /** {!WebInspector.ExtensionAuditCategoryResults} */ ( this._clientObjects[message.resultId]);
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 /** 1130 /**
1094 * @typedef {{code: string, description: string, details: !Array.<*>}} 1131 * @typedef {{code: string, description: string, details: !Array.<*>}}
1095 */ 1132 */
1096 WebInspector.ExtensionStatus.Record; 1133 WebInspector.ExtensionStatus.Record;
1097 1134
1098 WebInspector.extensionAPI = {}; 1135 WebInspector.extensionAPI = {};
1099 defineCommonExtensionSymbols(WebInspector.extensionAPI); 1136 defineCommonExtensionSymbols(WebInspector.extensionAPI);
1100 1137
1101 /** @type {!WebInspector.ExtensionServer} */ 1138 /** @type {!WebInspector.ExtensionServer} */
1102 WebInspector.extensionServer; 1139 WebInspector.extensionServer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698