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

Unified Diff: Source/devtools/front_end/InspectorBackend.js

Issue 185463010: DevTools: Introduce Target class which holds connection & models (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gr-RuntimeAgent
Patch Set: Address vsevik's comments Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/InspectorBackend.js
diff --git a/Source/devtools/front_end/InspectorBackend.js b/Source/devtools/front_end/InspectorBackend.js
index e8c948d194365b56897d70fd8c093da3e3ec2b88..c61f84a529094ec08525e644b8ffde4d6c731d0c 100644
--- a/Source/devtools/front_end/InspectorBackend.js
+++ b/Source/devtools/front_end/InspectorBackend.js
@@ -38,10 +38,46 @@ function InspectorBackendClass()
this._dispatcherPrototypes = {};
this._initialized = false;
this._enums = {};
+ this._initProtocolAgentsConstructor();
}
InspectorBackendClass.prototype = {
+ _initProtocolAgentsConstructor: function()
+ {
+ window.Protocol = {};
+
+ /**
+ * @constructor
+ * @param {!Object.<string, !Object>} agentsMap
+ */
+ window.Protocol.Agents = function(agentsMap) {
+ this._agentsMap = agentsMap;
+ };
+ },
+
+ /**
+ * @param {string} domain
+ */
+ _addAgentGetterMethodToProtocolAgentsPrototype: function(domain)
+ {
+ var upperCaseLength = 0;
+ while (upperCaseLength < domain.length && domain[upperCaseLength].toLowerCase() !== domain[upperCaseLength])
+ ++upperCaseLength;
+
+ var methodName = domain.substr(0, upperCaseLength).toLowerCase() + domain.slice(upperCaseLength) + "Agent";
+
+ /**
+ * @this {Protocol.Agents}
+ */
+ function agentGetter()
+ {
+ return this._agentsMap[domain];
+ }
+
+ window.Protocol.Agents.prototype[methodName] = agentGetter;
+ },
+
/**
* @return {!InspectorBackendClass.Connection}
*/
@@ -73,8 +109,10 @@ InspectorBackendClass.prototype = {
*/
_agentPrototype: function(domain)
{
- if (!this._agentPrototypes[domain])
+ if (!this._agentPrototypes[domain]) {
this._agentPrototypes[domain] = new InspectorBackendClass.AgentPrototype(domain);
+ this._addAgentGetterMethodToProtocolAgentsPrototype(domain);
+ }
return this._agentPrototypes[domain];
},
@@ -338,6 +376,14 @@ InspectorBackendClass.Connection.prototype = {
},
/**
+ * @return {!Object.<string, !Object>}
+ */
+ agentsMap: function()
+ {
+ return this._agents;
+ },
+
+ /**
* @param {string} domain
* @param {string} method
* @param {?Object} params

Powered by Google App Engine
This is Rietveld 408576698