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. |
11 chromoting.messageId = 1; | 11 chromoting.messageId = 1; |
12 | 12 |
13 chromoting.scaleToFit = false; | 13 chromoting.scaleToFit = false; |
14 | 14 |
15 // Default to trying to sandboxed connections. | 15 // Default to trying to sandboxed connections. |
16 chromoting.connectMethod = 'sandboxed'; | 16 chromoting.connectMethod = 'sandboxed'; |
17 | 17 |
18 // This executes a poll loop on the server for more Iq packets, and feeds them | 18 // This executes a poll loop on the server for more Iq packets, and feeds them |
19 // to the plugin. | 19 // to the plugin. |
20 function feedIq() { | 20 function feedIq() { |
21 var xhr = new XMLHttpRequest(); | 21 var xhr = new XMLHttpRequest(); |
| 22 addToDebugLog("xmpp proxy: " + chromoting.httpXmppProxy); |
22 xhr.open("GET", chromoting.httpXmppProxy + '/readIq?host_jid=' + | 23 xhr.open("GET", chromoting.httpXmppProxy + '/readIq?host_jid=' + |
23 encodeURIComponent(document.hostjid), true); | 24 encodeURIComponent(document.hostjid), true); |
24 xhr.withCredentials = true; | 25 xhr.withCredentials = true; |
25 xhr.onreadystatechange = function() { | 26 xhr.onreadystatechange = function() { |
26 if (xhr.readyState == 4) { | 27 if (xhr.readyState == 4) { |
27 if (xhr.status == 200) { | 28 if (xhr.status == 200) { |
28 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); | 29 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); |
29 chromoting.plugin.onIq(xhr.responseText); | 30 chromoting.plugin.onIq(xhr.responseText); |
30 } | 31 } |
31 if (xhr.status == 200 || xhr.status == 204) { | 32 if (xhr.status == 200 || xhr.status == 204) { |
32 window.setTimeout(feedIq, 0); | 33 window.setTimeout(feedIq, 0); |
33 } else { | 34 } else { |
34 addToDebugLog("HttpXmpp gateway returned code: " + xhr.status); | 35 addToDebugLog("HttpXmpp gateway returned code: " + xhr.status); |
35 chromoting.plugin.disconnect(); | 36 chromoting.plugin.disconnect(); |
36 setClientStateMessage("Failed"); | 37 setClientStateMessage("Failed"); |
37 } | 38 } |
38 } | 39 } |
39 } | 40 } |
40 xhr.send(null); | 41 xhr.send(null); |
41 } | 42 } |
42 | 43 |
43 function registerConnection() { | 44 function registerConnection() { |
44 var xhr = new XMLHttpRequest(); | 45 var xhr = new XMLHttpRequest(); |
| 46 addToDebugLog("xmpp proxy: " + chromoting.httpXmppProxy); |
45 xhr.open("POST", chromoting.httpXmppProxy + '/newConnection', true); | 47 xhr.open("POST", chromoting.httpXmppProxy + '/newConnection', true); |
46 xhr.withCredentials = true; | 48 xhr.withCredentials = true; |
47 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | 49 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
48 xhr.onreadystatechange = function() { | 50 xhr.onreadystatechange = function() { |
49 if (xhr.readyState == 4) { | 51 if (xhr.readyState == 4) { |
50 if (xhr.status == 200) { | 52 if (xhr.status == 200) { |
51 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); | 53 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); |
52 var clientjid = xhr.responseText; | 54 var clientjid = xhr.responseText; |
53 | 55 |
54 chromoting.plugin.sendIq = sendIq; | 56 chromoting.plugin.sendIq = sendIq; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 setClientStateMessage( | 341 setClientStateMessage( |
340 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + | 342 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + |
341 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + | 343 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + |
342 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + | 344 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + |
343 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + | 345 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + |
344 ", render: " + videoRenderLatency.toFixed(2) + "ms"); | 346 ", render: " + videoRenderLatency.toFixed(2) + "ms"); |
345 | 347 |
346 // Update the stats once per second. | 348 // Update the stats once per second. |
347 window.setTimeout("updateStatusBarStats()", 1000); | 349 window.setTimeout("updateStatusBarStats()", 1000); |
348 } | 350 } |
OLD | NEW |