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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/HostListManager.java

Issue 1976853002: [Remoting Android] Refactor OAuth Token Fetching Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.HandlerThread; 8 import android.os.HandlerThread;
9 import android.os.Looper; 9 import android.os.Looper;
10 10
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 byte[] requestBytes = requestBody.getBytes("UTF-8"); 268 byte[] requestBytes = requestBody.getBytes("UTF-8");
269 OutputStream outStream = link.getOutputStream(); 269 OutputStream outStream = link.getOutputStream();
270 outStream.write(requestBytes); 270 outStream.write(requestBytes);
271 outStream.close(); 271 outStream.close();
272 } 272 }
273 273
274 // Listen for the server to respond. 274 // Listen for the server to respond.
275 int status = link.getResponseCode(); 275 int status = link.getResponseCode();
276 switch (status) { 276 switch (status) {
277 case HttpURLConnection.HTTP_OK: // 200 277 case HttpURLConnection.HTTP_OK: // 200
278 case HttpURLConnection.HTTP_NO_CONTENT: // 204
Yuwei 2016/05/13 00:30:17 This is a quick fix for the HostListManager. Turns
Lambros 2016/05/13 01:11:31 We should probably replace this switch-statement w
Yuwei 2016/05/13 03:53:58 Sure. I'll add a TODO here. BTW I think only 401 i
278 break; 279 break;
279 case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 280 case HttpURLConnection.HTTP_UNAUTHORIZED: // 401
280 error = Error.AUTH_FAILED; 281 error = Error.AUTH_FAILED;
281 break; 282 break;
282 case HttpURLConnection.HTTP_BAD_GATEWAY: // 502 283 case HttpURLConnection.HTTP_BAD_GATEWAY: // 502
283 case HttpURLConnection.HTTP_UNAVAILABLE: // 503 284 case HttpURLConnection.HTTP_UNAVAILABLE: // 503
284 error = Error.SERVICE_UNAVAILABLE; 285 error = Error.SERVICE_UNAVAILABLE;
285 break; 286 break;
286 default: 287 default:
287 error = Error.UNKNOWN; 288 error = Error.UNKNOWN;
(...skipping 15 matching lines...) Expand all
303 throw new RuntimeException("Unexpected error while fetching host lis t: ", ex); 304 throw new RuntimeException("Unexpected error while fetching host lis t: ", ex);
304 } catch (IOException ex) { 305 } catch (IOException ex) {
305 return new Response(Error.NETWORK_ERROR, null); 306 return new Response(Error.NETWORK_ERROR, null);
306 } finally { 307 } finally {
307 if (link != null) { 308 if (link != null) {
308 link.disconnect(); 309 link.disconnect();
309 } 310 }
310 } 311 }
311 } 312 }
312 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698