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) {
case protocol::ConnectionToHost::AUTHENTICATED:
// Report the authenticated state as 'CONNECTING' to avoid changing
// 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";
case protocol::ConnectionToHost::CONNECTED:
return "CONNECTED";
......
......@@ -34,7 +34,7 @@ class VideoStub;
class ConnectionToHost {
public:
// 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
// update these locations if you make any changes to the ordering.
enum State {
......
......@@ -50,7 +50,7 @@ remoting.ClientSession = function(plugin, host, signalStrategy, mode,
base.inherits(this, base.EventSourceImpl);
/** @private */
this.state_ = remoting.ClientSession.State.CREATED;
this.state_ = remoting.ClientSession.State.INITIALIZING;
/** @private {!remoting.Error} */
this.error_ = remoting.Error.none();
......@@ -98,20 +98,27 @@ remoting.ClientSession.Events = {
};
// 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
// values represent state transitions that occur within the web-app that have
// no corresponding plugin state transition.
// from connection_to_host.h and must be kept in sync. Code in
// chromoting_instance.cc converts the C++ enums into strings that must match
// 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} */
remoting.ClientSession.State = {
CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
CREATED: -1,
UNKNOWN: 0,
CONNECTING: 1,
INITIALIZING: 2,
CONNECTED: 3,
CLOSED: 4,
FAILED: 5
INITIALIZING: 1,
CONNECTING: 2,
// We don't currently receive AUTHENTICATED from the host - it comes through
// as 'CONNECTING' instead.
// 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) {
var oldState = this.state_;
this.state_ = newState;
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) {
state = remoting.ClientSession.State.CONNECTION_CANCELED;
} else if (this.state_ == remoting.ClientSession.State.FAILED &&
......
......@@ -109,6 +109,7 @@ remoting.LogToServer.prototype.logSignalStrategyProgress =
remoting.LogToServer.isStartOfSession_ = function(state) {
return ((state == remoting.ClientSession.State.CONNECTING) ||
(state == remoting.ClientSession.State.INITIALIZING) ||
(state == remoting.ClientSession.State.AUTHENTICATED) ||
(state == remoting.ClientSession.State.CONNECTED));
};
......
......@@ -59,12 +59,12 @@ remoting.ServerLogEntry.getValueForSessionState_ = function(state) {
switch(state) {
case remoting.ClientSession.State.UNKNOWN:
return 'unknown';
case remoting.ClientSession.State.CREATED:
return 'created';
case remoting.ClientSession.State.CONNECTING:
return 'connecting';
case remoting.ClientSession.State.INITIALIZING:
return 'initializing';
case remoting.ClientSession.State.CONNECTING:
return 'connecting';
case remoting.ClientSession.State.AUTHENTICATED:
return 'authenticated';
case remoting.ClientSession.State.CONNECTED:
return 'connected';
case remoting.ClientSession.State.CLOSED:
......
......@@ -491,10 +491,6 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
this.initProtocolExtensions_();
break;
case remoting.ClientSession.State.CREATED:
console.log('Created plugin');
break;
case remoting.ClientSession.State.CONNECTING:
remoting.identity.getEmail().then(
function(/** string */ email) {
......@@ -502,6 +498,10 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
});
break;
case remoting.ClientSession.State.AUTHENTICATED:
console.log('Connection authenticated');
break;
case remoting.ClientSession.State.INITIALIZING:
console.log('Initializing connection');
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