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

Side by Side Diff: remoting/webapp/me2mom/remoting.js

Issue 7511001: Don't transition to in-session mode until the connection has been established. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/me2mom/client_session.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 var remoting = remoting || {}; 5 var remoting = remoting || {};
6 6
7 (function() { 7 (function() {
8 'use strict'; 8 'use strict';
9 9
10 window.addEventListener('blur', pluginLostFocus_, false); 10 window.addEventListener('blur', pluginLostFocus_, false);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ', Capture: ' + stats['capture_latency'].toFixed(2) + 'ms' + 431 ', Capture: ' + stats['capture_latency'].toFixed(2) + 'ms' +
432 ', Encode: ' + stats['encode_latency'].toFixed(2) + 'ms' + 432 ', Encode: ' + stats['encode_latency'].toFixed(2) + 'ms' +
433 ', Decode: ' + stats['decode_latency'].toFixed(2) + 'ms' + 433 ', Decode: ' + stats['decode_latency'].toFixed(2) + 'ms' +
434 ', Render: ' + stats['render_latency'].toFixed(2) + 'ms' + 434 ', Render: ' + stats['render_latency'].toFixed(2) + 'ms' +
435 ', Latency: ' + stats['roundtrip_latency'].toFixed(2) + 'ms'; 435 ', Latency: ' + stats['roundtrip_latency'].toFixed(2) + 'ms';
436 436
437 // Update the stats once per second. 437 // Update the stats once per second.
438 window.setTimeout(updateStatistics, 1000); 438 window.setTimeout(updateStatistics, 1000);
439 } 439 }
440 440
441 function onClientStateChange_(state) { 441 function onClientStateChange_(oldState) {
442 var state = remoting.session.state;
442 if (state == remoting.ClientSession.State.UNKNOWN) { 443 if (state == remoting.ClientSession.State.UNKNOWN) {
443 setClientStateMessage('Unknown'); 444 setClientStateMessage('Unknown');
444 } else if (state == remoting.ClientSession.State.CREATED) { 445 } else if (state == remoting.ClientSession.State.CREATED) {
445 setClientStateMessage('Created'); 446 setClientStateMessage('Created');
446 } else if (state == remoting.ClientSession.State.BAD_PLUGIN_VERSION) { 447 } else if (state == remoting.ClientSession.State.BAD_PLUGIN_VERSION) {
447 setClientStateMessage('Incompatible Plugin Version'); 448 setClientStateMessage('Incompatible Plugin Version');
448 } else if (state == remoting.ClientSession.State.UNKNOWN_PLUGIN_ERROR) { 449 } else if (state == remoting.ClientSession.State.UNKNOWN_PLUGIN_ERROR) {
449 setClientStateMessage('Unknown error with plugin.'); 450 setClientStateMessage('Unknown error with plugin.');
450 } else if (state == remoting.ClientSession.State.CONNECTING) { 451 } else if (state == remoting.ClientSession.State.CONNECTING) {
451 setClientStateMessage('Connecting as ' + remoting.username); 452 setClientStateMessage('Connecting as ' + remoting.username);
452 } else if (state == remoting.ClientSession.State.INITIALIZING) { 453 } else if (state == remoting.ClientSession.State.INITIALIZING) {
453 setClientStateMessage('Initializing connection'); 454 setClientStateMessage('Initializing connection');
454 } else if (state == remoting.ClientSession.State.CONNECTED) { 455 } else if (state == remoting.ClientSession.State.CONNECTED) {
455 var split = remoting.hostJid.split('/'); 456 var split = remoting.hostJid.split('/');
456 var host = null; 457 var host = null;
457 if (split.length == 2) { 458 if (split.length == 2) {
458 host = split[0]; 459 host = split[0];
459 } 460 }
460 setClientStateMessage('Connected to', host); 461 setClientStateMessage('Connected to', host);
462 setGlobalMode(remoting.AppMode.IN_SESSION);
461 updateStatistics(); 463 updateStatistics();
462 } else if (state == remoting.ClientSession.State.CLOSED) { 464 } else if (state == remoting.ClientSession.State.CLOSED) {
463 setClientStateMessage('Closed'); 465 setClientStateMessage('Closed');
466 if (oldState != remoting.ClientSession.State.CONNECTED) {
467 // TODO(jamiewalch): This is not quite correct, as it will report
468 // "Invalid access code", regardless of what actually went wrong.
469 // Fix this up by having the host send a suitable error code.
470 showConnectError_(404);
471 }
464 } else if (state == remoting.ClientSession.State.CONNECTION_FAILED) { 472 } else if (state == remoting.ClientSession.State.CONNECTION_FAILED) {
465 setClientStateMessage('Failed'); 473 setClientStateMessage('Failed');
466 } else { 474 } else {
467 setClientStateMessage('Bad State: ' + state); 475 setClientStateMessage('Bad State: ' + state);
468 } 476 }
469 } 477 }
470 478
471 function startSession_() { 479 function startSession_() {
472 remoting.debug.log('Starting session...'); 480 remoting.debug.log('Starting session...');
473 remoting.username = getEmail(); 481 remoting.username = getEmail();
474 setGlobalMode(remoting.AppMode.IN_SESSION);
475 remoting.session = 482 remoting.session =
476 new remoting.ClientSession(remoting.hostJid, remoting.hostPublicKey, 483 new remoting.ClientSession(remoting.hostJid, remoting.hostPublicKey,
477 remoting.accessCode, getEmail(), 484 remoting.accessCode, getEmail(),
478 onClientStateChange_); 485 onClientStateChange_);
479 remoting.oauth2.callWithToken(function(token) { 486 remoting.oauth2.callWithToken(function(token) {
480 remoting.session.createPluginAndConnect( 487 remoting.session.createPluginAndConnect(
481 document.getElementById('session-mode'), 488 document.getElementById('session-mode'),
482 token); 489 token);
483 }); 490 });
484 } 491 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 remoting.session = null; 639 remoting.session = null;
633 remoting.debug.log('Disconnected.'); 640 remoting.debug.log('Disconnected.');
634 remoting.setClientMode('unconnected'); 641 remoting.setClientMode('unconnected');
635 var accessCode = document.getElementById('access-code-entry'); 642 var accessCode = document.getElementById('access-code-entry');
636 accessCode.value = ''; 643 accessCode.value = '';
637 setGlobalMode(remoting.AppMode.CLIENT); 644 setGlobalMode(remoting.AppMode.CLIENT);
638 } 645 }
639 } 646 }
640 647
641 }()); 648 }());
OLDNEW
« no previous file with comments | « remoting/webapp/me2mom/client_session.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698