OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Maximum numer of lines to record in the debug log. | 5 // Maximum numer of lines to record in the debug log. |
6 // Only the most recent <n> lines are displayed. | 6 // Only the most recent <n> lines are displayed. |
7 var MAX_DEBUG_LOG_SIZE = 1000; | 7 var MAX_DEBUG_LOG_SIZE = 1000; |
8 var remoting = chrome.extension.getBackgroundPage().remoting; | 8 var remoting = chrome.extension.getBackgroundPage().remoting; |
9 | 9 |
10 // Message id so that we can identify (and ignore) message fade operations for | 10 // Message id so that we can identify (and ignore) message fade operations for |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 xhr.open('POST', remoting.httpXmppProxy + '/newConnection', true); | 48 xhr.open('POST', remoting.httpXmppProxy + '/newConnection', true); |
49 xhr.withCredentials = true; | 49 xhr.withCredentials = true; |
50 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | 50 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
51 xhr.onreadystatechange = function() { | 51 xhr.onreadystatechange = function() { |
52 if (xhr.readyState == 4) { | 52 if (xhr.readyState == 4) { |
53 if (xhr.status == 200) { | 53 if (xhr.status == 200) { |
54 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); | 54 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); |
55 var clientjid = xhr.responseText; | 55 var clientjid = xhr.responseText; |
56 | 56 |
57 remoting.plugin.sendIq = sendIq; | 57 remoting.plugin.sendIq = sendIq; |
58 remoting.plugin.connect(remoting.hostjid, clientjid, | 58 remoting.plugin.connectSandboxed(clientjid, remoting.hostjid, |
59 remoting.accessCode); | 59 remoting.accessCode); |
60 // TODO(ajwong): This should just be feedIq(); | 60 // TODO(ajwong): This should just be feedIq(); |
61 window.setTimeout(feedIq, 1000); | 61 window.setTimeout(feedIq, 1000); |
62 } else { | 62 } else { |
63 addToDebugLog('FailedToConnect: --' + xhr.responseText + | 63 addToDebugLog('FailedToConnect: --' + xhr.responseText + |
64 '-- (status=' + xhr.status + ')'); | 64 '-- (status=' + xhr.status + ')'); |
65 setClientStateMessage('Failed'); | 65 setClientStateMessage('Failed'); |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + | 69 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 plugin.desktopSizeUpdate = desktopSizeChanged; | 116 plugin.desktopSizeUpdate = desktopSizeChanged; |
117 plugin.loginChallenge = loginChallengeCallback; | 117 plugin.loginChallenge = loginChallengeCallback; |
118 | 118 |
119 addToDebugLog('Connect as user ' + remoting.username); | 119 addToDebugLog('Connect as user ' + remoting.username); |
120 | 120 |
121 // TODO(garykac): Clean exit if |connect| isn't a function. | 121 // TODO(garykac): Clean exit if |connect| isn't a function. |
122 if (typeof plugin.connect === 'function') { | 122 if (typeof plugin.connect === 'function') { |
123 if (remoting.connectMethod == 'sandboxed') { | 123 if (remoting.connectMethod == 'sandboxed') { |
124 registerConnection(); | 124 registerConnection(); |
125 } else { | 125 } else { |
126 plugin.connectUnsandboxed(remoting.hostjid, remoting.username, | 126 plugin.connect(remoting.username, remoting.hostjid, |
127 remoting.xmppAuthToken, remoting.accessCode); | 127 remoting.xmppAuthToken, remoting.accessCode); |
128 } | 128 } |
129 } else { | 129 } else { |
130 addToDebugLog('ERROR: remoting plugin not loaded'); | 130 addToDebugLog('ERROR: remoting plugin not loaded'); |
131 setClientStateMessage('Plugin not loaded'); | 131 setClientStateMessage('Plugin not loaded'); |
132 } | 132 } |
133 | 133 |
134 } | 134 } |
135 | 135 |
136 function toggleDebugLog() { | 136 function toggleDebugLog() { |
137 debugLog = document.getElementById('debug_log'); | 137 debugLog = document.getElementById('debug_log'); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 setClientStateMessage( | 310 setClientStateMessage( |
311 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + | 311 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + |
312 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + | 312 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + |
313 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + | 313 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + |
314 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + | 314 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + |
315 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); | 315 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); |
316 | 316 |
317 // Update the stats once per second. | 317 // Update the stats once per second. |
318 window.setTimeout('updateStatusBarStats()', 1000); | 318 window.setTimeout('updateStatusBarStats()', 1000); |
319 } | 319 } |
OLD | NEW |