Commit 4cc79a20 authored by garykac's avatar garykac Committed by Commit bot

[Chromoting] Update client connection enums in JS to match C++.

BUG=

Review URL: https://codereview.chromium.org/1032553008

Cr-Commit-Position: refs/heads/master@{#322249}
parent 574df666
...@@ -91,6 +91,8 @@ std::string ConnectionStateToString(protocol::ConnectionToHost::State state) { ...@@ -91,6 +91,8 @@ std::string ConnectionStateToString(protocol::ConnectionToHost::State state) {
case protocol::ConnectionToHost::AUTHENTICATED: case protocol::ConnectionToHost::AUTHENTICATED:
// Report the authenticated state as 'CONNECTING' to avoid changing // Report the authenticated state as 'CONNECTING' to avoid changing
// the interface between the plugin and webapp. // the interface between the plugin and webapp.
// TODO(garykac) Change to 'AUTHENTICATED' in M44 or once we've switched
// the client to NaCl.
return "CONNECTING"; return "CONNECTING";
case protocol::ConnectionToHost::CONNECTED: case protocol::ConnectionToHost::CONNECTED:
return "CONNECTED"; return "CONNECTED";
......
...@@ -34,7 +34,7 @@ class VideoStub; ...@@ -34,7 +34,7 @@ class VideoStub;
class ConnectionToHost { class ConnectionToHost {
public: public:
// The UI implementations maintain corresponding definitions of this // The UI implementations maintain corresponding definitions of this
// enumeration in webapp/client_session.js and // enumeration in client_session.js and
// android/java/src/org/chromium/chromoting/jni/JniInterface.java. Be sure to // android/java/src/org/chromium/chromoting/jni/JniInterface.java. Be sure to
// update these locations if you make any changes to the ordering. // update these locations if you make any changes to the ordering.
enum State { enum State {
......
...@@ -50,7 +50,7 @@ remoting.ClientSession = function(plugin, host, signalStrategy, mode, ...@@ -50,7 +50,7 @@ remoting.ClientSession = function(plugin, host, signalStrategy, mode,
base.inherits(this, base.EventSourceImpl); base.inherits(this, base.EventSourceImpl);
/** @private */ /** @private */
this.state_ = remoting.ClientSession.State.CREATED; this.state_ = remoting.ClientSession.State.INITIALIZING;
/** @private {!remoting.Error} */ /** @private {!remoting.Error} */
this.error_ = remoting.Error.none(); this.error_ = remoting.Error.none();
...@@ -98,20 +98,27 @@ remoting.ClientSession.Events = { ...@@ -98,20 +98,27 @@ remoting.ClientSession.Events = {
}; };
// Note that the positive values in both of these enums are copied directly // Note that the positive values in both of these enums are copied directly
// from chromoting_scriptable_object.h and must be kept in sync. The negative // from connection_to_host.h and must be kept in sync. Code in
// values represent state transitions that occur within the web-app that have // chromoting_instance.cc converts the C++ enums into strings that must match
// no corresponding plugin state transition. // the names given here.
// The negative values represent state transitions that occur within the
// web-app that have no corresponding plugin state transition.
/** @enum {number} */ /** @enum {number} */
remoting.ClientSession.State = { remoting.ClientSession.State = {
CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
CREATED: -1, CREATED: -1,
UNKNOWN: 0, UNKNOWN: 0,
CONNECTING: 1, INITIALIZING: 1,
INITIALIZING: 2, CONNECTING: 2,
CONNECTED: 3, // We don't currently receive AUTHENTICATED from the host - it comes through
CLOSED: 4, // as 'CONNECTING' instead.
FAILED: 5 // TODO(garykac) Update chromoting_instance.cc to send this once we've
// shipped a webapp release with support for AUTHENTICATED.
AUTHENTICATED: 3,
CONNECTED: 4,
CLOSED: 5,
FAILED: 6
}; };
/** /**
...@@ -484,7 +491,8 @@ remoting.ClientSession.prototype.setState_ = function(newState) { ...@@ -484,7 +491,8 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
var oldState = this.state_; var oldState = this.state_;
this.state_ = newState; this.state_ = newState;
var state = this.state_; var state = this.state_;
if (oldState == remoting.ClientSession.State.CONNECTING) { if (oldState == remoting.ClientSession.State.CONNECTING ||
oldState == remoting.ClientSession.State.AUTHENTICATED) {
if (this.state_ == remoting.ClientSession.State.CLOSED) { if (this.state_ == remoting.ClientSession.State.CLOSED) {
state = remoting.ClientSession.State.CONNECTION_CANCELED; state = remoting.ClientSession.State.CONNECTION_CANCELED;
} else if (this.state_ == remoting.ClientSession.State.FAILED && } else if (this.state_ == remoting.ClientSession.State.FAILED &&
......
...@@ -109,6 +109,7 @@ remoting.LogToServer.prototype.logSignalStrategyProgress = ...@@ -109,6 +109,7 @@ remoting.LogToServer.prototype.logSignalStrategyProgress =
remoting.LogToServer.isStartOfSession_ = function(state) { remoting.LogToServer.isStartOfSession_ = function(state) {
return ((state == remoting.ClientSession.State.CONNECTING) || return ((state == remoting.ClientSession.State.CONNECTING) ||
(state == remoting.ClientSession.State.INITIALIZING) || (state == remoting.ClientSession.State.INITIALIZING) ||
(state == remoting.ClientSession.State.AUTHENTICATED) ||
(state == remoting.ClientSession.State.CONNECTED)); (state == remoting.ClientSession.State.CONNECTED));
}; };
......
...@@ -59,12 +59,12 @@ remoting.ServerLogEntry.getValueForSessionState_ = function(state) { ...@@ -59,12 +59,12 @@ remoting.ServerLogEntry.getValueForSessionState_ = function(state) {
switch(state) { switch(state) {
case remoting.ClientSession.State.UNKNOWN: case remoting.ClientSession.State.UNKNOWN:
return 'unknown'; return 'unknown';
case remoting.ClientSession.State.CREATED:
return 'created';
case remoting.ClientSession.State.CONNECTING:
return 'connecting';
case remoting.ClientSession.State.INITIALIZING: case remoting.ClientSession.State.INITIALIZING:
return 'initializing'; return 'initializing';
case remoting.ClientSession.State.CONNECTING:
return 'connecting';
case remoting.ClientSession.State.AUTHENTICATED:
return 'authenticated';
case remoting.ClientSession.State.CONNECTED: case remoting.ClientSession.State.CONNECTED:
return 'connected'; return 'connected';
case remoting.ClientSession.State.CLOSED: case remoting.ClientSession.State.CLOSED:
......
...@@ -491,10 +491,6 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) { ...@@ -491,10 +491,6 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
this.initProtocolExtensions_(); this.initProtocolExtensions_();
break; break;
case remoting.ClientSession.State.CREATED:
console.log('Created plugin');
break;
case remoting.ClientSession.State.CONNECTING: case remoting.ClientSession.State.CONNECTING:
remoting.identity.getEmail().then( remoting.identity.getEmail().then(
function(/** string */ email) { function(/** string */ email) {
...@@ -502,6 +498,10 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) { ...@@ -502,6 +498,10 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
}); });
break; break;
case remoting.ClientSession.State.AUTHENTICATED:
console.log('Connection authenticated');
break;
case remoting.ClientSession.State.INITIALIZING: case remoting.ClientSession.State.INITIALIZING:
console.log('Initializing connection'); console.log('Initializing connection');
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment