OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 chrome.runtime.onMessageExternal.addListener( | 5 chrome.runtime.onMessageExternal.addListener( |
6 function(message, sender, sendResponse) { | 6 function(message, sender, sendResponse) { |
7 function doSendResponse(value, error) { | 7 function doSendResponse(value, error) { |
8 var errorMessage = error || chrome.extension.lastError; | 8 var errorMessage = error || chrome.extension.lastError; |
9 sendResponse({'value': value, 'error': errorMessage}); | 9 sendResponse({'value': value, 'error': errorMessage}); |
10 } | 10 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return false; | 68 return false; |
69 } else if (method == 'logging.stop') { | 69 } else if (method == 'logging.stop') { |
70 chrome.webrtcLoggingPrivate.stop( | 70 chrome.webrtcLoggingPrivate.stop( |
71 sender.tab.id, origin, doSendResponse); | 71 sender.tab.id, origin, doSendResponse); |
72 return true; | 72 return true; |
73 } else if (method == 'logging.upload') { | 73 } else if (method == 'logging.upload') { |
74 chrome.webrtcLoggingPrivate.upload( | 74 chrome.webrtcLoggingPrivate.upload( |
75 sender.tab.id, origin, doSendResponse); | 75 sender.tab.id, origin, doSendResponse); |
76 return true; | 76 return true; |
77 } else if (method == 'logging.stopAndUpload') { | 77 } else if (method == 'logging.stopAndUpload') { |
78 chrome.webrtcLoggingPrivate.stop(sender.tab.id, origin, function() { | 78 stopAllRtpDump(sender.tab.id, origin, function() { |
79 chrome.webrtcLoggingPrivate.upload( | 79 chrome.webrtcLoggingPrivate.stop(sender.tab.id, origin, function() { |
80 sender.tab.id, origin, doSendResponse); | 80 chrome.webrtcLoggingPrivate.upload( |
| 81 sender.tab.id, origin, doSendResponse); |
| 82 }); |
81 }); | 83 }); |
82 return true; | 84 return true; |
83 } else if (method == 'logging.discard') { | 85 } else if (method == 'logging.discard') { |
84 chrome.webrtcLoggingPrivate.discard( | 86 chrome.webrtcLoggingPrivate.discard( |
85 sender.tab.id, origin, doSendResponse); | 87 sender.tab.id, origin, doSendResponse); |
86 return true; | 88 return true; |
87 } else if (method == 'getSinks') { | 89 } else if (method == 'getSinks') { |
88 chrome.webrtcAudioPrivate.getSinks(doSendResponse); | 90 chrome.webrtcAudioPrivate.getSinks(doSendResponse); |
89 return true; | 91 return true; |
90 } else if (method == 'getActiveSink') { | 92 } else if (method == 'getActiveSink') { |
(...skipping 17 matching lines...) Expand all Loading... |
108 // check if it's loaded; if it's not, the extension system will | 110 // check if it's loaded; if it's not, the extension system will |
109 // call the callback with no arguments and set | 111 // call the callback with no arguments and set |
110 // chrome.runtime.lastError. | 112 // chrome.runtime.lastError. |
111 doSendResponse(); | 113 doSendResponse(); |
112 return false; | 114 return false; |
113 } else if (method == 'getNaclArchitecture') { | 115 } else if (method == 'getNaclArchitecture') { |
114 chrome.runtime.getPlatformInfo(function(obj) { | 116 chrome.runtime.getPlatformInfo(function(obj) { |
115 doSendResponse(obj.nacl_arch); | 117 doSendResponse(obj.nacl_arch); |
116 }); | 118 }); |
117 return true; | 119 return true; |
| 120 } else if (method == 'logging.startRtpDump') { |
| 121 var incoming = message['incoming'] || false; |
| 122 var outgoing = message['outgoing'] || false; |
| 123 chrome.webrtcLoggingPrivate.startRtpDump( |
| 124 sender.tab.id, origin, incoming, outgoing, doSendResponse); |
| 125 return true; |
| 126 } else if (method == 'logging.stopRtpDump') { |
| 127 var incoming = message['incoming'] || false; |
| 128 var outgoing = message['outgoing'] || false; |
| 129 chrome.webrtcLoggingPrivate.stopRtpDump( |
| 130 sender.tab.id, origin, incoming, outgoing, doSendResponse); |
| 131 return true; |
118 } | 132 } |
119 throw new Error('Unknown method: ' + method); | 133 throw new Error('Unknown method: ' + method); |
120 } catch (e) { | 134 } catch (e) { |
121 doSendResponse(null, e.name + ': ' + e.message); | 135 doSendResponse(null, e.name + ': ' + e.message); |
122 } | 136 } |
123 } | 137 } |
124 ); | 138 ); |
125 | 139 |
126 // If Hangouts connects with a port named 'onSinksChangedListener', we | 140 // If Hangouts connects with a port named 'onSinksChangedListener', we |
127 // will register a listener and send it a message {'eventName': | 141 // will register a listener and send it a message {'eventName': |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 'pluginCpuUsage': pluginProcessCpu | 215 'pluginCpuUsage': pluginProcessCpu |
202 }); | 216 }); |
203 } | 217 } |
204 | 218 |
205 chrome.processes.onUpdated.addListener(processListener); | 219 chrome.processes.onUpdated.addListener(processListener); |
206 port.onDisconnect.addListener(function() { | 220 port.onDisconnect.addListener(function() { |
207 chrome.processes.onUpdated.removeListener(processListener); | 221 chrome.processes.onUpdated.removeListener(processListener); |
208 }); | 222 }); |
209 } | 223 } |
210 | 224 |
| 225 function stopAllRtpDump(tabId, origin, callback) { |
| 226 // Stops incoming and outgoing separately, otherwise stopRtpDump will fail if |
| 227 // either type of dump has not been started. |
| 228 chrome.webrtcLoggingPrivate.stopRtpDump( |
| 229 tabId, origin, true, false, |
| 230 function() { |
| 231 chrome.webrtcLoggingPrivate.stopRtpDump( |
| 232 tabId, origin, false, true, callback); |
| 233 }); |
| 234 } |
| 235 |
211 chrome.runtime.onConnectExternal.addListener(function(port) { | 236 chrome.runtime.onConnectExternal.addListener(function(port) { |
212 if (port.name == 'onSinksChangedListener') { | 237 if (port.name == 'onSinksChangedListener') { |
213 onSinksChangedPort(port); | 238 onSinksChangedPort(port); |
214 } else if (port.name == 'chooseDesktopMedia') { | 239 } else if (port.name == 'chooseDesktopMedia') { |
215 onChooseDesktopMediaPort(port); | 240 onChooseDesktopMediaPort(port); |
216 } else if (port.name == 'processCpu') { | 241 } else if (port.name == 'processCpu') { |
217 onProcessCpu(port); | 242 onProcessCpu(port); |
218 } else { | 243 } else { |
219 // Unknown port type. | 244 // Unknown port type. |
220 port.disconnect(); | 245 port.disconnect(); |
221 } | 246 } |
222 }); | 247 }); |
OLD | NEW |