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

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

Issue 1065733004: Added partial unit tests for host_controller.js. More to come. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hdf-unittest
Patch Set: added licenses to satisfy presubmit Created 5 years, 8 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/crd/js/error.js ('k') | remoting/webapp/crd/js/host_controller_unittest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * @param {function():void} onDone Callback to be called when done. 118 * @param {function():void} onDone Callback to be called when done.
119 * @param {function(!remoting.Error):void} onError Callback to be called on 119 * @param {function(!remoting.Error):void} onError Callback to be called on
120 * error. 120 * error.
121 * @return {void} Nothing. 121 * @return {void} Nothing.
122 */ 122 */
123 remoting.HostController.prototype.start = function(hostPin, consent, onDone, 123 remoting.HostController.prototype.start = function(hostPin, consent, onDone,
124 onError) { 124 onError) {
125 /** @type {remoting.HostController} */ 125 /** @type {remoting.HostController} */
126 var that = this; 126 var that = this;
127 127
128 /** @return {string} */ 128 var newHostId = base.generateUuid();
129 function generateUuid() {
130 var random = new Uint16Array(8);
131 window.crypto.getRandomValues(random);
132 /** @type {Array<string>} */
133 var e = new Array();
134 for (var i = 0; i < 8; i++) {
135 e[i] = (/** @type {number} */ (random[i]) + 0x10000).
136 toString(16).substring(1);
137 }
138 return e[0] + e[1] + '-' + e[2] + '-' + e[3] + '-' +
139 e[4] + '-' + e[5] + e[6] + e[7];
140 };
141
142 var newHostId = generateUuid();
143 129
144 /** @param {!remoting.Error} error */ 130 /** @param {!remoting.Error} error */
145 function onStartError(error) { 131 function onStartError(error) {
146 // Unregister the host if we failed to start it. 132 // Unregister the host if we failed to start it.
147 remoting.hostList.unregisterHostById(newHostId); 133 remoting.hostList.unregisterHostById(newHostId);
148 onError(error); 134 onError(error);
149 } 135 }
150 136
151 /** 137 /**
152 * @param {string} hostName 138 * @param {string} hostName
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 function connectSignalingWithTokenAndEmail(token, email) { 553 function connectSignalingWithTokenAndEmail(token, email) {
568 signalStrategy.connect(remoting.settings.XMPP_SERVER, email, token); 554 signalStrategy.connect(remoting.settings.XMPP_SERVER, email, token);
569 } 555 }
570 556
571 remoting.identity.getToken().then( 557 remoting.identity.getToken().then(
572 connectSignalingWithToken, remoting.Error.handler(onError)); 558 connectSignalingWithToken, remoting.Error.handler(onError));
573 }; 559 };
574 560
575 /** @type {remoting.HostController} */ 561 /** @type {remoting.HostController} */
576 remoting.hostController = null; 562 remoting.hostController = null;
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/error.js ('k') | remoting/webapp/crd/js/host_controller_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698