Chromium Code Reviews| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 } | 371 } |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * @param {string} domain | 374 * @param {string} domain |
| 375 * @param {!Object} dispatcher | 375 * @param {!Object} dispatcher |
| 376 */ | 376 */ |
| 377 registerDispatcher(domain, dispatcher) { | 377 registerDispatcher(domain, dispatcher) { |
| 378 if (!this._dispatchers[domain]) | 378 if (!this._dispatchers[domain]) |
| 379 return; | 379 return; |
| 380 | 380 |
| 381 this._dispatchers[domain].setDomainDispatcher(dispatcher); | 381 this._dispatchers[domain].addDomainDispatcher(dispatcher); |
| 382 } | 382 } |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * @param {function()=} script | 385 * @param {function()=} script |
| 386 */ | 386 */ |
| 387 _deprecatedRunAfterPendingDispatches(script) { | 387 _deprecatedRunAfterPendingDispatches(script) { |
| 388 if (!this._scripts) | 388 if (!this._scripts) |
| 389 this._scripts = []; | 389 this._scripts = []; |
| 390 | 390 |
| 391 if (script) | 391 if (script) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 callback.apply(null, argumentsArray); | 656 callback.apply(null, argumentsArray); |
| 657 } | 657 } |
| 658 }; | 658 }; |
| 659 | 659 |
| 660 /** | 660 /** |
| 661 * @unrestricted | 661 * @unrestricted |
| 662 */ | 662 */ |
| 663 Protocol.InspectorBackend._DispatcherPrototype = class { | 663 Protocol.InspectorBackend._DispatcherPrototype = class { |
| 664 constructor() { | 664 constructor() { |
| 665 this._eventArgs = {}; | 665 this._eventArgs = {}; |
| 666 this._dispatcher = null; | 666 this._dispatchers = []; |
| 667 } | 667 } |
| 668 | 668 |
| 669 /** | 669 /** |
| 670 * @param {string} eventName | 670 * @param {string} eventName |
| 671 * @param {!Object} params | 671 * @param {!Object} params |
| 672 */ | 672 */ |
| 673 registerEvent(eventName, params) { | 673 registerEvent(eventName, params) { |
| 674 this._eventArgs[eventName] = params; | 674 this._eventArgs[eventName] = params; |
| 675 } | 675 } |
| 676 | 676 |
| 677 /** | 677 /** |
| 678 * @param {!Object} dispatcher | 678 * @param {!Object} dispatcher |
| 679 */ | 679 */ |
| 680 setDomainDispatcher(dispatcher) { | 680 addDomainDispatcher(dispatcher) { |
| 681 this._dispatcher = dispatcher; | 681 this._dispatchers.push(dispatcher); |
| 682 } | 682 } |
| 683 | 683 |
| 684 /** | 684 /** |
| 685 * @param {string} functionName | 685 * @param {string} functionName |
| 686 * @param {!Object} messageObject | 686 * @param {!Object} messageObject |
| 687 */ | 687 */ |
| 688 dispatch(functionName, messageObject) { | 688 dispatch(functionName, messageObject) { |
| 689 if (!this._dispatcher) | 689 if (!this._dispatchers.length) |
| 690 return; | 690 return; |
| 691 | 691 |
| 692 if (!(functionName in this._dispatcher)) { | 692 if (!(functionName in this._dispatchers[0])) { |
| 693 Protocol.InspectorBackend.reportProtocolError( | 693 Protocol.InspectorBackend.reportProtocolError( |
| 694 'Protocol Error: Attempted to dispatch an unimplemented method \'' + m essageObject.method + '\'', | 694 'Protocol Error: Attempted to dispatch an unimplemented method \'' + m essageObject.method + '\'', |
| 695 messageObject); | 695 messageObject); |
| 696 return; | 696 return; |
| 697 } | 697 } |
| 698 | 698 |
| 699 if (!this._eventArgs[messageObject.method]) { | 699 if (!this._eventArgs[messageObject.method]) { |
| 700 Protocol.InspectorBackend.reportProtocolError( | 700 Protocol.InspectorBackend.reportProtocolError( |
| 701 'Protocol Error: Attempted to dispatch an unspecified method \'' + mes sageObject.method + '\'', | 701 'Protocol Error: Attempted to dispatch an unspecified method \'' + mes sageObject.method + '\'', |
| 702 messageObject); | 702 messageObject); |
| 703 return; | 703 return; |
| 704 } | 704 } |
| 705 | 705 |
| 706 var params = []; | 706 var params = []; |
| 707 if (messageObject.params) { | 707 if (messageObject.params) { |
| 708 var paramNames = this._eventArgs[messageObject.method]; | 708 var paramNames = this._eventArgs[messageObject.method]; |
| 709 for (var i = 0; i < paramNames.length; ++i) | 709 for (var i = 0; i < paramNames.length; ++i) |
| 710 params.push(messageObject.params[paramNames[i]]); | 710 params.push(messageObject.params[paramNames[i]]); |
| 711 } | 711 } |
| 712 | 712 |
| 713 var timingLabel = 'time-stats: ' + messageObject.method; | 713 var timingLabel = 'time-stats: ' + messageObject.method; |
| 714 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) | 714 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) |
| 715 console.time(timingLabel); | 715 console.time(timingLabel); |
| 716 | 716 |
| 717 this._dispatcher[functionName].apply(this._dispatcher, params); | 717 for (var index = 0; index < this._dispatchers.length; index++) |
|
pfeldman
2017/02/03 03:01:08
++index
| |
| 718 this._dispatchers[index][functionName].apply(this._dispatchers[index], par ams); | |
| 718 | 719 |
| 719 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) | 720 if (Protocol.InspectorBackend.Options.dumpInspectorTimeStats) |
| 720 console.timeEnd(timingLabel); | 721 console.timeEnd(timingLabel); |
| 721 } | 722 } |
| 722 }; | 723 }; |
| 723 | 724 |
| 724 Protocol.InspectorBackend.Options = { | 725 Protocol.InspectorBackend.Options = { |
| 725 dumpInspectorTimeStats: false, | 726 dumpInspectorTimeStats: false, |
| 726 dumpInspectorProtocolMessages: false, | 727 dumpInspectorProtocolMessages: false, |
| 727 suppressRequestErrors: false | 728 suppressRequestErrors: false |
| 728 }; | 729 }; |
| OLD | NEW |