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

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

Issue 1067133002: Move ProtocolExtensionManager from SessionConnector into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and Reviewer's feedback 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 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 17 matching lines...) Expand all
28 * 28 *
29 * @const 29 * @const
30 * @type {number} 30 * @type {number}
31 */ 31 */
32 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS = 15 * 60 * 1000; 32 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS = 15 * 60 * 1000;
33 33
34 /** 34 /**
35 * @param {remoting.ClientPlugin} plugin 35 * @param {remoting.ClientPlugin} plugin
36 * @param {remoting.Host} host The host to connect to. 36 * @param {remoting.Host} host The host to connect to.
37 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. 37 * @param {remoting.SignalStrategy} signalStrategy Signal strategy.
38 * @param {function(string, string):boolean} onExtensionMessage The handler for
39 * protocol extension messages. Returns true if a message is recognized;
40 * false otherwise.
41 * 38 *
42 * @constructor 39 * @constructor
43 * @extends {base.EventSourceImpl} 40 * @extends {base.EventSourceImpl}
44 * @implements {base.Disposable} 41 * @implements {base.Disposable}
45 * @implements {remoting.ClientPlugin.ConnectionEventHandler} 42 * @implements {remoting.ClientPlugin.ConnectionEventHandler}
46 */ 43 */
47 remoting.ClientSession = function(plugin, host, signalStrategy, 44 remoting.ClientSession = function(plugin, host, signalStrategy) {
48 onExtensionMessage) {
49 base.inherits(this, base.EventSourceImpl); 45 base.inherits(this, base.EventSourceImpl);
50 46
51 /** @private */ 47 /** @private */
52 this.state_ = remoting.ClientSession.State.INITIALIZING; 48 this.state_ = remoting.ClientSession.State.INITIALIZING;
53 49
54 /** @private {!remoting.Error} */ 50 /** @private {!remoting.Error} */
55 this.error_ = remoting.Error.none(); 51 this.error_ = remoting.Error.none();
56 52
57 /** @private */ 53 /** @private */
58 this.host_ = host; 54 this.host_ = host;
(...skipping 14 matching lines...) Expand all
73 remoting.formatIq.setJids(this.signalStrategy_.getJid(), host.jabberId); 69 remoting.formatIq.setJids(this.signalStrategy_.getJid(), host.jabberId);
74 70
75 /** 71 /**
76 * Allow host-offline error reporting to be suppressed in situations where it 72 * Allow host-offline error reporting to be suppressed in situations where it
77 * would not be useful, for example, when using a cached host JID. 73 * would not be useful, for example, when using a cached host JID.
78 * 74 *
79 * @type {boolean} @private 75 * @type {boolean} @private
80 */ 76 */
81 this.logHostOfflineErrors_ = true; 77 this.logHostOfflineErrors_ = true;
82 78
83 /** @private {function(string, string):boolean} */
84 this.onExtensionMessageHandler_ = onExtensionMessage;
85
86 /** @private {remoting.ClientPlugin} */ 79 /** @private {remoting.ClientPlugin} */
87 this.plugin_ = plugin; 80 this.plugin_ = plugin;
88 plugin.setConnectionEventHandler(this); 81 plugin.setConnectionEventHandler(this);
89 82
90 this.defineEvents(Object.keys(remoting.ClientSession.Events)); 83 this.defineEvents(Object.keys(remoting.ClientSession.Events));
91 }; 84 };
92 85
93 /** @enum {string} */ 86 /** @enum {string} */
94 remoting.ClientSession.Events = { 87 remoting.ClientSession.Events = {
95 stateChanged: 'stateChanged', // deprecated. 88 stateChanged: 'stateChanged', // deprecated.
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return; 498 return;
506 } 499 }
507 500
508 this.capabilities_ = capabilities; 501 this.capabilities_ = capabilities;
509 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { 502 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) {
510 this.sendGoogleDriveAccessToken_(); 503 this.sendGoogleDriveAccessToken_();
511 } 504 }
512 }; 505 };
513 506
514 /** 507 /**
515 * @param {string} type
516 * @param {string} data
517 */
518 remoting.ClientSession.prototype.onExtensionMessage = function(type, data) {
519 this.onExtensionMessageHandler_(type, data);
520 };
521
522 /**
523 * @param {remoting.ClientSession.State} newState The new state for the session. 508 * @param {remoting.ClientSession.State} newState The new state for the session.
524 * @return {void} Nothing. 509 * @return {void} Nothing.
525 * @private 510 * @private
526 */ 511 */
527 remoting.ClientSession.prototype.setState_ = function(newState) { 512 remoting.ClientSession.prototype.setState_ = function(newState) {
528 var oldState = this.state_; 513 var oldState = this.state_;
529 this.state_ = newState; 514 this.state_ = newState;
530 var state = this.state_; 515 var state = this.state_;
531 if (oldState == remoting.ClientSession.State.CONNECTING || 516 if (oldState == remoting.ClientSession.State.CONNECTING ||
532 oldState == remoting.ClientSession.State.AUTHENTICATED) { 517 oldState == remoting.ClientSession.State.AUTHENTICATED) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 'https://docs.google.com/feeds/', 613 'https://docs.google.com/feeds/',
629 'https://www.googleapis.com/auth/drive' 614 'https://www.googleapis.com/auth/drive'
630 ]; 615 ];
631 remoting.identity.getNewToken(googleDriveScopes). 616 remoting.identity.getNewToken(googleDriveScopes).
632 then(sendToken). 617 then(sendToken).
633 catch(remoting.Error.handler(sendError)); 618 catch(remoting.Error.handler(sendError));
634 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), 619 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this),
635 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); 620 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS);
636 }; 621 };
637 622
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/client_plugin_impl.js ('k') | remoting/webapp/crd/js/desktop_remoting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698