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

Side by Side Diff: web/inc/rpc/rpc-call.html

Issue 2570963003: Revert of Rewrite LogDog log viewer app. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « web/inc/rpc/client.ts ('k') | web/inc/rpc/rpc-error.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright 2016 The LUCI Authors. All rights reserved. 2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 --> 5 -->
6 6
7 <link rel="import" href="../bower_components/iron-ajax/iron-request.html"> 7 <link rel="import" href="../bower_components/iron-ajax/iron-request.html">
8 8
9 <!-- 9 <!--
10 The `rpc-call` is a single RPC call. Produced by <rpc-client>. 10 The `rpc-call` is a single RPC call. Produced by <rpc-client>.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 this._ironRequest = document.createElement('iron-request'); 195 this._ironRequest = document.createElement('iron-request');
196 this._ironRequest.send(this.toRequestOptions()); 196 this._ironRequest.send(this.toRequestOptions());
197 this.xhr = this._ironRequest.xhr; 197 this.xhr = this._ironRequest.xhr;
198 this._ironRequest.completes 198 this._ironRequest.completes
199 .then(this._done.bind(this, null)) 199 .then(this._done.bind(this, null))
200 .catch(this._done.bind(this)); 200 .catch(this._done.bind(this));
201 }, 201 },
202 202
203 _done: function(error) { 203 _done: function(error) {
204 try { 204 try {
205 var status = this.xhr.status; 205 if (error && typeof this.xhr.status !== 'number') {
206 if (error && typeof status !== 'number') {
207 // We didn't receive the response. 206 // We didn't receive the response.
208 throw error; 207 throw error;
209 } 208 }
210 209
211 var codeHeader = this.xhr.getResponseHeader('X-Prpc-Grpc-Code'); 210 var codeHeader = this.xhr.getResponseHeader('X-Prpc-Grpc-Code');
212 if (!codeHeader) { 211 if (!codeHeader) {
213 throw new luci.rpc.HttpError( status, 212 throw Error(
214 'Invalid response: no X-Prpc-Grpc-Code response header'); 213 'Invalid response: no X-Prpc-Grpc-Code response header');
215 } 214 }
216 215
217 try { 216 try {
218 this._setCode(parseInt(codeHeader, 10)); 217 this._setCode(parseInt(codeHeader, 10));
219 if (this.code == null || isNaN(this.code)) { 218 if (this.code == null || isNaN(this.code)) {
220 throw Error('code is not defined'); 219 throw Error('code is not defined');
221 } 220 }
222 } catch (e) { 221 } catch (e) {
223 throw new luci.rpc.HttpError( status, 222 throw Error(
224 'Invalid X-Prpc-Grpc-Code response header "' + codeHeader + 223 'Invalid X-Prpc-Grpc-Code response header "' + codeHeader +
225 '": ' + e 224 '": ' + e
226 ); 225 );
227 } 226 }
228 227
229 if (this.code !== luci.rpc.Code.OK) { 228 if (this.code !== luci.rpc.Code.OK) {
230 throw new luci.rpc.GrpcError(this.code, this.xhr.responseText); 229 throw new luci.rpc.GrpcError(this.code, this.xhr.responseText);
231 } 230 }
232 231
233 if (this._ironRequest.response == null) { 232 if (this._ironRequest.response == null) {
234 throw Error('could not parse response'); 233 throw Error('could not parse response');
235 } 234 }
236 235
237 this._setResponse(this._ironRequest.response); 236 this._setResponse(this._ironRequest.response);
238 this._setError(null); 237 this._setError(null);
239 this._resolveCompletes(this); 238 this._resolveCompletes(this);
240 } catch (e) { 239 } catch (e) {
241 this._setResponse(null); 240 this._setResponse(null);
242 this._setError(e); 241 this._setError(e);
243 this._rejectCompletes(e); 242 this._rejectCompletes(e);
244 } 243 }
245 } 244 }
246 }); 245 });
247 </script> 246 </script>
248 </dom-module> 247 </dom-module>
OLDNEW
« no previous file with comments | « web/inc/rpc/client.ts ('k') | web/inc/rpc/rpc-error.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698