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