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

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

Issue 937593002: Changed identity API to use promises instead of callbacks. (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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 /** @constructor */ 10 /** @constructor */
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 /** 302 /**
303 * @param {string} hostName 303 * @param {string} hostName
304 * @param {string} privateKey 304 * @param {string} privateKey
305 * @param {string} publicKey 305 * @param {string} publicKey
306 * @param {string} hostClientId 306 * @param {string} hostClientId
307 */ 307 */
308 function onHostClientId( 308 function onHostClientId(
309 hostName, privateKey, publicKey, hostClientId) { 309 hostName, privateKey, publicKey, hostClientId) {
310 remoting.identity.callWithToken( 310 remoting.identity.getToken().then(
311 doRegisterHost.bind( 311 doRegisterHost.bind(
312 null, hostName, privateKey, publicKey, hostClientId), onError); 312 null, hostName, privateKey, publicKey, hostClientId),
313 remoting.Error.handler(onError));
313 } 314 }
314 315
315 /** 316 /**
316 * @param {string} hostName 317 * @param {string} hostName
317 * @param {string} privateKey 318 * @param {string} privateKey
318 * @param {string} publicKey 319 * @param {string} publicKey
319 * @param {boolean} hasFeature 320 * @param {boolean} hasFeature
320 */ 321 */
321 function onHasFeatureOAuthClient( 322 function onHasFeatureOAuthClient(
322 hostName, privateKey, publicKey, hasFeature) { 323 hostName, privateKey, publicKey, hasFeature) {
323 if (hasFeature) { 324 if (hasFeature) {
324 that.hostDaemonFacade_.getHostClientId( 325 that.hostDaemonFacade_.getHostClientId(
325 onHostClientId.bind(null, hostName, privateKey, publicKey), onError); 326 onHostClientId.bind(null, hostName, privateKey, publicKey), onError);
326 } else { 327 } else {
327 remoting.identity.callWithToken( 328 remoting.identity.getToken().then(
328 doRegisterHost.bind( 329 doRegisterHost.bind(
329 null, hostName, privateKey, publicKey, null), onError); 330 null, hostName, privateKey, publicKey, null),
331 remoting.Error.handler(onError));
330 } 332 }
331 } 333 }
332 334
333 /** 335 /**
334 * @param {string} hostName 336 * @param {string} hostName
335 * @param {string} privateKey 337 * @param {string} privateKey
336 * @param {string} publicKey 338 * @param {string} publicKey
337 */ 339 */
338 function onKeyGenerated(hostName, privateKey, publicKey) { 340 function onKeyGenerated(hostName, privateKey, publicKey) {
339 that.hasFeature( 341 that.hasFeature(
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 onError(error); 554 onError(error);
553 break; 555 break;
554 } 556 }
555 }; 557 };
556 558
557 signalStrategy = remoting.SignalStrategy.create(); 559 signalStrategy = remoting.SignalStrategy.create();
558 signalStrategy.setStateChangedCallback(onState); 560 signalStrategy.setStateChangedCallback(onState);
559 561
560 /** @param {string} token */ 562 /** @param {string} token */
561 function connectSignalingWithToken(token) { 563 function connectSignalingWithToken(token) {
562 remoting.identity.getEmail( 564 remoting.identity.getEmail().then(
563 connectSignalingWithTokenAndEmail.bind(null, token), onError); 565 connectSignalingWithTokenAndEmail.bind(null, token),
566 remoting.Error.handler(onError));
564 } 567 }
565 568
566 /** 569 /**
567 * @param {string} token 570 * @param {string} token
568 * @param {string} email 571 * @param {string} email
569 */ 572 */
570 function connectSignalingWithTokenAndEmail(token, email) { 573 function connectSignalingWithTokenAndEmail(token, email) {
571 signalStrategy.connect( 574 signalStrategy.connect(
572 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); 575 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token);
573 } 576 }
574 577
575 remoting.identity.callWithToken(connectSignalingWithToken, onError); 578 remoting.identity.getToken().then(
579 connectSignalingWithToken, remoting.Error.handler(onError));
576 }; 580 };
577 581
578 /** @type {remoting.HostController} */ 582 /** @type {remoting.HostController} */
579 remoting.hostController = null; 583 remoting.hostController = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698