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

Side by Side 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: Rebase on master 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 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 20 matching lines...) Expand all
31 /** 31 /**
32 * @constructor 32 * @constructor
33 */ 33 */
34 function InspectorBackendClass() 34 function InspectorBackendClass()
35 { 35 {
36 this._connection = null; 36 this._connection = null;
37 this._agentPrototypes = {}; 37 this._agentPrototypes = {};
38 this._dispatcherPrototypes = {}; 38 this._dispatcherPrototypes = {};
39 this._initialized = false; 39 this._initialized = false;
40 this._enums = {}; 40 this._enums = {};
41 this._initProtocolAgentsClass();
41 } 42 }
42 43
43 InspectorBackendClass.prototype = { 44 InspectorBackendClass.prototype = {
44 45
46 _initProtocolAgentsClass: function()
vsevik 2014/03/06 17:52:31 nit: _initProtocolAgentsConstructor
sergeyv 2014/03/07 09:42:08 Done.
47 {
48 window.Protocol = {};
49
50 /**
51 * @constructor
52 * @param {!Object.<string, !Object>} agentsMap
53 */
54 window.Protocol.Agents = function(agentsMap) {
55 this._agentsMap = agentsMap;
56 };
57 },
58
59 /**
60 * @param {string} domain
61 */
62 _addProtocolAgentsMethod: function(domain)
vsevik 2014/03/06 17:52:31 nit: _addAgentGetterMethodToProtocolAgentsPrototyp
sergeyv 2014/03/07 09:42:08 Done.
63 {
64 var upperCaseLength = 0;
65 while (upperCaseLength < domain.length && domain[upperCaseLength].toLowe rCase() !== domain[upperCaseLength])
66 ++upperCaseLength;
67
68 var methodName = domain.substr(0, upperCaseLength).toLowerCase() + domai n.slice(upperCaseLength) + "Agent";
69
70 /**
71 * @this {Protocol.Agents}
72 */
73 function agentGetter()
74 {
75 return this._agentsMap[domain];
76 }
77
78 window.Protocol.Agents.prototype[methodName] = agentGetter;
79 },
80
45 /** 81 /**
46 * @return {!InspectorBackendClass.Connection} 82 * @return {!InspectorBackendClass.Connection}
47 */ 83 */
48 connection: function() 84 connection: function()
49 { 85 {
50 if (!this._connection) 86 if (!this._connection)
51 throw "Main connection was not initialized"; 87 throw "Main connection was not initialized";
52 return this._connection; 88 return this._connection;
53 }, 89 },
54 90
(...skipping 11 matching lines...) Expand all
66 window[domainAndMethod[0] + "Agent"][domainAndMethod[1]] = this._enu ms[type]; 102 window[domainAndMethod[0] + "Agent"][domainAndMethod[1]] = this._enu ms[type];
67 } 103 }
68 }, 104 },
69 105
70 /** 106 /**
71 * @param {string} domain 107 * @param {string} domain
72 * @return {!InspectorBackendClass.AgentPrototype} 108 * @return {!InspectorBackendClass.AgentPrototype}
73 */ 109 */
74 _agentPrototype: function(domain) 110 _agentPrototype: function(domain)
75 { 111 {
76 if (!this._agentPrototypes[domain]) 112 if (!this._agentPrototypes[domain]) {
77 this._agentPrototypes[domain] = new InspectorBackendClass.AgentProto type(domain); 113 this._agentPrototypes[domain] = new InspectorBackendClass.AgentProto type(domain);
114 this._addProtocolAgentsMethod(domain);
115 }
78 116
79 return this._agentPrototypes[domain]; 117 return this._agentPrototypes[domain];
80 }, 118 },
81 119
82 /** 120 /**
83 * @param {string} domain 121 * @param {string} domain
84 * @return {!InspectorBackendClass.DispatcherPrototype} 122 * @return {!InspectorBackendClass.DispatcherPrototype}
85 */ 123 */
86 _dispatcherPrototype: function(domain) 124 _dispatcherPrototype: function(domain)
87 { 125 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 /** 369 /**
332 * @param {string} domain 370 * @param {string} domain
333 * @return {!InspectorBackendClass.AgentPrototype} 371 * @return {!InspectorBackendClass.AgentPrototype}
334 */ 372 */
335 agent: function(domain) 373 agent: function(domain)
336 { 374 {
337 return this._agents[domain]; 375 return this._agents[domain];
338 }, 376 },
339 377
340 /** 378 /**
379 * @return {!Object.<string, !Object>}
380 */
381 agentsMap: function()
382 {
383 return this._agents;
384 },
385
386 /**
341 * @param {string} domain 387 * @param {string} domain
342 * @param {string} method 388 * @param {string} method
343 * @param {?Object} params 389 * @param {?Object} params
344 * @param {?function(*)} callback 390 * @param {?function(*)} callback
345 * @private 391 * @private
346 */ 392 */
347 _wrapCallbackAndSendMessageObject: function(domain, method, params, callback ) 393 _wrapCallbackAndSendMessageObject: function(domain, method, params, callback )
348 { 394 {
349 var messageObject = {}; 395 var messageObject = {};
350 messageObject.method = method; 396 messageObject.method = method;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 753 }
708 754
709 } 755 }
710 756
711 InspectorBackendClass.Options = { 757 InspectorBackendClass.Options = {
712 dumpInspectorTimeStats: false, 758 dumpInspectorTimeStats: false,
713 dumpInspectorProtocolMessages: false 759 dumpInspectorProtocolMessages: false
714 } 760 }
715 761
716 InspectorBackend = new InspectorBackendClass(); 762 InspectorBackend = new InspectorBackendClass();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698