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 |
11 // old messages. This starts at 1 and is incremented for each new message. | 11 // old messages. This starts at 1 and is incremented for each new message. |
12 remoting.messageId = 1; | 12 remoting.messageId = 1; |
13 | 13 |
14 remoting.scaleToFit = false; | 14 remoting.scaleToFit = false; |
15 | 15 |
16 // Default to trying to sandboxed connections. | 16 // Default to trying to sandboxed connections. |
17 remoting.connectMethod = 'sandboxed'; | 17 remoting.connectMethod = 'sandboxed'; |
18 remoting.httpXmppProxy = 'https://chromoting-httpxmpp-dev.corp.google.com'; | 18 remoting.httpXmppProxy = |
| 19 'https://chromoting-httpxmpp-oauth2-dev.corp.google.com'; |
19 | 20 |
20 // This executes a poll loop on the server for more Iq packets, and feeds them | 21 // This executes a poll loop on the server for more Iq packets, and feeds them |
21 // to the plugin. | 22 // to the plugin. |
22 function feedIq() { | 23 function feedIq() { |
23 var xhr = new XMLHttpRequest(); | 24 var xhr = new XMLHttpRequest(); |
24 xhr.open('GET', remoting.httpXmppProxy + '/readIq?host_jid=' + | 25 xhr.open('GET', remoting.httpXmppProxy + '/readIq?host_jid=' + |
25 encodeURIComponent(remoting.hostjid), true); | 26 encodeURIComponent(remoting.hostjid), true); |
26 xhr.withCredentials = true; | 27 xhr.withCredentials = true; |
27 xhr.onreadystatechange = function() { | 28 xhr.onreadystatechange = function() { |
28 if (xhr.readyState == 4) { | 29 if (xhr.readyState == 4) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 window.setTimeout(feedIq, 1000); | 61 window.setTimeout(feedIq, 1000); |
61 } else { | 62 } else { |
62 addToDebugLog('FailedToConnect: --' + xhr.responseText + | 63 addToDebugLog('FailedToConnect: --' + xhr.responseText + |
63 '-- (status=' + xhr.status + ')'); | 64 '-- (status=' + xhr.status + ')'); |
64 setClientStateMessage('Failed'); | 65 setClientStateMessage('Failed'); |
65 } | 66 } |
66 } | 67 } |
67 } | 68 } |
68 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + | 69 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + |
69 '&username=' + encodeURIComponent(remoting.username) + | 70 '&username=' + encodeURIComponent(remoting.username) + |
70 '&password=' + encodeURIComponent(remoting.xmppAuthToken)); | 71 '&password=' + encodeURIComponent(remoting.oauth2.getAccessToken())); |
71 setClientStateMessage('Connecting'); | 72 setClientStateMessage('Connecting'); |
72 } | 73 } |
73 | 74 |
74 function sendIq(msg) { | 75 function sendIq(msg) { |
75 addToDebugLog('Sending Iq: ' + msg); | 76 addToDebugLog('Sending Iq: ' + msg); |
76 | 77 |
77 // Extract the top level fields of the Iq packet. | 78 // Extract the top level fields of the Iq packet. |
78 // TODO(ajwong): Can the plugin just return these fields broken out. | 79 // TODO(ajwong): Can the plugin just return these fields broken out. |
79 parser = new DOMParser(); | 80 parser = new DOMParser(); |
80 iqNode = parser.parseFromString(msg, 'text/xml').firstChild; | 81 iqNode = parser.parseFromString(msg, 'text/xml').firstChild; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 setClientStateMessage( | 311 setClientStateMessage( |
311 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + | 312 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + |
312 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + | 313 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + |
313 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + | 314 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + |
314 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + | 315 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + |
315 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); | 316 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); |
316 | 317 |
317 // Update the stats once per second. | 318 // Update the stats once per second. |
318 window.setTimeout('updateStatusBarStats()', 1000); | 319 window.setTimeout('updateStatusBarStats()', 1000); |
319 } | 320 } |
OLD | NEW |