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

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

Issue 2543323004: Rewrite LogDog log viewer app. (Closed)
Patch Set: Control all fetch sizes, fix follow on initial click, fix small fetch when auth is retrid. 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
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 if (error && typeof this.xhr.status !== 'number') { 205 var status = this.xhr.status;
206 if (error && typeof status !== 'number') {
206 // We didn't receive the response. 207 // We didn't receive the response.
207 throw error; 208 throw error;
208 } 209 }
209 210
210 var codeHeader = this.xhr.getResponseHeader('X-Prpc-Grpc-Code'); 211 var codeHeader = this.xhr.getResponseHeader('X-Prpc-Grpc-Code');
211 if (!codeHeader) { 212 if (!codeHeader) {
212 throw Error( 213 throw new luci.rpc.HttpError( status,
213 'Invalid response: no X-Prpc-Grpc-Code response header'); 214 'Invalid response: no X-Prpc-Grpc-Code response header');
214 } 215 }
215 216
216 try { 217 try {
217 this._setCode(parseInt(codeHeader, 10)); 218 this._setCode(parseInt(codeHeader, 10));
218 if (this.code == null || isNaN(this.code)) { 219 if (this.code == null || isNaN(this.code)) {
219 throw Error('code is not defined'); 220 throw Error('code is not defined');
220 } 221 }
221 } catch (e) { 222 } catch (e) {
222 throw Error( 223 throw new luci.rpc.HttpError( status,
223 'Invalid X-Prpc-Grpc-Code response header "' + codeHeader + 224 'Invalid X-Prpc-Grpc-Code response header "' + codeHeader +
224 '": ' + e 225 '": ' + e
225 ); 226 );
226 } 227 }
227 228
228 if (this.code !== luci.rpc.Code.OK) { 229 if (this.code !== luci.rpc.Code.OK) {
229 throw new luci.rpc.GrpcError(this.code, this.xhr.responseText); 230 throw new luci.rpc.GrpcError(this.code, this.xhr.responseText);
230 } 231 }
231 232
232 if (this._ironRequest.response == null) { 233 if (this._ironRequest.response == null) {
233 throw Error('could not parse response'); 234 throw Error('could not parse response');
234 } 235 }
235 236
236 this._setResponse(this._ironRequest.response); 237 this._setResponse(this._ironRequest.response);
237 this._setError(null); 238 this._setError(null);
238 this._resolveCompletes(this); 239 this._resolveCompletes(this);
239 } catch (e) { 240 } catch (e) {
240 this._setResponse(null); 241 this._setResponse(null);
241 this._setError(e); 242 this._setError(e);
242 this._rejectCompletes(e); 243 this._rejectCompletes(e);
243 } 244 }
244 } 245 }
245 }); 246 });
246 </script> 247 </script>
247 </dom-module> 248 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698