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

Side by Side Diff: Source/devtools/front_end/sdk/InspectorBackend.js

Issue 660523002: DevTools: add support for chunked protocol messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/host/InspectorFrontendHost.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 604 }
605 605
606 /** 606 /**
607 * @constructor 607 * @constructor
608 * @extends {InspectorBackendClass.Connection} 608 * @extends {InspectorBackendClass.Connection}
609 */ 609 */
610 InspectorBackendClass.MainConnection = function() 610 InspectorBackendClass.MainConnection = function()
611 { 611 {
612 InspectorBackendClass.Connection.call(this); 612 InspectorBackendClass.Connection.call(this);
613 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.DispatchMessage, this._dispatchMessage, this); 613 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.DispatchMessage, this._dispatchMessage, this);
614 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.DispatchMessageChunk, this._dispatchMessageChunk, this);
614 } 615 }
615 616
616 InspectorBackendClass.MainConnection.prototype = { 617 InspectorBackendClass.MainConnection.prototype = {
617 618
618 /** 619 /**
619 * @param {!Object} messageObject 620 * @param {!Object} messageObject
620 */ 621 */
621 sendMessage: function(messageObject) 622 sendMessage: function(messageObject)
622 { 623 {
623 var message = JSON.stringify(messageObject); 624 var message = JSON.stringify(messageObject);
624 InspectorFrontendHost.sendMessageToBackend(message); 625 InspectorFrontendHost.sendMessageToBackend(message);
625 }, 626 },
626 627
627 /** 628 /**
628 * @param {!WebInspector.Event} event 629 * @param {!WebInspector.Event} event
629 */ 630 */
630 _dispatchMessage: function(event) 631 _dispatchMessage: function(event)
631 { 632 {
632 this.dispatch(/** @type {!Object|string} */ (event.data)); 633 this.dispatch(/** @type {string} */ (event.data));
dgozman 2014/10/15 13:51:38 event.data could actually be an object (at least i
pfeldman 2014/10/15 14:06:59 Which layout tests?
634 },
635
636 /**
637 * @param {!WebInspector.Event} event
638 */
639 _dispatchMessageChunk: function(event)
640 {
641 var messageChunk = /** @type {string} */ (event.data["messageChunk"]);
642 var messageSize = /** @type {number} */ (event.data["messageSize"]);
alph 2014/10/15 13:44:58 Why do you need size? lastChunk boolean should be
pfeldman 2014/10/15 14:06:59 I'm doing it for consistency with the backend. Als
643 if (messageSize) {
644 this._messageBuffer = "";
645 this._messageSize = messageSize;
646 }
647 this._messageBuffer += messageChunk;
648 if (this._messageBuffer.length === this._messageSize) {
649 this.dispatch(this._messageBuffer);
dgozman 2014/10/15 13:51:38 It's safer to clear |this._messageBuffer| and |thi
pfeldman 2014/10/15 14:06:59 This is an async IPC call, we should not re-enter.
650 this._messageBuffer = "";
651 this._messageSize = 0;
652 }
633 }, 653 },
634 654
635 __proto__: InspectorBackendClass.Connection.prototype 655 __proto__: InspectorBackendClass.Connection.prototype
636 } 656 }
637 657
638 /** 658 /**
639 * @constructor 659 * @constructor
640 * @extends {InspectorBackendClass.Connection} 660 * @extends {InspectorBackendClass.Connection}
641 * @param {string} url 661 * @param {string} url
642 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady 662 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 956
937 } 957 }
938 958
939 InspectorBackendClass.Options = { 959 InspectorBackendClass.Options = {
940 dumpInspectorTimeStats: false, 960 dumpInspectorTimeStats: false,
941 dumpInspectorProtocolMessages: false, 961 dumpInspectorProtocolMessages: false,
942 suppressRequestErrors: false 962 suppressRequestErrors: false
943 } 963 }
944 964
945 InspectorBackend = new InspectorBackendClass(); 965 InspectorBackend = new InspectorBackendClass();
OLDNEW
« no previous file with comments | « Source/devtools/front_end/host/InspectorFrontendHost.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698