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

Side by Side Diff: remoting/webapp/base/js/application.js

Issue 1012073006: [Webapp Refactor] Removes the client plugin on disconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback 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
« no previous file with comments | « no previous file | remoting/webapp/crd/js/client_session.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * Interface abstracting the Application functionality. 7 * Interface abstracting the Application functionality.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 /** 115 /**
116 * Called when a new session has been connected. 116 * Called when a new session has been connected.
117 * 117 *
118 * @param {remoting.ConnectionInfo} connectionInfo 118 * @param {remoting.ConnectionInfo} connectionInfo
119 * @return {void} Nothing. 119 * @return {void} Nothing.
120 */ 120 */
121 remoting.Application.prototype.onConnected = function(connectionInfo) { 121 remoting.Application.prototype.onConnected = function(connectionInfo) {
122 this.sessionConnectedHooks_ = new base.Disposables( 122 this.sessionConnectedHooks_ = new base.Disposables(
123 new base.EventHook(connectionInfo.session(), 'stateChanged', 123 new base.EventHook(connectionInfo.session(), 'stateChanged',
124 this.onClientStateChange_.bind(this)), 124 this.onSessionFinished_.bind(this)),
125 new base.RepeatingTimer(this.updateStatistics_.bind(this), 1000) 125 new base.RepeatingTimer(this.updateStatistics_.bind(this), 1000)
126 ); 126 );
127 remoting.clipboard.startSession(); 127 remoting.clipboard.startSession();
128 128
129 this.delegate_.handleConnected(connectionInfo); 129 this.delegate_.handleConnected(connectionInfo);
130 }; 130 };
131 131
132 /** 132 /**
133 * Called when the current session has been disconnected. 133 * Called when the current session has been disconnected.
134 * 134 *
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return this.sessionConnector_; 186 return this.sessionConnector_;
187 }; 187 };
188 188
189 /** 189 /**
190 * Callback function called when the state of the client plugin changes. The 190 * Callback function called when the state of the client plugin changes. The
191 * current and previous states are available via the |state| member variable. 191 * current and previous states are available via the |state| member variable.
192 * 192 *
193 * @param {remoting.ClientSession.StateEvent=} state 193 * @param {remoting.ClientSession.StateEvent=} state
194 * @private 194 * @private
195 */ 195 */
196 remoting.Application.prototype.onClientStateChange_ = function(state) { 196 remoting.Application.prototype.onSessionFinished_ = function(state) {
197 switch (state.current) { 197 switch (state.current) {
198 case remoting.ClientSession.State.CLOSED: 198 case remoting.ClientSession.State.CLOSED:
199 console.log('Connection closed by host'); 199 console.log('Connection closed by host');
200 this.onDisconnected(); 200 this.onDisconnected();
201 break; 201 break;
202 case remoting.ClientSession.State.FAILED: 202 case remoting.ClientSession.State.FAILED:
203 var error = remoting.clientSession.getError(); 203 var error = remoting.clientSession.getError();
204 console.error('Client plugin reported connection failed: ' + 204 console.error('Client plugin reported connection failed: ' +
205 error.toString()); 205 error.toString());
206 if (error === null) { 206 if (error === null) {
207 error = remoting.Error.unexpected(); 207 error = remoting.Error.unexpected();
208 } 208 }
209 this.onError(error); 209 this.onError(error);
210 break; 210 break;
211 211
212 default: 212 default:
213 console.error('Unexpected client plugin state: ' + state.current); 213 console.error('Unexpected client plugin state: ' + state.current);
214 // This should only happen if the web-app and client plugin get out of 214 // This should only happen if the web-app and client plugin get out of
215 // sync, so MISSING_PLUGIN is a suitable error. 215 // sync, so MISSING_PLUGIN is a suitable error.
216 this.onError(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); 216 this.onError(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN));
217 break; 217 break;
218 } 218 }
219 219
220 base.dispose(this.sessionConnectedHooks_); 220 base.dispose(this.sessionConnectedHooks_);
221 this.sessionConnectedHooks_= null; 221 this.sessionConnectedHooks_= null;
222 remoting.clientSession.dispose(); 222 this.sessionConnector_.closeSession();
223 remoting.clientSession = null;
224 }; 223 };
225 224
226 /** @private */ 225 /** @private */
227 remoting.Application.prototype.updateStatistics_ = function() { 226 remoting.Application.prototype.updateStatistics_ = function() {
228 var perfstats = remoting.clientSession.getPerfStats(); 227 var perfstats = remoting.clientSession.getPerfStats();
229 remoting.stats.update(perfstats); 228 remoting.stats.update(perfstats);
230 remoting.clientSession.logStatistics(perfstats); 229 remoting.clientSession.logStatistics(perfstats);
231 }; 230 };
232 231
233 232
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 * Perform any application-specific cleanup before exiting. This is called in 318 * Perform any application-specific cleanup before exiting. This is called in
320 * lieu of start() if the user declines the app permissions, and will usually 319 * lieu of start() if the user declines the app permissions, and will usually
321 * be called immediately prior to exiting, although delegates should not rely 320 * be called immediately prior to exiting, although delegates should not rely
322 * on this. 321 * on this.
323 */ 322 */
324 remoting.Application.Delegate.prototype.handleExit = function() {}; 323 remoting.Application.Delegate.prototype.handleExit = function() {};
325 324
326 325
327 /** @type {remoting.Application} */ 326 /** @type {remoting.Application} */
328 remoting.app = null; 327 remoting.app = null;
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/crd/js/client_session.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698