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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 xhr.open('POST', remoting.httpXmppProxy + '/newConnection', true); | 47 xhr.open('POST', remoting.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 remoting.plugin.sendIq = sendIq; | 56 remoting.plugin.sendIq = sendIq; |
57 remoting.plugin.connectSandboxed(clientjid, remoting.hostjid, | 57 remoting.plugin.connect(remoting.hostjid, "ACCESS_CODE", |
58 remoting.accessCode); | 58 clientjid, remoting.accessCode); |
59 // TODO(ajwong): This should just be feedIq(); | 59 // TODO(ajwong): This should just be feedIq(); |
60 window.setTimeout(feedIq, 1000); | 60 window.setTimeout(feedIq, 1000); |
61 } else { | 61 } else { |
62 addToDebugLog('FailedToConnect: --' + xhr.responseText + | 62 addToDebugLog('FailedToConnect: --' + xhr.responseText + |
63 '-- (status=' + xhr.status + ')'); | 63 '-- (status=' + xhr.status + ')'); |
64 setClientStateMessage('Failed'); | 64 setClientStateMessage('Failed'); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + | 68 xhr.send('host_jid=' + encodeURIComponent(remoting.hostjid) + |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 plugin.connectionInfoUpdate = connectionInfoUpdateCallback; | 113 plugin.connectionInfoUpdate = connectionInfoUpdateCallback; |
114 plugin.debugInfo = debugInfoCallback; | 114 plugin.debugInfo = debugInfoCallback; |
115 plugin.desktopSizeUpdate = desktopSizeChanged; | 115 plugin.desktopSizeUpdate = desktopSizeChanged; |
116 plugin.loginChallenge = loginChallengeCallback; | 116 plugin.loginChallenge = loginChallengeCallback; |
117 | 117 |
118 addToDebugLog('Connect as user ' + remoting.username); | 118 addToDebugLog('Connect as user ' + remoting.username); |
119 | 119 |
120 // TODO(garykac): Clean exit if |connect| isn't a function. | 120 // TODO(garykac): Clean exit if |connect| isn't a function. |
121 if (typeof plugin.connect === 'function') { | 121 if (typeof plugin.connect === 'function') { |
122 if (remoting.connectMethod == 'sandboxed') { | 122 if (remoting.connectMethod == 'sandboxed') { |
| 123 plugin.setSandboxed(true); |
123 registerConnection(); | 124 registerConnection(); |
124 } else { | 125 } else { |
125 plugin.connect(remoting.username, remoting.hostjid, | 126 plugin.setSandboxed(false); |
| 127 plugin.connect(remoting.hostjid, "ACCESS_CODE", remoting.username, |
126 remoting.xmppAuthToken, remoting.accessCode); | 128 remoting.xmppAuthToken, remoting.accessCode); |
127 } | 129 } |
128 } else { | 130 } else { |
129 addToDebugLog('ERROR: remoting plugin not loaded'); | 131 addToDebugLog('ERROR: remoting plugin not loaded'); |
130 setClientStateMessage('Plugin not loaded'); | 132 setClientStateMessage('Plugin not loaded'); |
131 } | 133 } |
132 | 134 |
133 } | 135 } |
134 | 136 |
135 function toggleDebugLog() { | 137 function toggleDebugLog() { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 setClientStateMessage( | 324 setClientStateMessage( |
323 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + | 325 'Video stats: bandwidth: ' + videoBandwidth.toFixed(2) + 'Kbps' + |
324 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + | 326 ', Latency: capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + |
325 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + | 327 ', encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + |
326 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + | 328 ', decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + |
327 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); | 329 ', render: ' + videoRenderLatency.toFixed(2) + 'ms'); |
328 | 330 |
329 // Update the stats once per second. | 331 // Update the stats once per second. |
330 window.setTimeout('updateStatusBarStats()', 1000); | 332 window.setTimeout('updateStatusBarStats()', 1000); |
331 } | 333 } |
OLD | NEW |