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

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

Issue 1012073006: [Webapp Refactor] Removes the client plugin on disconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 * the client and host. 234 * the client and host.
235 */ 235 */
236 remoting.ClientSession.prototype.hasCapability = function(capability) { 236 remoting.ClientSession.prototype.hasCapability = function(capability) {
237 if (this.capabilities_ == null) 237 if (this.capabilities_ == null)
238 return false; 238 return false;
239 239
240 return this.capabilities_.indexOf(capability) > -1; 240 return this.capabilities_.indexOf(capability) > -1;
241 }; 241 };
242 242
243 /** 243 /**
244 * @return {void} Nothing.
245 */
246 remoting.ClientSession.prototype.removePlugin = function() {
kelvinp 2015/03/18 20:08:35 This is a misleading name as it doesn't remove the
247 this.plugin_ = null;
248 };
249
250 /**
251 * Disconnect the current session with a particular |error|. The session will 244 * Disconnect the current session with a particular |error|. The session will
252 * raise a |stateChanged| event in response to it. The caller should then call 245 * raise a |stateChanged| event in response to it. The caller should then call
253 * dispose() to remove and destroy the <embed> element. 246 * dispose() to remove and destroy the <embed> element.
254 * 247 *
255 * @param {!remoting.Error} error The reason for the disconnection. Use 248 * @param {!remoting.Error} error The reason for the disconnection. Use
256 * remoting.Error.none() if there is no error. 249 * remoting.Error.none() if there is no error.
257 * @return {void} Nothing. 250 * @return {void} Nothing.
258 */ 251 */
259 remoting.ClientSession.prototype.disconnect = function(error) { 252 remoting.ClientSession.prototype.disconnect = function(error) {
253 this.sendIq_(
254 '<cli:iq ' +
255 'to="' + this.host_.jabberId + '" ' +
256 'type="set" ' +
257 'id="session-terminate" ' +
258 'xmlns:cli="jabber:client">' +
259 '<jingle ' +
260 'xmlns="urn:xmpp:jingle:1" ' +
261 'action="session-terminate" ' +
262 'sid="' + this.sessionId_ + '">' +
263 '<reason><success/></reason>' +
264 '</jingle>' +
265 '</cli:iq>');
266
260 var state = error.isNone() ? 267 var state = error.isNone() ?
261 remoting.ClientSession.State.CLOSED : 268 remoting.ClientSession.State.CLOSED :
262 remoting.ClientSession.State.FAILED; 269 remoting.ClientSession.State.FAILED;
263 270
264 // The plugin won't send a state change notification, so we explicitly log 271 // The plugin won't send a state change notification, so we explicitly log
265 // the fact that the connection has closed. 272 // the fact that the connection has closed.
266 this.logToServer.logClientSessionStateChange(state, error); 273 this.logToServer.logClientSessionStateChange(state, error);
267 this.error_ = error; 274 this.error_ = error;
268 this.setState_(state); 275 this.setState_(state);
269 }; 276 };
270 277
271 /** 278 /**
272 * Deletes the <embed> element from the container and disconnects. 279 * Deletes the <embed> element from the container and disconnects.
273 * 280 *
274 * @return {void} Nothing. 281 * @return {void} Nothing.
275 */ 282 */
276 remoting.ClientSession.prototype.dispose = function() { 283 remoting.ClientSession.prototype.dispose = function() {
277 this.sendIq_( 284 this.plugin_ = null;
278 '<cli:iq ' +
279 'to="' + this.host_.jabberId + '" ' +
280 'type="set" ' +
281 'id="session-terminate" ' +
282 'xmlns:cli="jabber:client">' +
283 '<jingle ' +
284 'xmlns="urn:xmpp:jingle:1" ' +
285 'action="session-terminate" ' +
286 'sid="' + this.sessionId_ + '">' +
287 '<reason><success/></reason>' +
288 '</jingle>' +
289 '</cli:iq>');
290 this.removePlugin();
291 }; 285 };
292 286
293 /** 287 /**
294 * @return {remoting.ClientSession.State} The current state. 288 * @return {remoting.ClientSession.State} The current state.
295 */ 289 */
296 remoting.ClientSession.prototype.getState = function() { 290 remoting.ClientSession.prototype.getState = function() {
297 return this.state_; 291 return this.state_;
298 }; 292 };
299 293
300 /** 294 /**
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 */ 613 */
620 remoting.ClientSession.prototype.enableDebugRegion = function(enable) { 614 remoting.ClientSession.prototype.enableDebugRegion = function(enable) {
621 if (enable) { 615 if (enable) {
622 this.plugin_.setDebugDirtyRegionHandler( 616 this.plugin_.setDebugDirtyRegionHandler(
623 remoting.desktopConnectedView.handleDebugRegion.bind( 617 remoting.desktopConnectedView.handleDebugRegion.bind(
624 remoting.desktopConnectedView)); 618 remoting.desktopConnectedView));
625 } else { 619 } else {
626 this.plugin_.setDebugDirtyRegionHandler(null); 620 this.plugin_.setDebugDirtyRegionHandler(null);
627 } 621 }
628 } 622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698