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

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

Issue 916763005: Allowing WhispernetClient to be used during initialization (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 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 // Globals holding our encoder and decoder. We will never have more than one 7 // Globals holding our encoder and decoder. We will never have more than one
8 // Global variable that will be used to access this Nacl bridge. 8 // Global variable that will be used to access this Nacl bridge.
9 var whispernetNacl = null; 9 var whispernetNacl = null;
10 10
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 console.log('Configuring encoder!'); 26 console.log('Configuring encoder!');
27 whisperEncoder = new WhisperEncoder(audioParams.paramData, whispernetNacl); 27 whisperEncoder = new WhisperEncoder(audioParams.paramData, whispernetNacl);
28 whisperEncoder.setAudioDataCallback(chrome.copresencePrivate.sendSamples); 28 whisperEncoder.setAudioDataCallback(chrome.copresencePrivate.sendSamples);
29 29
30 console.log('Configuring decoder!'); 30 console.log('Configuring decoder!');
31 whisperDecoder = new WhisperDecoder(audioParams.paramData, whispernetNacl); 31 whisperDecoder = new WhisperDecoder(audioParams.paramData, whispernetNacl);
32 whisperDecoder.setReceiveCallback(chrome.copresencePrivate.sendFound); 32 whisperDecoder.setReceiveCallback(chrome.copresencePrivate.sendFound);
33 whisperDecoder.onDetectBroadcast(chrome.copresencePrivate.sendDetect); 33 whisperDecoder.onDetectBroadcast(chrome.copresencePrivate.sendDetect);
34
35 chrome.copresencePrivate.sendInitialized(true);
36 } 34 }
37 35
38 /** 36 /**
39 * Sends a request to whispernet to encode a token. 37 * Sends a request to whispernet to encode a token.
40 * @param {Object} params Encode token parameters object. 38 * @param {Object} params Encode token parameters object.
41 */ 39 */
42 function encodeTokenRequest(params) { 40 function encodeTokenRequest(params) {
43 if (whisperEncoder) { 41 if (whisperEncoder) {
44 whisperEncoder.encode(params); 42 whisperEncoder.encode(params);
45 } else { 43 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 */ 93 */
96 function initWhispernet() { 94 function initWhispernet() {
97 console.log('init: Starting Nacl bridge.'); 95 console.log('init: Starting Nacl bridge.');
98 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component 96 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component
99 // resources without having to rename them to .js. 97 // resources without having to rename them to .js.
100 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png', 98 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png',
101 onWhispernetLoaded); 99 onWhispernetLoaded);
102 } 100 }
103 101
104 window.addEventListener('DOMContentLoaded', initWhispernet); 102 window.addEventListener('DOMContentLoaded', initWhispernet);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698