OLD | NEW |
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 * Class handling reconnecting the session when it is disconnected due to | 7 * Class handling reconnecting the session when it is disconnected due to |
8 * network failure. | 8 * network failure. |
9 * | 9 * |
10 * The SmartReconnector listens for changes in connection state of | 10 * The SmartReconnector listens for changes in connection state of |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }, | 74 }, |
75 | 75 |
76 reconnectAsync_: function() { | 76 reconnectAsync_: function() { |
77 this.cancelPending_(); | 77 this.cancelPending_(); |
78 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 78 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
79 this.reconnectTimerId_ = window.setTimeout( | 79 this.reconnectTimerId_ = window.setTimeout( |
80 this.bound_.reconnect, remoting.SmartReconnector.kReconnectDelay); | 80 this.bound_.reconnect, remoting.SmartReconnector.kReconnectDelay); |
81 }, | 81 }, |
82 | 82 |
83 /** | 83 /** |
84 * @param {remoting.ClientSession.StateEvent} event | 84 * @param {remoting.ClientSession.StateEvent=} event |
85 */ | 85 */ |
86 stateChanged_: function(event) { | 86 stateChanged_: function(event) { |
87 var State = remoting.ClientSession.State; | 87 var State = remoting.ClientSession.State; |
88 if (event.previous === State.CONNECTED && event.current === State.FAILED) { | 88 if (event.previous === State.CONNECTED && event.current === State.FAILED) { |
89 this.cancelPending_(); | 89 this.cancelPending_(); |
90 if (navigator.onLine) { | 90 if (navigator.onLine) { |
91 this.reconnect_(); | 91 this.reconnect_(); |
92 } else { | 92 } else { |
93 window.addEventListener('online', this.bound_.reconnectAsync, false); | 93 window.addEventListener('online', this.bound_.reconnectAsync, false); |
94 } | 94 } |
95 } | 95 } |
96 }, | 96 }, |
97 | 97 |
98 /** | 98 /** |
99 * @param {boolean} active True if the video channel is active. | 99 * @param {boolean=} active True if the video channel is active. |
100 */ | 100 */ |
101 videoChannelStateChanged_: function (active) { | 101 videoChannelStateChanged_: function (active) { |
102 this.cancelPending_(); | 102 this.cancelPending_(); |
103 if (!active) { | 103 if (!active) { |
104 window.addEventListener( | 104 window.addEventListener( |
105 'online', this.bound_.startReconnectTimeout, false); | 105 'online', this.bound_.startReconnectTimeout, false); |
106 } | 106 } |
107 }, | 107 }, |
108 | 108 |
109 startReconnectTimeout_: function () { | 109 startReconnectTimeout_: function () { |
(...skipping 14 matching lines...) Expand all Loading... |
124 | 124 |
125 dispose: function() { | 125 dispose: function() { |
126 this.clientSession_.removeEventListener( | 126 this.clientSession_.removeEventListener( |
127 remoting.ClientSession.Events.stateChanged, | 127 remoting.ClientSession.Events.stateChanged, |
128 this.bound_.stateChanged); | 128 this.bound_.stateChanged); |
129 this.clientSession_.removeEventListener( | 129 this.clientSession_.removeEventListener( |
130 remoting.ClientSession.Events.videoChannelStateChanged, | 130 remoting.ClientSession.Events.videoChannelStateChanged, |
131 this.bound_.videoChannelStateChanged); | 131 this.bound_.videoChannelStateChanged); |
132 } | 132 } |
133 }; | 133 }; |
OLD | NEW |