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

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

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
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 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** 10 /**
11 * XmppLoginHandler handles authentication handshake for XmppConnection. It 11 * XmppLoginHandler handles authentication handshake for XmppConnection. It
12 * receives incoming data using onDataReceived(), calls |sendMessageCallback| 12 * receives incoming data using onDataReceived(), calls |sendMessageCallback|
13 * to send outgoing messages and calls |onHandshakeDoneCallback| after 13 * to send outgoing messages and calls |onHandshakeDoneCallback| after
14 * authentication is finished successfully or |onErrorCallback| on error. 14 * authentication is finished successfully or |onErrorCallback| on error.
15 * 15 *
16 * See RFC3920 for description of XMPP and authentication handshake. 16 * See RFC3920 for description of XMPP and authentication handshake.
17 * 17 *
18 * @param {string} server Domain name of the server we are connecting to. 18 * @param {string} server Domain name of the server we are connecting to.
19 * @param {string} username Username. 19 * @param {string} username Username.
20 * @param {string} authToken OAuth2 token. 20 * @param {string} authToken OAuth2 token.
21 * @param {boolean} needHandshakeBeforeTls Set to true when <starttls> handshake 21 * @param {boolean} needHandshakeBeforeTls Set to true when <starttls> handshake
22 * is required before starting TLS. Otherwise TLS can be started right away. 22 * is required before starting TLS. Otherwise TLS can be started right away.
23 * @param {function(string):void} sendMessageCallback Callback to call to send 23 * @param {function(string):void} sendMessageCallback Callback to call to send
24 * a message. 24 * a message.
25 * @param {function():void} startTlsCallback Callback to call to start TLS on 25 * @param {function():void} startTlsCallback Callback to call to start TLS on
26 * the underlying socket. 26 * the underlying socket.
27 * @param {function(string, remoting.XmppStreamParser):void} 27 * @param {function(string, remoting.XmppStreamParser):void}
28 * onHandshakeDoneCallback Callback to call after authentication is 28 * onHandshakeDoneCallback Callback to call after authentication is
29 * completed successfully 29 * completed successfully
30 * @param {function(remoting.Error, string):void} onErrorCallback Callback to 30 * @param {function(!remoting.Error, string):void} onErrorCallback Callback to
31 * call on error. Can be called at any point during lifetime of connection. 31 * call on error. Can be called at any point during lifetime of connection.
32 * @constructor 32 * @constructor
33 */ 33 */
34 remoting.XmppLoginHandler = function(server, 34 remoting.XmppLoginHandler = function(server,
35 username, 35 username,
36 authToken, 36 authToken,
37 needHandshakeBeforeTls, 37 needHandshakeBeforeTls,
38 sendMessageCallback, 38 sendMessageCallback,
39 startTlsCallback, 39 startTlsCallback,
40 onHandshakeDoneCallback, 40 onHandshakeDoneCallback,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 this.sendMessageCallback_('<stream:stream to="' + this.server_ + 274 this.sendMessageCallback_('<stream:stream to="' + this.server_ +
275 '" version="1.0" xmlns="jabber:client" ' + 275 '" version="1.0" xmlns="jabber:client" ' +
276 'xmlns:stream="http://etherx.jabber.org/streams">' + 276 'xmlns:stream="http://etherx.jabber.org/streams">' +
277 firstMessage); 277 firstMessage);
278 this.streamParser_ = new remoting.XmppStreamParser(); 278 this.streamParser_ = new remoting.XmppStreamParser();
279 this.streamParser_.setCallbacks(this.onStanza_.bind(this), 279 this.streamParser_.setCallbacks(this.onStanza_.bind(this),
280 this.onParserError_.bind(this)); 280 this.onParserError_.bind(this));
281 } 281 }
282 282
283 /** 283 /**
284 * @param {remoting.Error} error 284 * @param {!remoting.Error} error
285 * @param {string} text 285 * @param {string} text
286 * @private 286 * @private
287 */ 287 */
288 remoting.XmppLoginHandler.prototype.onError_ = function(error, text) { 288 remoting.XmppLoginHandler.prototype.onError_ = function(error, text) {
289 if (this.state_ != remoting.XmppLoginHandler.State.ERROR) { 289 if (this.state_ != remoting.XmppLoginHandler.State.ERROR) {
290 this.onErrorCallback_(error, text); 290 this.onErrorCallback_(error, text);
291 this.state_ = remoting.XmppLoginHandler.State.ERROR; 291 this.state_ = remoting.XmppLoginHandler.State.ERROR;
292 } else { 292 } else {
293 console.error(text); 293 console.error(text);
294 } 294 }
295 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698