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

Side by Side Diff: chrome/browser/resources/whispernet_proxy/js/wrapper.js

Issue 870053008: 64-bit token fixes (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
« no previous file with comments | « no previous file | components/copresence/handlers/audio/audio_directive_handler_impl.cc » ('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 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 /** 7 /**
8 * Function to convert an array of bytes to a base64 string 8 * Function to convert an array of bytes to a base64 string
9 * TODO(rkc): Change this to use a Uint8array instead of a string. 9 * TODO(rkc): Change this to use a Uint8array instead of a string.
10 * @param {string} bytes String containing the bytes we want to convert. 10 * @param {string} bytes String containing the bytes we want to convert.
11 * @return {string} String containing the base64 representation. 11 * @return {string} String containing the base64 representation.
12 */ 12 */
13 function bytesToBase64(bytes) { 13 function bytesToBase64(bytes) {
14 var bstr = ''; 14 var bstr = '';
15 for (var i = 0; i < bytes.length; ++i) 15 for (var i = 0; i < bytes.length; ++i)
16 bstr += String.fromCharCode(bytes[i]); 16 bstr += String.fromCharCode(bytes[i]);
17 return btoa(bstr); 17 return btoa(bstr).replace('=', '');
18 } 18 }
19 19
20 /** 20 /**
21 * Function to convert a string to an array of bytes. 21 * Function to convert a string to an array of bytes.
22 * @param {string} str String to convert. 22 * @param {string} str String to convert.
23 * @return {Array} Array containing the string. 23 * @return {Array} Array containing the string.
24 */ 24 */
25 function stringToArray(str) { 25 function stringToArray(str) {
26 var buffer = []; 26 var buffer = [];
27 for (var i = 0; i < str.length; ++i) 27 for (var i = 0; i < str.length; ++i)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 /** 80 /**
81 * Method to handle messages from the whispernet NaCl wrapper. 81 * Method to handle messages from the whispernet NaCl wrapper.
82 * @param {Event} e Event from the whispernet wrapper. 82 * @param {Event} e Event from the whispernet wrapper.
83 * @private 83 * @private
84 */ 84 */
85 WhisperEncoder.prototype.onNaclMessage_ = function(e) { 85 WhisperEncoder.prototype.onNaclMessage_ = function(e) {
86 var msg = e.data; 86 var msg = e.data;
87 if (msg.type == 'encode_token_response') { 87 if (msg.type == 'encode_token_response') {
88 this.audioDataCallback_( 88 this.audioDataCallback_(
89 { token: bytesToBase64(msg.token), audible: msg.audible }, msg.samples); 89 { token: bytesToBase64(msg.token), audible: msg.audible }, msg.samples);
Charlie 2015/01/29 22:51:24 Does it matter that this line is now passing back
xiyuan 2015/01/30 02:16:54 This looks okay to me since we uses it as an opaqu
90 } 90 }
91 }; 91 };
92 92
93 /** 93 /**
94 * Creates a whispernet decoder. 94 * Creates a whispernet decoder.
95 * @constructor 95 * @constructor
96 * @param {Object} params Dictionary of parameters used to initialize the 96 * @param {Object} params Dictionary of parameters used to initialize the
97 * whispernet decoder. 97 * whispernet decoder.
98 * @param {Object} whisperNacl The NaclBridge object to use to communicate with 98 * @param {Object} whisperNacl The NaclBridge object to use to communicate with
99 * the whispernet wrapper. 99 * the whispernet wrapper.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return; 192 return;
193 193
194 var returnCandidates = []; 194 var returnCandidates = [];
195 for (var i = 0; i < candidates.length; ++i) { 195 for (var i = 0; i < candidates.length; ++i) {
196 returnCandidates[i] = { token: bytesToBase64(candidates[i]), 196 returnCandidates[i] = { token: bytesToBase64(candidates[i]),
197 audible: audible }; 197 audible: audible };
198 } 198 }
199 this.tokenCallback_(returnCandidates); 199 this.tokenCallback_(returnCandidates);
200 }; 200 };
201 201
OLDNEW
« no previous file with comments | « no previous file | components/copresence/handlers/audio/audio_directive_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698