| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 var messageObject = /** @type {!Object} */ ((typeof message === 'string') ?
JSON.parse(message) : message); | 331 var messageObject = /** @type {!Object} */ ((typeof message === 'string') ?
JSON.parse(message) : message); |
| 332 | 332 |
| 333 if ('id' in messageObject) { // just a response for some request | 333 if ('id' in messageObject) { // just a response for some request |
| 334 var callback = this._callbacks[messageObject.id]; | 334 var callback = this._callbacks[messageObject.id]; |
| 335 if (!callback) { | 335 if (!callback) { |
| 336 InspectorBackendClass.reportProtocolError('Protocol Error: the message w
ith wrong id', messageObject); | 336 InspectorBackendClass.reportProtocolError('Protocol Error: the message w
ith wrong id', messageObject); |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 | 339 |
| 340 var processingStartTime; | 340 var timingLabel = 'time-stats: ' + callback.methodName; |
| 341 if (InspectorBackendClass.Options.dumpInspectorTimeStats) | 341 if (InspectorBackendClass.Options.dumpInspectorTimeStats) |
| 342 processingStartTime = Date.now(); | 342 console.time(timingLabel); |
| 343 | 343 |
| 344 this._agent(callback.domain).dispatchResponse(messageObject, callback.meth
odName, callback); | 344 this._agent(callback.domain).dispatchResponse(messageObject, callback.meth
odName, callback); |
| 345 --this._pendingResponsesCount; | 345 --this._pendingResponsesCount; |
| 346 delete this._callbacks[messageObject.id]; | 346 delete this._callbacks[messageObject.id]; |
| 347 | 347 |
| 348 if (InspectorBackendClass.Options.dumpInspectorTimeStats) { | 348 if (InspectorBackendClass.Options.dumpInspectorTimeStats) |
| 349 console.log( | 349 console.timeEnd(timingLabel); |
| 350 'time-stats: ' + callback.methodName + ' = ' + (processingStartTime
- callback.sendRequestTime) + ' + ' + | |
| 351 (Date.now() - processingStartTime)); | |
| 352 } | |
| 353 | 350 |
| 354 if (this._scripts && !this._pendingResponsesCount) | 351 if (this._scripts && !this._pendingResponsesCount) |
| 355 this._deprecatedRunAfterPendingDispatches(); | 352 this._deprecatedRunAfterPendingDispatches(); |
| 356 } else { | 353 } else { |
| 357 if (!('method' in messageObject)) { | 354 if (!('method' in messageObject)) { |
| 358 InspectorBackendClass.reportProtocolError('Protocol Error: the message w
ithout method', messageObject); | 355 InspectorBackendClass.reportProtocolError('Protocol Error: the message w
ithout method', messageObject); |
| 359 return; | 356 return; |
| 360 } | 357 } |
| 361 | 358 |
| 362 var method = messageObject.method.split('.'); | 359 var method = messageObject.method.split('.'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 this._scripts = []; | 406 this._scripts = []; |
| 410 for (var id = 0; id < scripts.length; ++id) | 407 for (var id = 0; id < scripts.length; ++id) |
| 411 scripts[id].call(this); | 408 scripts[id].call(this); |
| 412 } | 409 } |
| 413 } | 410 } |
| 414 | 411 |
| 415 /** | 412 /** |
| 416 * @param {string} message | 413 * @param {string} message |
| 417 */ | 414 */ |
| 418 _dumpProtocolMessage(message) { | 415 _dumpProtocolMessage(message) { |
| 419 console.log(message); | 416 console.log(message); // eslint-disable-line no-console |
| 420 } | 417 } |
| 421 | 418 |
| 422 /** | 419 /** |
| 423 * @param {string} reason | 420 * @param {string} reason |
| 424 */ | 421 */ |
| 425 _onDisconnect(reason) { | 422 _onDisconnect(reason) { |
| 426 this._connection = null; | 423 this._connection = null; |
| 427 this._runPendingCallbacks(); | 424 this._runPendingCallbacks(); |
| 428 this.dispose(); | 425 this.dispose(); |
| 429 } | 426 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 return; | 703 return; |
| 707 } | 704 } |
| 708 | 705 |
| 709 var params = []; | 706 var params = []; |
| 710 if (messageObject.params) { | 707 if (messageObject.params) { |
| 711 var paramNames = this._eventArgs[messageObject.method]; | 708 var paramNames = this._eventArgs[messageObject.method]; |
| 712 for (var i = 0; i < paramNames.length; ++i) | 709 for (var i = 0; i < paramNames.length; ++i) |
| 713 params.push(messageObject.params[paramNames[i]]); | 710 params.push(messageObject.params[paramNames[i]]); |
| 714 } | 711 } |
| 715 | 712 |
| 716 var processingStartTime; | 713 var timingLabel = 'time-stats: ' + messageObject.method; |
| 717 if (InspectorBackendClass.Options.dumpInspectorTimeStats) | 714 if (InspectorBackendClass.Options.dumpInspectorTimeStats) |
| 718 processingStartTime = Date.now(); | 715 console.time(timingLabel); |
| 719 | 716 |
| 720 this._dispatcher[functionName].apply(this._dispatcher, params); | 717 this._dispatcher[functionName].apply(this._dispatcher, params); |
| 721 | 718 |
| 722 if (InspectorBackendClass.Options.dumpInspectorTimeStats) | 719 if (InspectorBackendClass.Options.dumpInspectorTimeStats) |
| 723 console.log('time-stats: ' + messageObject.method + ' = ' + (Date.now() -
processingStartTime)); | 720 console.timeEnd(timingLabel); |
| 724 } | 721 } |
| 725 }; | 722 }; |
| 726 | 723 |
| 727 InspectorBackendClass.Options = { | 724 InspectorBackendClass.Options = { |
| 728 dumpInspectorTimeStats: false, | 725 dumpInspectorTimeStats: false, |
| 729 dumpInspectorProtocolMessages: false, | 726 dumpInspectorProtocolMessages: false, |
| 730 suppressRequestErrors: false | 727 suppressRequestErrors: false |
| 731 }; | 728 }; |
| OLD | NEW |