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

Unified Diff: remoting/webapp/crd/js/session_connector_impl.js

Issue 1067133002: Move ProtocolExtensionManager from SessionConnector into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/crd/js/session_connector_impl.js
diff --git a/remoting/webapp/crd/js/session_connector_impl.js b/remoting/webapp/crd/js/session_connector_impl.js
index 9afccef896432da669397946eecffcf3d9bc5d87..d38c5223454b61ed3e0e8b5f3f22358b24fc846b 100644
--- a/remoting/webapp/crd/js/session_connector_impl.js
+++ b/remoting/webapp/crd/js/session_connector_impl.js
@@ -89,17 +89,6 @@ remoting.SessionConnectorImpl.prototype.resetConnection_ = function() {
/** @private {remoting.CredentialsProvider} */
this.credentialsProvider_ = null;
-
- /** @private {Object<string,remoting.ProtocolExtension>} */
- this.protocolExtensions_ = {};
-
- /**
- * True once a session has been created and we've started the extensions.
- * This is used to immediately start any extensions that are registered
- * after the CONNECTED state change.
- * @private {boolean}
- */
- this.protocolExtensionsStarted_ = false;
};
/**
@@ -327,8 +316,7 @@ remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function(
}
this.clientSession_ = new remoting.ClientSession(
- this.plugin_, this.host_, this.signalStrategy_,
- this.onProtocolExtensionMessage_.bind(this));
+ this.plugin_, this.host_, this.signalStrategy_);
remoting.clientSession = this.clientSession_;
this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_);
@@ -360,89 +348,6 @@ remoting.SessionConnectorImpl.prototype.closeSession = function() {
};
/**
- * @param {remoting.ProtocolExtension} extension
- */
-remoting.SessionConnectorImpl.prototype.registerProtocolExtension =
- function(extension) {
- var types = extension.getExtensionTypes();
-
- // Make sure we don't have an extension of that type already registered.
- for (var i=0, len=types.length; i < len; i++) {
- if (types[i] in this.protocolExtensions_) {
- console.error(
- 'Attempt to register multiple extensions of the same type: ', type);
- return;
- }
- }
-
- for (var i=0, len=types.length; i < len; i++) {
- var type = types[i];
- this.protocolExtensions_[type] = extension;
- if (this.protocolExtensionsStarted_) {
- this.startProtocolExtension_(type);
- }
- }
-};
-
-/** @private */
-remoting.SessionConnectorImpl.prototype.initProtocolExtensions_ = function() {
- base.debug.assert(!this.protocolExtensionsStarted_);
- for (var type in this.protocolExtensions_) {
- this.startProtocolExtension_(type);
- }
- this.protocolExtensionsStarted_ = true;
-};
-
-/**
- * @param {string} type
- * @private
- */
-remoting.SessionConnectorImpl.prototype.startProtocolExtension_ =
- function(type) {
- var extension = this.protocolExtensions_[type];
- extension.startExtension(this.plugin_.sendClientMessage.bind(this.plugin_));
-};
-
-/**
- * Called when an extension message needs to be handled.
- *
- * @param {string} type The type of the extension message.
- * @param {string} data The payload of the extension message.
- * @return {boolean} Return true if the extension message was recognized.
- * @private
- */
-remoting.SessionConnectorImpl.prototype.onProtocolExtensionMessage_ =
- function(type, data) {
- if (type == 'test-echo-reply') {
- console.log('Got echo reply: ' + data);
- return true;
- }
-
- var message = base.jsonParseSafe(data);
- if (typeof message != 'object') {
- console.error('Error parsing extension json data: ' + data);
- return false;
- }
-
- if (type in this.protocolExtensions_) {
- /** @type {remoting.ProtocolExtension} */
- var extension = this.protocolExtensions_[type];
- var handled = false;
- try {
- handled = extension.onExtensionMessage(type, message);
- } catch (/** @type {*} */ err) {
- console.error('Failed to process protocol extension ' + type +
- ' message: ' + err);
- }
- if (handled) {
- return true;
- }
- }
-
- return false;
-};
-
-/**
* Handle a change in the state of the client session prior to successful
* connection (after connection, this class no longer handles state change
* events). Errors that occur while connecting either trigger a reconnect
@@ -472,8 +377,6 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
this.host_, this.credentialsProvider_, this.clientSession_,
this.plugin_);
this.onConnected_(connectionInfo);
- // Initialize any protocol extensions that may have been added by the app.
- this.initProtocolExtensions_();
break;
case remoting.ClientSession.State.CONNECTING:
« remoting/webapp/crd/js/client_plugin_impl.js ('K') | « remoting/webapp/crd/js/session_connector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698