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

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 var onDone = function(/** !remoting.Xhr.Response */ response) {
131 var onDone = function(xhr) { 131 if (response.status >= 200 && response.status < 300) {
132 if (xhr.status >= 200 && xhr.status < 300) {
133 getUserInfo(); 132 getUserInfo();
134 } else { 133 } else {
135 showError(); 134 showError();
136 } 135 }
137 }; 136 };
138 remoting.xhr.start({ 137 new remoting.Xhr({
139 method: 'POST', 138 method: 'POST',
140 url: uri, 139 url: uri,
141 onDone: onDone,
142 jsonContent: body, 140 jsonContent: body,
143 oauthToken: token 141 oauthToken: token
144 }); 142 }).start().then(onDone);
145 } else { 143 } else {
146 getUserInfo(); 144 getUserInfo();
147 } 145 }
148 } 146 }
149 } 147 }
150 148
151 function onOk() { 149 function onOk() {
152 setWaiting(true); 150 setWaiting(true);
153 var abandon = /** @type {HTMLInputElement} */ 151 var abandon = /** @type {HTMLInputElement} */
154 (document.getElementById('abandon-host')); 152 (document.getElementById('abandon-host'));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 var method = /** @type {string} */ (event.data['method']); 222 var method = /** @type {string} */ (event.data['method']);
225 if (method == 'init') { 223 if (method == 'init') {
226 if (event.data['hostId']) { 224 if (event.data['hostId']) {
227 hostId = /** @type {string} */ (event.data['hostId']); 225 hostId = /** @type {string} */ (event.data['hostId']);
228 } 226 }
229 connectionStats = /** @type {string} */ (event.data['connectionStats']); 227 connectionStats = /** @type {string} */ (event.data['connectionStats']);
230 } 228 }
231 }; 229 };
232 230
233 window.addEventListener('load', onLoad, false); 231 window.addEventListener('load', onLoad, false);
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/crd/js/dns_blackhole_checker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698