OLD | NEW |
---|---|
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 * @param {string} domain | 60 * @param {string} domain |
61 */ | 61 */ |
62 _addAgentGetterMethodToProtocolTargetPrototype(domain) { | 62 _addAgentGetterMethodToProtocolTargetPrototype(domain) { |
63 var upperCaseLength = 0; | 63 var upperCaseLength = 0; |
64 while (upperCaseLength < domain.length && domain[upperCaseLength].toLowerCas e() !== domain[upperCaseLength]) | 64 while (upperCaseLength < domain.length && domain[upperCaseLength].toLowerCas e() !== domain[upperCaseLength]) |
65 ++upperCaseLength; | 65 ++upperCaseLength; |
66 | 66 |
67 var methodName = domain.substr(0, upperCaseLength).toLowerCase() + domain.sl ice(upperCaseLength) + 'Agent'; | 67 var methodName = domain.substr(0, upperCaseLength).toLowerCase() + domain.sl ice(upperCaseLength) + 'Agent'; |
68 | 68 |
69 /** | 69 /** |
70 * @this {Protocol.TargetBase} | 70 * @this {Protocol.Dispatcher} |
71 */ | 71 */ |
72 function agentGetter() { | 72 function agentGetter() { |
73 return this._agents[domain]; | 73 return this._agents[domain]; |
74 } | 74 } |
75 | 75 |
76 Protocol.TargetBase.prototype[methodName] = agentGetter; | 76 Protocol.Dispatcher.prototype[methodName] = agentGetter; |
77 | 77 |
78 /** | 78 /** |
79 * @this {Protocol.TargetBase} | 79 * @this {Protocol.Dispatcher} |
80 */ | 80 */ |
81 function registerDispatcher(dispatcher) { | 81 function registerDispatcher(dispatcher) { |
82 this.registerDispatcher(domain, dispatcher); | 82 this._registerDispatcher(domain, dispatcher); |
83 } | 83 } |
84 | 84 |
85 Protocol.TargetBase.prototype['register' + domain + 'Dispatcher'] = register Dispatcher; | 85 Protocol.Dispatcher.prototype['register' + domain + 'Dispatcher'] = register Dispatcher; |
86 } | 86 } |
87 | 87 |
88 /** | 88 /** |
89 * @param {string} domain | 89 * @param {string} domain |
90 * @return {!Protocol.InspectorBackend._AgentPrototype} | 90 * @return {!Protocol.InspectorBackend._AgentPrototype} |
91 */ | 91 */ |
92 _agentPrototype(domain) { | 92 _agentPrototype(domain) { |
93 if (!this._agentPrototypes[domain]) { | 93 if (!this._agentPrototypes[domain]) { |
94 this._agentPrototypes[domain] = new Protocol.InspectorBackend._AgentProtot ype(domain); | 94 this._agentPrototypes[domain] = new Protocol.InspectorBackend._AgentProtot ype(domain); |
95 this._addAgentGetterMethodToProtocolTargetPrototype(domain); | 95 this._addAgentGetterMethodToProtocolTargetPrototype(domain); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 Protocol.InspectorBackend.Connection.Params; | 205 Protocol.InspectorBackend.Connection.Params; |
206 | 206 |
207 /** | 207 /** |
208 * @typedef {function(!Protocol.InspectorBackend.Connection.Params):!Protocol.In spectorBackend.Connection} | 208 * @typedef {function(!Protocol.InspectorBackend.Connection.Params):!Protocol.In spectorBackend.Connection} |
209 */ | 209 */ |
210 Protocol.InspectorBackend.Connection.Factory; | 210 Protocol.InspectorBackend.Connection.Factory; |
211 | 211 |
212 /** | 212 /** |
213 * @unrestricted | 213 * @unrestricted |
214 */ | 214 */ |
215 Protocol.TargetBase = class { | 215 Protocol.Dispatcher = class { |
216 /** | 216 /** |
217 * @param {!Protocol.InspectorBackend.Connection.Factory} connectionFactory | 217 * @param {!Protocol.InspectorBackend.Connection.Factory} connectionFactory |
218 */ | 218 */ |
219 constructor(connectionFactory) { | 219 constructor(connectionFactory) { |
220 this._connection = | 220 this._connection = |
221 connectionFactory({onMessage: this._onMessage.bind(this), onDisconnect: this._onDisconnect.bind(this)}); | 221 connectionFactory({onMessage: this._onMessage.bind(this), onDisconnect: this._onDisconnect.bind(this)}); |
222 this._lastMessageId = 1; | 222 this._lastMessageId = 1; |
223 this._pendingResponsesCount = 0; | 223 this._pendingResponsesCount = 0; |
224 this._agents = {}; | 224 this._agents = {}; |
225 this._dispatchers = {}; | 225 this._dispatchers = {}; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 } | 369 } |
370 | 370 |
371 this._dispatchers[domainName].dispatch(method[1], messageObject); | 371 this._dispatchers[domainName].dispatch(method[1], messageObject); |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 /** | 375 /** |
376 * @param {string} domain | 376 * @param {string} domain |
377 * @param {!Object} dispatcher | 377 * @param {!Object} dispatcher |
378 */ | 378 */ |
379 registerDispatcher(domain, dispatcher) { | 379 _registerDispatcher(domain, dispatcher) { |
380 if (!this._dispatchers[domain]) | 380 if (!this._dispatchers[domain]) |
381 return; | 381 return; |
382 | 382 |
383 this._dispatchers[domain].addDomainDispatcher(dispatcher); | 383 this._dispatchers[domain].addDomainDispatcher(dispatcher); |
384 } | 384 } |
385 | 385 |
386 /** | 386 /** |
387 * @param {function()=} script | 387 * @param {function()=} script |
388 */ | 388 */ |
389 _deprecatedRunAfterPendingDispatches(script) { | 389 _deprecatedRunAfterPendingDispatches(script) { |
(...skipping 27 matching lines...) Expand all Loading... | |
417 _dumpProtocolMessage(message) { | 417 _dumpProtocolMessage(message) { |
418 console.log(message); // eslint-disable-line no-console | 418 console.log(message); // eslint-disable-line no-console |
419 } | 419 } |
420 | 420 |
421 /** | 421 /** |
422 * @param {string} reason | 422 * @param {string} reason |
423 */ | 423 */ |
424 _onDisconnect(reason) { | 424 _onDisconnect(reason) { |
425 this._connection = null; | 425 this._connection = null; |
426 this._runPendingCallbacks(); | 426 this._runPendingCallbacks(); |
427 this.dispose(); | 427 if (this._disposeCallback) |
caseq
2017/04/29 02:12:53
Rename to _disconnectCallback.
| |
428 this._disposeCallback.call(null); | |
428 } | 429 } |
429 | 430 |
430 /** | 431 /** |
431 * @protected | 432 * @param {function()} callback |
432 */ | 433 */ |
433 dispose() { | 434 setDisposeCallback(callback) { |
435 this._disposeCallback = callback; | |
434 } | 436 } |
435 | 437 |
436 /** | 438 /** |
437 * @return {boolean} | 439 * @return {boolean} |
438 */ | 440 */ |
439 isDisposed() { | 441 isDisposed() { |
440 return !this._connection; | 442 return !this._connection; |
441 } | 443 } |
442 | 444 |
443 _runPendingCallbacks() { | 445 _runPendingCallbacks() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 /** | 479 /** |
478 * @param {string} domain | 480 * @param {string} domain |
479 */ | 481 */ |
480 constructor(domain) { | 482 constructor(domain) { |
481 this._replyArgs = {}; | 483 this._replyArgs = {}; |
482 this._hasErrorData = {}; | 484 this._hasErrorData = {}; |
483 this._domain = domain; | 485 this._domain = domain; |
484 } | 486 } |
485 | 487 |
486 /** | 488 /** |
487 * @param {!Protocol.TargetBase} target | 489 * @param {!Protocol.Dispatcher} target |
caseq
2017/04/29 02:12:53
This is confusing. Should this be renamed?
| |
488 */ | 490 */ |
489 setTarget(target) { | 491 setTarget(target) { |
490 this._target = target; | 492 this._target = target; |
491 } | 493 } |
492 | 494 |
493 /** | 495 /** |
494 * @param {string} methodName | 496 * @param {string} methodName |
495 * @param {!Array.<!Object>} signature | 497 * @param {!Array.<!Object>} signature |
496 * @param {!Array.<string>} replyArgs | 498 * @param {!Array.<string>} replyArgs |
497 * @param {boolean} hasErrorData | 499 * @param {boolean} hasErrorData |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) | 731 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) |
730 console.timeEnd(timingLabel); | 732 console.timeEnd(timingLabel); |
731 } | 733 } |
732 }; | 734 }; |
733 | 735 |
734 Protocol.InspectorBackend.Options = { | 736 Protocol.InspectorBackend.Options = { |
735 dumpInspectorTimeStats: false, | 737 dumpInspectorTimeStats: false, |
736 dumpInspectorProtocolMessages: false, | 738 dumpInspectorProtocolMessages: false, |
737 suppressRequestErrors: false | 739 suppressRequestErrors: false |
738 }; | 740 }; |
OLD | NEW |