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

Unified Diff: chrome/browser/resources/google_now/utility.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge 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/google_now/utility.js
diff --git a/chrome/browser/resources/google_now/utility.js b/chrome/browser/resources/google_now/utility.js
index ee34219868a153d00846af7c0fdd49822a28c256..6dd5ba7be05aaaffb776a2ef8e9212f03f78afd1 100644
--- a/chrome/browser/resources/google_now/utility.js
+++ b/chrome/browser/resources/google_now/utility.js
@@ -123,7 +123,8 @@ function buildServerRequest(method, handlerName, opt_contentType) {
function sendErrorReport(error) {
// Don't remove 'error.stack.replace' below!
var filteredStack = error.canSendMessageToServer ?
- error.stack : error.stack.replace(/.*\n/, '(message removed)\n');
+ error.stack :
+ error.stack.replace(/.*\n/, '(message removed)\n');
var file;
var line;
var topFrameLineMatch = filteredStack.match(/\n at .*\n/);
@@ -162,12 +163,8 @@ function sendErrorReport(error) {
if (error.canSendMessageToServer)
errorText = errorText + ': ' + error.message;
- var errorObject = {
- message: errorText,
- file: file,
- line: line,
- trace: filteredStack
- };
+ var errorObject =
+ {message: errorText, file: file, line: line, trace: filteredStack};
// We use relatively direct calls here because the instrumentation may be in
// a bad state. Wrappers and promises should not be involved in the reporting.
@@ -290,8 +287,8 @@ var wrapper = (function() {
*/
function checkInWrappedCallback() {
if (!isInWrappedCallback) {
- reportError(buildErrorWithMessageForServer(
- 'Not in instrumented callback'));
+ reportError(
+ buildErrorWithMessageForServer('Not in instrumented callback'));
}
}
@@ -332,8 +329,9 @@ var wrapper = (function() {
if (wrapperPluginInstance)
wrapperPluginInstance.epilogue();
- verify(isInWrappedCallback,
- 'Instrumented callback is not instrumented upon exit');
+ verify(
+ isInWrappedCallback,
+ 'Instrumented callback is not instrumented upon exit');
isInWrappedCallback = false;
return returnValue;
@@ -353,9 +351,7 @@ var wrapper = (function() {
* @return {Function} An instrumented function.
*/
function createInstrumentedFunction(
- functionIdentifierParts,
- functionName,
- callbackParameter) {
+ functionIdentifierParts, functionName, callbackParameter) {
return function() {
// This is the wrapper for the API function. Pass the wrapped callback to
// the original function.
@@ -366,15 +362,14 @@ var wrapper = (function() {
functionIdentifierParts.join('.') + '.' + functionName +
' is not a function'));
}
- arguments[callbackParameter] = wrapCallback(
- callback, functionName == 'addListener');
+ arguments[callbackParameter] =
+ wrapCallback(callback, functionName == 'addListener');
var chromeContainer = chrome;
functionIdentifierParts.forEach(function(fragment) {
chromeContainer = chromeContainer[fragment];
});
- return chromeContainer[functionName].
- apply(chromeContainer, arguments);
+ return chromeContainer[functionName].apply(chromeContainer, arguments);
};
}
@@ -411,9 +406,7 @@ var wrapper = (function() {
}
instrumentedContainer[functionName] = createInstrumentedFunction(
- functionIdentifierParts,
- functionName,
- callbackParameter);
+ functionIdentifierParts, functionName, callbackParameter);
}
instrumentChromeApiFunction('runtime.onSuspend.addListener', 0);
@@ -423,7 +416,7 @@ var wrapper = (function() {
verify(
stringifiedPendingCallbacks == '{}',
'Pending callbacks when unloading event page @' + Date.now() + ':' +
- stringifiedPendingCallbacks);
+ stringifiedPendingCallbacks);
});
return {
@@ -566,14 +559,13 @@ function registerPromiseAdapter() {
* @return {*} Consumable argument with necessary wrapping applied.
*/
function registerAndWrapMaybeCallback(
- maybeCallback, sameTracker, otherTracker) {
+ maybeCallback, sameTracker, otherTracker) {
// If sameTracker.callbacks is undefined, we've reached an ending state
// that means this callback will never be called back.
// We will still forward this call on to let the promise system
// handle further processing, but since this promise is in an ending state
// we can be confident it will never be called back.
- if (isCallable(maybeCallback) &&
- !maybeCallback.wrappedByPromiseTracker &&
+ if (isCallable(maybeCallback) && !maybeCallback.wrappedByPromiseTracker &&
sameTracker.callbacks) {
var handler = wrapper.wrapCallback(function() {
if (sameTracker.callbacks) {
@@ -626,10 +618,7 @@ function registerPromiseAdapter() {
// which ends up calling handleThen.
handleThen(function() {}, function() {});
- return {
- handleThen: handleThen,
- handleCatch: handleCatch
- };
+ return {handleThen: handleThen, handleCatch: handleCatch};
}
}
@@ -657,8 +646,7 @@ var PromiseRejection = {
* otherwise it is resolved to the default storage object.
*/
function fillFromChromeLocalStorage(
- defaultStorageObject,
- opt_allowPromiseRejection) {
+ defaultStorageObject, opt_allowPromiseRejection) {
return new Promise(function(resolve, reject) {
// We have to create a keys array because keys with a default value
// of undefined will cause that key to not be looked up!
@@ -724,9 +712,8 @@ function buildTaskManager(areConflicting) {
verify(
taskPendingCallbackCount == 0,
'tasks.startFirst: still have pending task callbacks: ' +
- taskPendingCallbackCount +
- ', queue = ' + JSON.stringify(queue) + ', ' +
- wrapper.debugGetStateString());
+ taskPendingCallbackCount + ', queue = ' + JSON.stringify(queue) +
+ ', ' + wrapper.debugGetStateString());
var entry = queue[0];
console.log('Starting task ' + entry.name);
@@ -746,8 +733,8 @@ function buildTaskManager(areConflicting) {
function canQueue(taskName) {
for (var i = 0; i < queue.length; ++i) {
if (areConflicting(taskName, queue[i].name)) {
- console.log('Conflict: new=' + taskName +
- ', scheduled=' + queue[i].name);
+ console.log(
+ 'Conflict: new=' + taskName + ', scheduled=' + queue[i].name);
return false;
}
}
@@ -779,8 +766,7 @@ function buildTaskManager(areConflicting) {
* Completes the current task and starts the next queued task if available.
*/
function finish() {
- verify(queue.length >= 1,
- 'tasks.finish: The task queue is empty');
+ verify(queue.length >= 1, 'tasks.finish: The task queue is empty');
console.log('Finishing task ' + queue[0].name);
queue.shift();
@@ -790,10 +776,9 @@ function buildTaskManager(areConflicting) {
instrumented.runtime.onSuspend.addListener(function() {
verify(
- queue.length == 0,
- 'Incomplete task when unloading event page,' +
- ' queue = ' + JSON.stringify(queue) + ', ' +
- wrapper.debugGetStateString());
+ queue.length == 0, 'Incomplete task when unloading event page,' +
+ ' queue = ' + JSON.stringify(queue) + ', ' +
+ wrapper.debugGetStateString());
});
@@ -835,9 +820,7 @@ function buildTaskManager(areConflicting) {
return new TasksWrapperPlugin();
});
- return {
- add: add
- };
+ return {add: add};
}
/**
@@ -1036,17 +1019,17 @@ function buildAuthenticationManager() {
*/
function checkAndNotifyListeners() {
isSignedIn().then(function(signedIn) {
- fillFromChromeLocalStorage({lastSignedInState: undefined})
- .then(function(items) {
- if (items.lastSignedInState != signedIn) {
- chrome.storage.local.set(
- {lastSignedInState: signedIn});
- listeners.forEach(function(callback) {
- callback();
- });
- }
- });
+ fillFromChromeLocalStorage({
+ lastSignedInState: undefined
+ }).then(function(items) {
+ if (items.lastSignedInState != signedIn) {
+ chrome.storage.local.set({lastSignedInState: signedIn});
+ listeners.forEach(function(callback) {
+ callback();
+ });
+ }
});
+ });
}
instrumented.identity.onSignInChanged.addListener(function() {
« no previous file with comments | « chrome/browser/resources/google_now/common_test_util.js ('k') | chrome/browser/resources/google_now/utility_test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698