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

Side by Side Diff: remoting/webapp/app_remoting/js/feedback_consent.js

Issue 1003433002: Updated remoting.xhr API to use promises. Removed access to the native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spy-promise
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @type {string} The host id corresponding to the user's VM. The @pending 8 * @type {string} The host id corresponding to the user's VM. The @pending
9 * place-holder instructs the Orchestrator to abandon any pending host, 9 * place-holder instructs the Orchestrator to abandon any pending host,
10 * and is used if no host id is provided by the main window. 10 * and is used if no host id is provided by the main window.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } else { 120 } else {
121 if (abandonHost == 'yes') { 121 if (abandonHost == 'yes') {
122 var body = { 122 var body = {
123 'abandonHost': 'true', 123 'abandonHost': 'true',
124 'crashServiceReportId': crashServiceReportId 124 'crashServiceReportId': crashServiceReportId
125 }; 125 };
126 var uri = remoting.settings.APP_REMOTING_API_BASE_URL + 126 var uri = remoting.settings.APP_REMOTING_API_BASE_URL +
127 '/applications/' + remoting.settings.getAppRemotingApplicationId() + 127 '/applications/' + remoting.settings.getAppRemotingApplicationId() +
128 '/hosts/' + hostId + 128 '/hosts/' + hostId +
129 '/reportIssue'; 129 '/reportIssue';
130 /** @param {XMLHttpRequest} xhr */ 130 /** @param {!remoting.Xhr.Response} response */
Jamie 2015/03/18 22:16:16 Nit: Use the shorter, in-line "/** <type> */" synt
John Williams 2015/03/19 20:19:42 Done.
131 var onDone = function(xhr) { 131 var onDone = function(response) {
132 if (xhr.status >= 200 && xhr.status < 300) { 132 if (response.status >= 200 && response.status < 300) {
133 getUserInfo(); 133 getUserInfo();
134 } else { 134 } else {
135 showError(); 135 showError();
136 } 136 }
137 }; 137 };
138 remoting.xhr.start({ 138 new remoting.Xhr({
139 method: 'POST', 139 method: 'POST',
140 url: uri, 140 url: uri,
141 onDone: onDone,
142 jsonContent: body, 141 jsonContent: body,
143 oauthToken: token 142 oauthToken: token
144 }); 143 }).start().then(onDone);
145 } else { 144 } else {
146 getUserInfo(); 145 getUserInfo();
147 } 146 }
148 } 147 }
149 } 148 }
150 149
151 function onOk() { 150 function onOk() {
152 setWaiting(true); 151 setWaiting(true);
153 var abandon = /** @type {HTMLInputElement} */ 152 var abandon = /** @type {HTMLInputElement} */
154 (document.getElementById('abandon-host')); 153 (document.getElementById('abandon-host'));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 var method = /** @type {string} */ (event.data['method']); 223 var method = /** @type {string} */ (event.data['method']);
225 if (method == 'init') { 224 if (method == 'init') {
226 if (event.data['hostId']) { 225 if (event.data['hostId']) {
227 hostId = /** @type {string} */ (event.data['hostId']); 226 hostId = /** @type {string} */ (event.data['hostId']);
228 } 227 }
229 connectionStats = /** @type {string} */ (event.data['connectionStats']); 228 connectionStats = /** @type {string} */ (event.data['connectionStats']);
230 } 229 }
231 }; 230 };
232 231
233 window.addEventListener('load', onLoad, false); 232 window.addEventListener('load', onLoad, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698