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

Side by Side Diff: remoting/webapp/crd/js/client_session.js

Issue 1032553008: [Chromoting] Update client connection enums in JS to match C++. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add support for AUTHENTICATED in webapp Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 this.defineEvents(Object.keys(remoting.ClientSession.Events)); 91 this.defineEvents(Object.keys(remoting.ClientSession.Events));
92 }; 92 };
93 93
94 /** @enum {string} */ 94 /** @enum {string} */
95 remoting.ClientSession.Events = { 95 remoting.ClientSession.Events = {
96 stateChanged: 'stateChanged', 96 stateChanged: 'stateChanged',
97 videoChannelStateChanged: 'videoChannelStateChanged', 97 videoChannelStateChanged: 'videoChannelStateChanged',
98 }; 98 };
99 99
100 // Note that the positive values in both of these enums are copied directly 100 // Note that the positive values in both of these enums are copied directly
101 // from chromoting_scriptable_object.h and must be kept in sync. The negative 101 // from connection_to_host.h and must be kept in sync. Code in
102 // values represent state transitions that occur within the web-app that have 102 // chromoting_instance.cc converts the C++ enums into strings that must match
103 // no corresponding plugin state transition. 103 // the names given here.
104 // The negative values represent state transitions that occur within the
105 // web-app that have no corresponding plugin state transition.
104 /** @enum {number} */ 106 /** @enum {number} */
105 remoting.ClientSession.State = { 107 remoting.ClientSession.State = {
106 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. 108 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
107 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. 109 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
108 CREATED: -1, 110 CREATED: -1,
109 UNKNOWN: 0, 111 UNKNOWN: 0,
110 CONNECTING: 1, 112 INITIALIZING: 1,
Sergey Ulanov 2015/03/25 00:01:49 The plugin never sends INITIALIZING state notifica
garykac 2015/03/26 19:03:48 Done.
111 INITIALIZING: 2, 113 CONNECTING: 2,
112 CONNECTED: 3, 114 // We don't currently receive AUTHENTICATED from the host - it comes through
113 CLOSED: 4, 115 // as 'CONNECTING' instead.
114 FAILED: 5 116 // TODO(garykac) Update chromoting_instance.cc to send this once we've
117 // shipped a webapp release with support for AUTHENTICATED.
118 AUTHENTICATED: 3,
119 CONNECTED: 4,
120 CLOSED: 5,
121 FAILED: 6
115 }; 122 };
116 123
117 /** 124 /**
118 * @param {string} state The state name. 125 * @param {string} state The state name.
119 * @return {remoting.ClientSession.State} The session state enum value. 126 * @return {remoting.ClientSession.State} The session state enum value.
120 */ 127 */
121 remoting.ClientSession.State.fromString = function(state) { 128 remoting.ClientSession.State.fromString = function(state) {
122 if (!remoting.ClientSession.State.hasOwnProperty(state)) { 129 if (!remoting.ClientSession.State.hasOwnProperty(state)) {
123 throw "Invalid ClientSession.State: " + state; 130 throw "Invalid ClientSession.State: " + state;
124 } 131 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 484
478 /** 485 /**
479 * @param {remoting.ClientSession.State} newState The new state for the session. 486 * @param {remoting.ClientSession.State} newState The new state for the session.
480 * @return {void} Nothing. 487 * @return {void} Nothing.
481 * @private 488 * @private
482 */ 489 */
483 remoting.ClientSession.prototype.setState_ = function(newState) { 490 remoting.ClientSession.prototype.setState_ = function(newState) {
484 var oldState = this.state_; 491 var oldState = this.state_;
485 this.state_ = newState; 492 this.state_ = newState;
486 var state = this.state_; 493 var state = this.state_;
487 if (oldState == remoting.ClientSession.State.CONNECTING) { 494 if (oldState == remoting.ClientSession.State.CONNECTING ||
495 oldState == remoting.ClientSession.State.AUTHENTICATED) {
garykac 2015/03/24 20:36:38 Currently, AUTHENTICATED is sent as CONNECTING, so
488 if (this.state_ == remoting.ClientSession.State.CLOSED) { 496 if (this.state_ == remoting.ClientSession.State.CLOSED) {
489 state = remoting.ClientSession.State.CONNECTION_CANCELED; 497 state = remoting.ClientSession.State.CONNECTION_CANCELED;
490 } else if (this.state_ == remoting.ClientSession.State.FAILED && 498 } else if (this.state_ == remoting.ClientSession.State.FAILED &&
491 this.error_.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) && 499 this.error_.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) &&
492 !this.logHostOfflineErrors_) { 500 !this.logHostOfflineErrors_) {
493 // The application requested host-offline errors to be suppressed, for 501 // The application requested host-offline errors to be suppressed, for
494 // example, because this connection attempt is using a cached host JID. 502 // example, because this connection attempt is using a cached host JID.
495 console.log('Suppressing host-offline error.'); 503 console.log('Suppressing host-offline error.');
496 state = remoting.ClientSession.State.CONNECTION_CANCELED; 504 state = remoting.ClientSession.State.CONNECTION_CANCELED;
497 } 505 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 'https://docs.google.com/feeds/', 604 'https://docs.google.com/feeds/',
597 'https://www.googleapis.com/auth/drive' 605 'https://www.googleapis.com/auth/drive'
598 ]; 606 ];
599 remoting.identity.getNewToken(googleDriveScopes). 607 remoting.identity.getNewToken(googleDriveScopes).
600 then(sendToken). 608 then(sendToken).
601 catch(remoting.Error.handler(sendError)); 609 catch(remoting.Error.handler(sendError));
602 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), 610 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this),
603 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); 611 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS);
604 }; 612 };
605 613
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698