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

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

Issue 952353002: Requiem for client_screen.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * Functions related to the 'client screen' for Chromoting.
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 /**
16 * @type {remoting.ClientSession} The client session object, set once the
17 * connector has invoked its onOk callback.
18 */
19 remoting.clientSession = null;
20
21 /**
22 * @type {remoting.DesktopConnectedView} The client session object, set once the
23 * connector has invoked its onOk callback.
24 */
25 remoting.desktopConnectedView = null;
26
27 /**
28 * Update the remoting client layout in response to a resize event.
29 *
30 * @return {void} Nothing.
31 */
32 remoting.onResize = function() {
33 if (remoting.desktopConnectedView) {
34 remoting.desktopConnectedView.onResize();
35 }
36 };
37
38 /**
39 * Handle changes in the visibility of the window, for example by pausing video.
40 *
41 * @return {void} Nothing.
42 */
43 remoting.onVisibilityChanged = function() {
44 if (remoting.desktopConnectedView) {
45 remoting.desktopConnectedView.pauseVideo(
46 ('hidden' in document) ? document.hidden : document.webkitHidden);
47 }
48 };
49
50 /**
51 * Disconnect the remoting client.
52 *
53 * @return {void} Nothing.
54 */
55 remoting.disconnect = function() {
56 if (!remoting.clientSession) {
57 return;
58 }
59 remoting.clientSession.disconnect(remoting.Error.NONE);
60 console.log('Disconnected.');
61 };
62
63 /**
64 * Callback function called when the state of the client plugin changes. The
65 * current and previous states are available via the |state| member variable.
66 *
67 * @param {remoting.ClientSession.StateEvent=} state
68 */
69 function onClientStateChange_(state) {
70 switch (state.current) {
71 case remoting.ClientSession.State.CLOSED:
72 console.log('Connection closed by host');
73 if (remoting.desktopConnectedView.getMode() ==
74 remoting.DesktopConnectedView.Mode.IT2ME) {
75 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
76 remoting.hangoutSessionEvents.raiseEvent(
77 remoting.hangoutSessionEvents.sessionStateChanged,
78 remoting.ClientSession.State.CLOSED);
79 } else {
80 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
81 }
82 remoting.app.onDisconnected();
83 break;
84
85 case remoting.ClientSession.State.FAILED:
86 var error = remoting.clientSession.getError();
87 console.error('Client plugin reported connection failed: ' + error);
88 if (error == null) {
89 error = remoting.Error.UNEXPECTED;
90 }
91 remoting.app.onError(error);
92 break;
93
94 default:
95 console.error('Unexpected client plugin state: ' + state.current);
96 // This should only happen if the web-app and client plugin get out of
97 // sync, so MISSING_PLUGIN is a suitable error.
98 remoting.app.onError(remoting.Error.MISSING_PLUGIN);
99 break;
100 }
101
102 remoting.clientSession.removeEventListener('stateChanged',
103 onClientStateChange_);
104 remoting.clientSession.cleanup();
105 remoting.clientSession = null;
106 remoting.desktopConnectedView = null;
107 }
108
109 /**
110 * Timer callback to update the statistics panel.
111 */
112 function updateStatistics_() {
113 if (!remoting.clientSession ||
114 remoting.clientSession.getState() !=
115 remoting.ClientSession.State.CONNECTED) {
116 return;
117 }
118 var perfstats = remoting.clientSession.getPerfStats();
119 remoting.stats.update(perfstats);
120 remoting.clientSession.logStatistics(perfstats);
121 // Update the stats once per second.
122 window.setTimeout(updateStatistics_, 1000);
123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698