OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 (function() { | 10 (function() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 return this.signalStrategy_.getError(); | 104 return this.signalStrategy_.getError(); |
105 }; | 105 }; |
106 | 106 |
107 remoting.DnsBlackholeChecker.prototype.getJid = function() { | 107 remoting.DnsBlackholeChecker.prototype.getJid = function() { |
108 base.debug.assert(this.state_ == remoting.SignalStrategy.State.CONNECTED); | 108 base.debug.assert(this.state_ == remoting.SignalStrategy.State.CONNECTED); |
109 return this.signalStrategy_.getJid(); | 109 return this.signalStrategy_.getJid(); |
110 }; | 110 }; |
111 | 111 |
112 remoting.DnsBlackholeChecker.prototype.dispose = function() { | 112 remoting.DnsBlackholeChecker.prototype.dispose = function() { |
113 if (this.xhr_) { | 113 this.xhr_ = null; |
114 this.xhr_.abort(); | |
115 this.xhr_ = null; | |
116 } | |
117 base.dispose(this.signalStrategy_); | 114 base.dispose(this.signalStrategy_); |
118 this.setState_(remoting.SignalStrategy.State.CLOSED); | 115 this.setState_(remoting.SignalStrategy.State.CLOSED); |
119 }; | 116 }; |
120 | 117 |
121 /** | 118 /** |
122 * @param {remoting.LogToServer} logToServer The LogToServer instance for the | 119 * @param {remoting.LogToServer} logToServer The LogToServer instance for the |
123 * connection. | 120 * connection. |
124 */ | 121 */ |
125 remoting.DnsBlackholeChecker.prototype.sendConnectionSetupResults = function( | 122 remoting.DnsBlackholeChecker.prototype.sendConnectionSetupResults = function( |
126 logToServer) { | 123 logToServer) { |
(...skipping 23 matching lines...) Expand all Loading... |
150 // In case DNS blackhole is active the external state stays FAILED. | 147 // In case DNS blackhole is active the external state stays FAILED. |
151 break; | 148 break; |
152 } | 149 } |
153 }; | 150 }; |
154 | 151 |
155 /** | 152 /** |
156 * @param {!remoting.Xhr.Response} response | 153 * @param {!remoting.Xhr.Response} response |
157 * @private | 154 * @private |
158 */ | 155 */ |
159 remoting.DnsBlackholeChecker.prototype.onHttpRequestDone_ = function(response) { | 156 remoting.DnsBlackholeChecker.prototype.onHttpRequestDone_ = function(response) { |
| 157 if (this.xhr_ == null) { |
| 158 // This happens when the dispose() method is called while a |
| 159 // request is pending. |
| 160 return; |
| 161 } |
| 162 |
160 this.xhr_ = null; | 163 this.xhr_ = null; |
161 if (response.status >= 200 && response.status <= 299) { | 164 if (response.status >= 200 && response.status <= 299) { |
162 console.log("DNS blackhole check succeeded."); | 165 console.log("DNS blackhole check succeeded."); |
163 this.blackholeState_ = BlackholeState.OPEN; | 166 this.blackholeState_ = BlackholeState.OPEN; |
164 if (this.signalStrategy_.getState() == | 167 if (this.signalStrategy_.getState() == |
165 remoting.SignalStrategy.State.CONNECTED) { | 168 remoting.SignalStrategy.State.CONNECTED) { |
166 this.setState_(remoting.SignalStrategy.State.CONNECTED); | 169 this.setState_(remoting.SignalStrategy.State.CONNECTED); |
167 } | 170 } |
168 } else { | 171 } else { |
169 console.error("DNS blackhole check failed: " + response.status + " " + | 172 console.error("DNS blackhole check failed: " + response.status + " " + |
(...skipping 11 matching lines...) Expand all Loading... |
181 * @private | 184 * @private |
182 */ | 185 */ |
183 remoting.DnsBlackholeChecker.prototype.setState_ = function(newState) { | 186 remoting.DnsBlackholeChecker.prototype.setState_ = function(newState) { |
184 if (this.state_ != newState) { | 187 if (this.state_ != newState) { |
185 this.state_ = newState; | 188 this.state_ = newState; |
186 this.onStateChangedCallback_(this.state_); | 189 this.onStateChangedCallback_(this.state_); |
187 } | 190 } |
188 }; | 191 }; |
189 | 192 |
190 }()); | 193 }()); |
OLD | NEW |