Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |