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 |