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

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

Issue 187263002: Refactor Authenticated Server Requests to use Promises (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify the scoping Created 6 years, 9 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 f5ccf80ce5eb67b1697e525c43980d212590fbdb..d91bd680d0274efa82538feb8d2201f7cd37a4d7 100644
--- a/chrome/browser/resources/google_now/utility.js
+++ b/chrome/browser/resources/google_now/utility.js
@@ -102,16 +102,16 @@ function verify(condition, message) {
* Builds a request to the notification server.
* @param {string} method Request method.
* @param {string} handlerName Server handler to send the request to.
- * @param {string=} contentType Value for the Content-type header.
+ * @param {string=} opt_contentType Value for the Content-type header.
* @return {XMLHttpRequest} Server request.
*/
-function buildServerRequest(method, handlerName, contentType) {
+function buildServerRequest(method, handlerName, opt_contentType) {
var request = new XMLHttpRequest();
request.responseType = 'text';
request.open(method, NOTIFICATION_CARDS_URL + '/' + handlerName, true);
- if (contentType)
- request.setRequestHeader('Content-type', contentType);
+ if (opt_contentType)
+ request.setRequestHeader('Content-type', opt_contentType);
return request;
}
@@ -169,6 +169,8 @@ function sendErrorReport(error) {
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.
var request = buildServerRequest('POST', 'jserrors', 'application/json');
request.onloadend = function(event) {
console.log('sendErrorReport status: ' + request.status);

Powered by Google App Engine
This is Rietveld 408576698