Chromium Code Reviews| 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..2f44e1ba38d521e363b68586d4e4d4669b712727 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._initProtocolAgentsClass(); |
| } |
| InspectorBackendClass.prototype = { |
| + _initProtocolAgentsClass: function() |
|
vsevik
2014/03/06 17:52:31
nit: _initProtocolAgentsConstructor
sergeyv
2014/03/07 09:42:08
Done.
|
| + { |
| + window.Protocol = {}; |
| + |
| + /** |
| + * @constructor |
| + * @param {!Object.<string, !Object>} agentsMap |
| + */ |
| + window.Protocol.Agents = function(agentsMap) { |
| + this._agentsMap = agentsMap; |
| + }; |
| + }, |
| + |
| + /** |
| + * @param {string} domain |
| + */ |
| + _addProtocolAgentsMethod: function(domain) |
|
vsevik
2014/03/06 17:52:31
nit: _addAgentGetterMethodToProtocolAgentsPrototyp
sergeyv
2014/03/07 09:42:08
Done.
|
| + { |
| + 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._addProtocolAgentsMethod(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 |