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

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: Rebase + Ready for Check-in 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 | « remoting/webapp/browser_test/browser_test.js ('k') | 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
(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 } else {
77 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
78 }
79 remoting.app.onDisconnected();
80 break;
81
82 case remoting.ClientSession.State.FAILED:
83 var error = remoting.clientSession.getError();
84 console.error('Client plugin reported connection failed: ' + error);
85 if (error == null) {
86 error = remoting.Error.UNEXPECTED;
87 }
88 remoting.app.onError(error);
89 break;
90
91 default:
92 console.error('Unexpected client plugin state: ' + state.current);
93 // This should only happen if the web-app and client plugin get out of
94 // sync, so MISSING_PLUGIN is a suitable error.
95 remoting.app.onError(remoting.Error.MISSING_PLUGIN);
96 break;
97 }
98
99 remoting.clientSession.removeEventListener('stateChanged',
100 onClientStateChange_);
101 remoting.clientSession.cleanup();
102 remoting.clientSession = null;
103 remoting.desktopConnectedView = null;
104 }
105
106 /**
107 * Timer callback to update the statistics panel.
108 */
109 function updateStatistics_() {
110 if (!remoting.clientSession ||
111 remoting.clientSession.getState() !=
112 remoting.ClientSession.State.CONNECTED) {
113 return;
114 }
115 var perfstats = remoting.clientSession.getPerfStats();
116 remoting.stats.update(perfstats);
117 remoting.clientSession.logStatistics(perfstats);
118 // Update the stats once per second.
119 window.setTimeout(updateStatistics_, 1000);
120 }
OLDNEW
« no previous file with comments | « remoting/webapp/browser_test/browser_test.js ('k') | remoting/webapp/crd/js/client_session.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698