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

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

Issue 392603002: DevTools: refactoring connection creation, removing a couple of dead code branches. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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/main/Main.js ('k') | Source/devtools/front_end/sdk/WorkerManager.js » ('j') | 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 console.log(message); 551 console.log(message);
552 }, 552 },
553 553
554 __proto__: WebInspector.Object.prototype 554 __proto__: WebInspector.Object.prototype
555 555
556 } 556 }
557 557
558 /** 558 /**
559 * @constructor 559 * @constructor
560 * @extends {InspectorBackendClass.Connection} 560 * @extends {InspectorBackendClass.Connection}
561 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady
562 */ 561 */
563 InspectorBackendClass.MainConnection = function(onConnectionReady) 562 InspectorBackendClass.MainConnection = function()
564 { 563 {
565 InspectorBackendClass.Connection.call(this); 564 InspectorBackendClass.Connection.call(this);
566 onConnectionReady(this);
567 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.DispatchMessage, this._dispatchMessage, this); 565 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.DispatchMessage, this._dispatchMessage, this);
568 } 566 }
569 567
570 InspectorBackendClass.MainConnection.prototype = { 568 InspectorBackendClass.MainConnection.prototype = {
571 569
572 /** 570 /**
573 * @param {!Object} messageObject 571 * @param {!Object} messageObject
574 */ 572 */
575 sendMessage: function(messageObject) 573 sendMessage: function(messageObject)
576 { 574 {
(...skipping 21 matching lines...) Expand all
598 InspectorBackendClass.WebSocketConnection = function(url, onConnectionReady) 596 InspectorBackendClass.WebSocketConnection = function(url, onConnectionReady)
599 { 597 {
600 InspectorBackendClass.Connection.call(this); 598 InspectorBackendClass.Connection.call(this);
601 this._socket = new WebSocket(url); 599 this._socket = new WebSocket(url);
602 this._socket.onmessage = this._onMessage.bind(this); 600 this._socket.onmessage = this._onMessage.bind(this);
603 this._socket.onerror = this._onError.bind(this); 601 this._socket.onerror = this._onError.bind(this);
604 this._socket.onopen = onConnectionReady.bind(null, this); 602 this._socket.onopen = onConnectionReady.bind(null, this);
605 this._socket.onclose = this.fireDisconnected.bind(this, "websocket_closed"); 603 this._socket.onclose = this.fireDisconnected.bind(this, "websocket_closed");
606 } 604 }
607 605
606 /**
607 * @param {string} url
608 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady
609 */
610 InspectorBackendClass.WebSocketConnection.Create = function(url, onConnectionRea dy)
611 {
612 new InspectorBackendClass.WebSocketConnection(url, onConnectionReady);
613 }
614
608 InspectorBackendClass.WebSocketConnection.prototype = { 615 InspectorBackendClass.WebSocketConnection.prototype = {
609 616
610 /** 617 /**
611 * @param {!MessageEvent} message 618 * @param {!MessageEvent} message
612 */ 619 */
613 _onMessage: function(message) 620 _onMessage: function(message)
614 { 621 {
615 var data = /** @type {string} */ (message.data) 622 var data = /** @type {string} */ (message.data)
616 this.dispatch(data); 623 this.dispatch(data);
617 }, 624 },
(...skipping 15 matching lines...) Expand all
633 this._socket.send(message); 640 this._socket.send(message);
634 }, 641 },
635 642
636 __proto__: InspectorBackendClass.Connection.prototype 643 __proto__: InspectorBackendClass.Connection.prototype
637 } 644 }
638 645
639 646
640 /** 647 /**
641 * @constructor 648 * @constructor
642 * @extends {InspectorBackendClass.Connection} 649 * @extends {InspectorBackendClass.Connection}
643 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady
644 */ 650 */
645 InspectorBackendClass.StubConnection = function(onConnectionReady) 651 InspectorBackendClass.StubConnection = function()
646 { 652 {
647 InspectorBackendClass.Connection.call(this); 653 InspectorBackendClass.Connection.call(this);
648 onConnectionReady(this);
649 } 654 }
650 655
651 InspectorBackendClass.StubConnection.prototype = { 656 InspectorBackendClass.StubConnection.prototype = {
652 657
653 /** 658 /**
654 * @param {!Object} messageObject 659 * @param {!Object} messageObject
655 */ 660 */
656 sendMessage: function(messageObject) 661 sendMessage: function(messageObject)
657 { 662 {
658 var message = JSON.stringify(messageObject); 663 var message = JSON.stringify(messageObject);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 883
879 } 884 }
880 885
881 InspectorBackendClass.Options = { 886 InspectorBackendClass.Options = {
882 dumpInspectorTimeStats: false, 887 dumpInspectorTimeStats: false,
883 dumpInspectorProtocolMessages: false, 888 dumpInspectorProtocolMessages: false,
884 suppressRequestErrors: false 889 suppressRequestErrors: false
885 } 890 }
886 891
887 InspectorBackend = new InspectorBackendClass(); 892 InspectorBackend = new InspectorBackendClass();
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/Main.js ('k') | Source/devtools/front_end/sdk/WorkerManager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698