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 | 8 |
9 // Message id so that we can identify (and ignore) message fade operations for | 9 // Message id so that we can identify (and ignore) message fade operations for |
10 // old messages. This starts at 1 and is incremented for each new message. | 10 // old messages. This starts at 1 and is incremented for each new message. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 xhr.open("POST", chromoting.httpXmppProxy + '/newConnection', true); | 47 xhr.open("POST", chromoting.httpXmppProxy + '/newConnection', true); |
48 xhr.withCredentials = true; | 48 xhr.withCredentials = true; |
49 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | 49 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
50 xhr.onreadystatechange = function() { | 50 xhr.onreadystatechange = function() { |
51 if (xhr.readyState == 4) { | 51 if (xhr.readyState == 4) { |
52 if (xhr.status == 200) { | 52 if (xhr.status == 200) { |
53 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); | 53 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); |
54 var clientjid = xhr.responseText; | 54 var clientjid = xhr.responseText; |
55 | 55 |
56 chromoting.plugin.sendIq = sendIq; | 56 chromoting.plugin.sendIq = sendIq; |
57 // TODO:(jamiewalch): Pass in the correct nonce. | 57 chromoting.plugin.connect(chromoting.hostjid, clientjid); |
58 chromoting.plugin.connectSandboxed(clientjid, chromoting.hostjid); | |
59 // TODO(ajwong): This should just be feedIq(); | 58 // TODO(ajwong): This should just be feedIq(); |
60 window.setTimeout(feedIq, 1000); | 59 window.setTimeout(feedIq, 1000); |
61 } else { | 60 } else { |
62 addToDebugLog('FailedToConnect: --' + xhr.responseText + | 61 addToDebugLog('FailedToConnect: --' + xhr.responseText + |
63 '-- (status=' + xhr.status + ')'); | 62 '-- (status=' + xhr.status + ')'); |
64 setClientStateMessage("Failed") | 63 setClientStateMessage("Failed") |
65 } | 64 } |
66 } | 65 } |
67 } | 66 } |
68 xhr.send('host_jid=' + encodeURIComponent(chromoting.hostjid) + | 67 xhr.send('host_jid=' + encodeURIComponent(chromoting.hostjid) + |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 plugin.loginChallenge = loginChallengeCallback; | 124 plugin.loginChallenge = loginChallengeCallback; |
126 | 125 |
127 addToDebugLog('Connect to ' + chromoting.hostname + ' as user ' + | 126 addToDebugLog('Connect to ' + chromoting.hostname + ' as user ' + |
128 chromoting.username); | 127 chromoting.username); |
129 | 128 |
130 // TODO(garykac): Clean exit if |connect| isn't a function. | 129 // TODO(garykac): Clean exit if |connect| isn't a function. |
131 if (typeof plugin.connect === 'function') { | 130 if (typeof plugin.connect === 'function') { |
132 if (chromoting.connectMethod == "sandboxed") { | 131 if (chromoting.connectMethod == "sandboxed") { |
133 registerConnection(); | 132 registerConnection(); |
134 } else { | 133 } else { |
135 // TODO:(jamiewalch): Pass in the correct nonce. | 134 plugin.connectUnsandboxed(chromoting.hostjid, chromoting.username, |
136 plugin.connect(chromoting.username, chromoting.hostjid, | 135 chromoting.talkToken); |
137 chromoting.talkToken, ''); | |
138 } | 136 } |
139 } else { | 137 } else { |
140 addToDebugLog('ERROR: chromoting plugin not loaded'); | 138 addToDebugLog('ERROR: chromoting plugin not loaded'); |
141 setClientStateMessage('Plugin not loaded'); | 139 setClientStateMessage('Plugin not loaded'); |
142 } | 140 } |
143 | 141 |
144 document.getElementById('title').innerText = chromoting.hostname; | 142 document.getElementById('title').innerText = chromoting.hostname; |
145 } | 143 } |
146 | 144 |
147 function toggleDebugLog() { | 145 function toggleDebugLog() { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 setClientStateMessage( | 339 setClientStateMessage( |
342 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + | 340 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + |
343 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + | 341 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + |
344 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + | 342 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + |
345 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + | 343 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + |
346 ", render: " + videoRenderLatency.toFixed(2) + "ms"); | 344 ", render: " + videoRenderLatency.toFixed(2) + "ms"); |
347 | 345 |
348 // Update the stats once per second. | 346 // Update the stats once per second. |
349 window.setTimeout("updateStatusBarStats()", 1000); | 347 window.setTimeout("updateStatusBarStats()", 1000); |
350 } | 348 } |
OLD | NEW |