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

Side by Side Diff: chrome/browser/resources/cryptotoken/gnubby.js

Issue 2900253006: WebUI: Fix more violations of no-extra-semi lint rule. (Closed)
Patch Set: clang-format Created 3 years, 7 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 /** 5 /**
6 * @fileoverview Provides a client view of a gnubby, aka USB security key. 6 * @fileoverview Provides a client view of a gnubby, aka USB security key.
7 */ 7 */
8 'use strict'; 8 'use strict';
9 9
10 /** 10 /**
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 window.clearTimeout(tid); 300 window.clearTimeout(tid);
301 tid = null; 301 tid = null;
302 } 302 }
303 self.lastReadError_ = /** @private {number|undefined} */ (a); 303 self.lastReadError_ = /** @private {number|undefined} */ (a);
304 var c = callback; 304 var c = callback;
305 if (c) { 305 if (c) {
306 callback = null; 306 callback = null;
307 window.setTimeout(function() { c(a, b); }, 0); 307 window.setTimeout(function() { c(a, b); }, 0);
308 } 308 }
309 if (self.closingWhenIdle) self.idleClose_(); 309 if (self.closingWhenIdle) self.idleClose_();
310 }; 310 }
311 311
312 function read_timeout() { 312 function read_timeout() {
313 if (!callback || !tid) return; // Already done. 313 if (!callback || !tid) return; // Already done.
314 314
315 console.error(UTIL_fmt( 315 console.error(UTIL_fmt(
316 '[' + Gnubby.hexCid(self.cid) + '] timeout!')); 316 '[' + Gnubby.hexCid(self.cid) + '] timeout!'));
317 317
318 if (self.dev) { 318 if (self.dev) {
319 self.dev.destroy(); // Stop pretending this thing works. 319 self.dev.destroy(); // Stop pretending this thing works.
320 } 320 }
321 321
322 tid = null; 322 tid = null;
323 323
324 schedule_cb(-GnubbyDevice.TIMEOUT); 324 schedule_cb(-GnubbyDevice.TIMEOUT);
325 }; 325 }
326 326
327 function cont_frame() { 327 function cont_frame() {
328 if (!callback || !tid) return; // Already done. 328 if (!callback || !tid) return; // Already done.
329 329
330 var f = new Uint8Array(self.readFrame_()); 330 var f = new Uint8Array(self.readFrame_());
331 var rcmd = f[4]; 331 var rcmd = f[4];
332 var totalLen = (f[5] << 8) + f[6]; 332 var totalLen = (f[5] << 8) + f[6];
333 333
334 if (rcmd == GnubbyDevice.CMD_ERROR && totalLen == 1) { 334 if (rcmd == GnubbyDevice.CMD_ERROR && totalLen == 1) {
335 // Error from device; forward. 335 // Error from device; forward.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 655
656 // Eat everything else but expected sentinel reply. 656 // Eat everything else but expected sentinel reply.
657 if (!sentinelEquals(f)) { 657 if (!sentinelEquals(f)) {
658 // Read more. 658 // Read more.
659 self.notifyFrame_(checkSentinel); 659 self.notifyFrame_(checkSentinel);
660 return; 660 return;
661 } 661 }
662 662
663 // Done. 663 // Done.
664 callback(-GnubbyDevice.OK, f); 664 callback(-GnubbyDevice.OK, f);
665 }; 665 }
666 666
667 function timeoutLoop() { 667 function timeoutLoop() {
668 if (done) return; 668 if (done) return;
669 669
670 if (trycount == 0) { 670 if (trycount == 0) {
671 // Failed. 671 // Failed.
672 callback(-GnubbyDevice.TIMEOUT); 672 callback(-GnubbyDevice.TIMEOUT);
673 return; 673 return;
674 } 674 }
675 675
676 --trycount; // Try another one. 676 --trycount; // Try another one.
677 sendSentinel(); 677 sendSentinel();
678 self.notifyFrame_(checkSentinel); 678 self.notifyFrame_(checkSentinel);
679 tid = window.setTimeout(timeoutLoop, 500); 679 tid = window.setTimeout(timeoutLoop, 500);
680 }; 680 }
681 681
682 var sendSentinel; 682 var sendSentinel;
683 var sentinelEquals; 683 var sentinelEquals;
684 var nonce; 684 var nonce;
685 var completionAction; 685 var completionAction;
686 686
687 function setInit() { 687 function setInit() {
688 sendSentinel = sendInitSentinel; 688 sendSentinel = sendInitSentinel;
689 nonce = UTIL_getRandom(8); 689 nonce = UTIL_getRandom(8);
690 sentinelEquals = initSentinelEquals; 690 sentinelEquals = initSentinelEquals;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 852 }
853 } 853 }
854 // Warn on errors other than waiting for touch, wrong data, and 854 // Warn on errors other than waiting for touch, wrong data, and
855 // unrecognized command. 855 // unrecognized command.
856 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) { 856 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) {
857 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16))); 857 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16)));
858 } 858 }
859 cb(rc); 859 cb(rc);
860 }); 860 });
861 }; 861 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698