Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4321)

Unified Diff: chrome/browser/resources/hangout_services/thunk.js

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: hackhackhack Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/hangout_services/thunk.js
diff --git a/chrome/browser/resources/hangout_services/thunk.js b/chrome/browser/resources/hangout_services/thunk.js
index 68c28bf7dc51a5a1b8a4983c1516ba7e0bb889ca..2809355341dcf177c007d156d2aeaf4e19ba561f 100644
--- a/chrome/browser/resources/hangout_services/thunk.js
+++ b/chrome/browser/resources/hangout_services/thunk.js
@@ -2,214 +2,208 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-chrome.runtime.onMessageExternal.addListener(
- function(message, sender, sendResponse) {
- function doSendResponse(value, errorString) {
- var error = null;
- if (errorString) {
- error = {};
- error['name'] = 'ComponentExtensionError';
- error['message'] = errorString;
- }
+chrome.runtime.onMessageExternal.addListener(function(
+ message, sender, sendResponse) {
+ function doSendResponse(value, errorString) {
+ var error = null;
+ if (errorString) {
+ error = {};
+ error['name'] = 'ComponentExtensionError';
+ error['message'] = errorString;
+ }
- var errorMessage = error || chrome.extension.lastError;
- sendResponse({'value': value, 'error': errorMessage});
- }
+ var errorMessage = error || chrome.extension.lastError;
+ sendResponse({'value': value, 'error': errorMessage});
+ }
- function getHost(url) {
- if (!url)
- return '';
- // Use the DOM to parse the URL. Since we don't add the anchor to
- // the page, this is the only reference to it and it will be
- // deleted once it's gone out of scope.
- var a = document.createElement('a');
- a.href = url;
- var origin = a.protocol + '//' + a.hostname;
- if (a.port != '')
- origin = origin + ':' + a.port;
- origin = origin + '/';
- return origin;
- }
+ function getHost(url) {
+ if (!url)
+ return '';
+ // Use the DOM to parse the URL. Since we don't add the anchor to
+ // the page, this is the only reference to it and it will be
+ // deleted once it's gone out of scope.
+ var a = document.createElement('a');
+ a.href = url;
+ var origin = a.protocol + '//' + a.hostname;
+ if (a.port != '')
+ origin = origin + ':' + a.port;
+ origin = origin + '/';
+ return origin;
+ }
- try {
- var requestInfo = {};
+ try {
+ var requestInfo = {};
- // Set the tab ID. If it's passed in the message, use that.
- // Otherwise use the sender information.
- if (message['tabId']) {
- requestInfo['tabId'] = +message['tabId'];
- if (isNaN(requestInfo['tabId'])) {
- throw new Error('Cannot convert tab ID string to integer: ' +
- message['tabId']);
- }
- } else if (sender.tab) {
- requestInfo['tabId'] = sender.tab.id;
- }
+ // Set the tab ID. If it's passed in the message, use that.
+ // Otherwise use the sender information.
+ if (message['tabId']) {
+ requestInfo['tabId'] = +message['tabId'];
+ if (isNaN(requestInfo['tabId'])) {
+ throw new Error(
+ 'Cannot convert tab ID string to integer: ' + message['tabId']);
+ }
+ } else if (sender.tab) {
+ requestInfo['tabId'] = sender.tab.id;
+ }
- if (sender.guestProcessId) {
- requestInfo['guestProcessId'] = sender.guestProcessId;
- }
+ if (sender.guestProcessId) {
+ requestInfo['guestProcessId'] = sender.guestProcessId;
+ }
- var method = message['method'];
+ var method = message['method'];
- // Set the origin. If a URL is passed in the message, use that.
- // Otherwise use the sender information.
- var origin;
- if (message['winUrl']) {
- origin = getHost(message['winUrl']);
- } else {
- origin = getHost(sender.url);
- }
+ // Set the origin. If a URL is passed in the message, use that.
+ // Otherwise use the sender information.
+ var origin;
+ if (message['winUrl']) {
+ origin = getHost(message['winUrl']);
+ } else {
+ origin = getHost(sender.url);
+ }
- if (method == 'cpu.getInfo') {
- chrome.system.cpu.getInfo(doSendResponse);
- return true;
- } else if (method == 'logging.setMetadata') {
- var metaData = message['metaData'];
- chrome.webrtcLoggingPrivate.setMetaData(
- requestInfo, origin, metaData, doSendResponse);
- return true;
- } else if (method == 'logging.start') {
- chrome.webrtcLoggingPrivate.start(
- requestInfo, origin, doSendResponse);
- return true;
- } else if (method == 'logging.uploadOnRenderClose') {
- chrome.webrtcLoggingPrivate.setUploadOnRenderClose(
- requestInfo, origin, true);
- doSendResponse();
- return false;
- } else if (method == 'logging.noUploadOnRenderClose') {
- chrome.webrtcLoggingPrivate.setUploadOnRenderClose(
- requestInfo, origin, false);
- doSendResponse();
- return false;
- } else if (method == 'logging.stop') {
- chrome.webrtcLoggingPrivate.stop(
- requestInfo, origin, doSendResponse);
- return true;
- } else if (method == 'logging.upload') {
- chrome.webrtcLoggingPrivate.upload(
- requestInfo, origin, doSendResponse);
- return true;
- } else if (method == 'logging.uploadStored') {
- var logId = message['logId'];
- chrome.webrtcLoggingPrivate.uploadStored(
- requestInfo, origin, logId, doSendResponse);
- return true;
- } else if (method == 'logging.stopAndUpload') {
- // Stop everything and upload. This is allowed to be called even if
- // logs have already been stopped or not started. Therefore, ignore
- // any errors along the way, but store them, so that if upload fails
- // they are all reported back.
- // Stop incoming and outgoing RTP dumps separately, otherwise
- // stopRtpDump will fail and not stop anything if either type has not
- // been started.
- var errors = [];
- chrome.webrtcLoggingPrivate.stopRtpDump(
- requestInfo, origin, true /* incoming */, false /* outgoing */,
- function() {
+ if (method == 'cpu.getInfo') {
+ chrome.system.cpu.getInfo(doSendResponse);
+ return true;
+ } else if (method == 'logging.setMetadata') {
+ var metaData = message['metaData'];
+ chrome.webrtcLoggingPrivate.setMetaData(
+ requestInfo, origin, metaData, doSendResponse);
+ return true;
+ } else if (method == 'logging.start') {
+ chrome.webrtcLoggingPrivate.start(requestInfo, origin, doSendResponse);
+ return true;
+ } else if (method == 'logging.uploadOnRenderClose') {
+ chrome.webrtcLoggingPrivate.setUploadOnRenderClose(
+ requestInfo, origin, true);
+ doSendResponse();
+ return false;
+ } else if (method == 'logging.noUploadOnRenderClose') {
+ chrome.webrtcLoggingPrivate.setUploadOnRenderClose(
+ requestInfo, origin, false);
+ doSendResponse();
+ return false;
+ } else if (method == 'logging.stop') {
+ chrome.webrtcLoggingPrivate.stop(requestInfo, origin, doSendResponse);
+ return true;
+ } else if (method == 'logging.upload') {
+ chrome.webrtcLoggingPrivate.upload(requestInfo, origin, doSendResponse);
+ return true;
+ } else if (method == 'logging.uploadStored') {
+ var logId = message['logId'];
+ chrome.webrtcLoggingPrivate.uploadStored(
+ requestInfo, origin, logId, doSendResponse);
+ return true;
+ } else if (method == 'logging.stopAndUpload') {
+ // Stop everything and upload. This is allowed to be called even if
+ // logs have already been stopped or not started. Therefore, ignore
+ // any errors along the way, but store them, so that if upload fails
+ // they are all reported back.
+ // Stop incoming and outgoing RTP dumps separately, otherwise
+ // stopRtpDump will fail and not stop anything if either type has not
+ // been started.
+ var errors = [];
+ chrome.webrtcLoggingPrivate.stopRtpDump(
+ requestInfo, origin, true /* incoming */, false /* outgoing */,
+ function() {
appendLastErrorMessage(errors);
chrome.webrtcLoggingPrivate.stopRtpDump(
requestInfo, origin, false /* incoming */, true /* outgoing */,
function() {
- appendLastErrorMessage(errors);
- chrome.webrtcLoggingPrivate.stop(
- requestInfo, origin, function() {
- appendLastErrorMessage(errors);
- chrome.webrtcLoggingPrivate.upload(
- requestInfo, origin,
- function(uploadValue) {
- var errorMessage = null;
- // If upload fails, report all previous errors. Otherwise,
- // throw them away.
- if (chrome.extension.lastError !== undefined) {
- appendLastErrorMessage(errors);
- errorMessage = errors.join('; ');
- }
- doSendResponse(uploadValue, errorMessage);
+ appendLastErrorMessage(errors);
+ chrome.webrtcLoggingPrivate.stop(
+ requestInfo, origin, function() {
+ appendLastErrorMessage(errors);
+ chrome.webrtcLoggingPrivate.upload(
+ requestInfo, origin, function(uploadValue) {
+ var errorMessage = null;
+ // If upload fails, report all previous errors.
+ // Otherwise,
+ // throw them away.
+ if (chrome.extension.lastError !== undefined) {
+ appendLastErrorMessage(errors);
+ errorMessage = errors.join('; ');
+ }
+ doSendResponse(uploadValue, errorMessage);
+ });
+ });
});
- });
- });
- });
- return true;
- } else if (method == 'logging.store') {
- var logId = message['logId'];
- chrome.webrtcLoggingPrivate.store(
- requestInfo, origin, logId, doSendResponse);
- return true;
- } else if (method == 'logging.discard') {
- chrome.webrtcLoggingPrivate.discard(
- requestInfo, origin, doSendResponse);
- return true;
- } else if (method == 'getSinks') {
- chrome.webrtcAudioPrivate.getSinks(doSendResponse);
- return true;
- } else if (method == 'getActiveSink') {
- chrome.webrtcAudioPrivate.getActiveSink(
- requestInfo, doSendResponse);
- return true;
- } else if (method == 'setActiveSink') {
- var sinkId = message['sinkId'];
- chrome.webrtcAudioPrivate.setActiveSink(
- requestInfo, sinkId, doSendResponse);
- return true;
- } else if (method == 'getAssociatedSink') {
- var sourceId = message['sourceId'];
- chrome.webrtcAudioPrivate.getAssociatedSink(
- origin, sourceId, doSendResponse);
- return true;
- } else if (method == 'isExtensionEnabled') {
- // This method is necessary because there may be more than one
- // version of this extension, under different extension IDs. By
- // first calling this method on the extension ID, the client can
- // check if it's loaded; if it's not, the extension system will
- // call the callback with no arguments and set
- // chrome.runtime.lastError.
- doSendResponse();
- return false;
- } else if (method == 'getNaclArchitecture') {
- chrome.runtime.getPlatformInfo(function(obj) {
- doSendResponse(obj.nacl_arch);
});
- return true;
- } else if (method == 'logging.startRtpDump') {
- var incoming = message['incoming'] || false;
- var outgoing = message['outgoing'] || false;
- chrome.webrtcLoggingPrivate.startRtpDump(
- requestInfo, origin, incoming, outgoing, doSendResponse);
- return true;
- } else if (method == 'logging.stopRtpDump') {
- var incoming = message['incoming'] || false;
- var outgoing = message['outgoing'] || false;
- chrome.webrtcLoggingPrivate.stopRtpDump(
- requestInfo, origin, incoming, outgoing, doSendResponse);
- return true;
- } else if (method == 'logging.startAudioDebugRecordings') {
- var seconds = message['seconds'] || 0;
- chrome.webrtcLoggingPrivate.startAudioDebugRecordings(
- requestInfo, origin, seconds, doSendResponse);
- return true;
- } else if (method == 'logging.stopAudioDebugRecordings') {
- chrome.webrtcLoggingPrivate.stopAudioDebugRecordings(
- requestInfo, origin, doSendResponse);
- return true;
- } else if (method == 'logging.startWebRtcEventLogging') {
- var seconds = message['seconds'] || 0;
- chrome.webrtcLoggingPrivate.startWebRtcEventLogging(
- requestInfo, origin, seconds, doSendResponse);
- return true;
- } else if (method == 'logging.stopWebRtcEventLogging') {
- chrome.webrtcLoggingPrivate.stopWebRtcEventLogging(
- requestInfo, origin, doSendResponse);
- return true;
- }
-
- throw new Error('Unknown method: ' + method);
- } catch (e) {
- doSendResponse(null, e.name + ': ' + e.message);
- }
+ return true;
+ } else if (method == 'logging.store') {
+ var logId = message['logId'];
+ chrome.webrtcLoggingPrivate.store(
+ requestInfo, origin, logId, doSendResponse);
+ return true;
+ } else if (method == 'logging.discard') {
+ chrome.webrtcLoggingPrivate.discard(requestInfo, origin, doSendResponse);
+ return true;
+ } else if (method == 'getSinks') {
+ chrome.webrtcAudioPrivate.getSinks(doSendResponse);
+ return true;
+ } else if (method == 'getActiveSink') {
+ chrome.webrtcAudioPrivate.getActiveSink(requestInfo, doSendResponse);
+ return true;
+ } else if (method == 'setActiveSink') {
+ var sinkId = message['sinkId'];
+ chrome.webrtcAudioPrivate.setActiveSink(
+ requestInfo, sinkId, doSendResponse);
+ return true;
+ } else if (method == 'getAssociatedSink') {
+ var sourceId = message['sourceId'];
+ chrome.webrtcAudioPrivate.getAssociatedSink(
+ origin, sourceId, doSendResponse);
+ return true;
+ } else if (method == 'isExtensionEnabled') {
+ // This method is necessary because there may be more than one
+ // version of this extension, under different extension IDs. By
+ // first calling this method on the extension ID, the client can
+ // check if it's loaded; if it's not, the extension system will
+ // call the callback with no arguments and set
+ // chrome.runtime.lastError.
+ doSendResponse();
+ return false;
+ } else if (method == 'getNaclArchitecture') {
+ chrome.runtime.getPlatformInfo(function(obj) {
+ doSendResponse(obj.nacl_arch);
+ });
+ return true;
+ } else if (method == 'logging.startRtpDump') {
+ var incoming = message['incoming'] || false;
+ var outgoing = message['outgoing'] || false;
+ chrome.webrtcLoggingPrivate.startRtpDump(
+ requestInfo, origin, incoming, outgoing, doSendResponse);
+ return true;
+ } else if (method == 'logging.stopRtpDump') {
+ var incoming = message['incoming'] || false;
+ var outgoing = message['outgoing'] || false;
+ chrome.webrtcLoggingPrivate.stopRtpDump(
+ requestInfo, origin, incoming, outgoing, doSendResponse);
+ return true;
+ } else if (method == 'logging.startAudioDebugRecordings') {
+ var seconds = message['seconds'] || 0;
+ chrome.webrtcLoggingPrivate.startAudioDebugRecordings(
+ requestInfo, origin, seconds, doSendResponse);
+ return true;
+ } else if (method == 'logging.stopAudioDebugRecordings') {
+ chrome.webrtcLoggingPrivate.stopAudioDebugRecordings(
+ requestInfo, origin, doSendResponse);
+ return true;
+ } else if (method == 'logging.startWebRtcEventLogging') {
+ var seconds = message['seconds'] || 0;
+ chrome.webrtcLoggingPrivate.startWebRtcEventLogging(
+ requestInfo, origin, seconds, doSendResponse);
+ return true;
+ } else if (method == 'logging.stopWebRtcEventLogging') {
+ chrome.webrtcLoggingPrivate.stopWebRtcEventLogging(
+ requestInfo, origin, doSendResponse);
+ return true;
}
-);
+
+ throw new Error('Unknown method: ' + method);
+ } catch (e) {
+ doSendResponse(null, e.name + ': ' + e.message);
+ }
+});
// If Hangouts connects with a port named 'onSinksChangedListener', we
// will register a listener and send it a message {'eventName':
@@ -221,8 +215,7 @@ function onSinksChangedPort(port) {
chrome.webrtcAudioPrivate.onSinksChanged.addListener(clientListener);
port.onDisconnect.addListener(function() {
- chrome.webrtcAudioPrivate.onSinksChanged.removeListener(
- clientListener);
+ chrome.webrtcAudioPrivate.onSinksChanged.removeListener(clientListener);
});
}
@@ -290,8 +283,9 @@ function onProcessCpu(port) {
browserProcessCpu = process.cpu;
} else if (process.type == 'gpu') {
gpuProcessCpu = process.cpu;
- } else if ((process.type == 'plugin' || process.type == 'nacl') &&
- process.title.toLowerCase().indexOf('hangouts') > 0) {
+ } else if (
+ (process.type == 'plugin' || process.type == 'nacl') &&
+ process.title.toLowerCase().indexOf('hangouts') > 0) {
pluginProcessCpu = process.cpu;
}
}

Powered by Google App Engine
This is Rietveld 408576698