| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io' hide HttpException; |
| 7 | 7 |
| 8 import 'buildbot_data.dart'; | 8 import 'buildbot_data.dart'; |
| 9 import 'buildbot_loading.dart'; | 9 import 'buildbot_loading.dart'; |
| 10 import 'buildbot_structures.dart'; | 10 import 'buildbot_structures.dart'; |
| 11 import 'logdog.dart'; | 11 import 'logdog.dart'; |
| 12 import 'util.dart'; | 12 import 'util.dart'; |
| 13 | 13 |
| 14 /// Interface for pulling build bot results. | 14 /// Interface for pulling build bot results. |
| 15 abstract class BuildbotClient { | 15 abstract class BuildbotClient { |
| 16 /// Reads the [BuildResult] for the [buildUri]. | 16 /// Reads the [BuildResult] for the [buildUri]. |
| 17 Future<BuildResult> readResult(BuildUri buildUri); | 17 Future<BuildResult> readResult(BuildUri buildUri); |
| 18 | 18 |
| 19 int get mostRecentBuildNumber; | 19 int get mostRecentBuildNumber; |
| 20 | 20 |
| 21 /// Closes the client and cleans up its state. | 21 /// Closes the client and cleans up its state. |
| 22 void close(); | 22 void close(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 /// Buildbot client that pulls build bot results through http. | 25 /// Buildbot client that pulls build bot results through http. |
| 26 class HttpBuildbotClient implements BuildbotClient { | 26 class HttpBuildbotClient implements BuildbotClient { |
| 27 final HttpClient _client = new HttpClient(); | 27 final HttpClient _client = new HttpClient(); |
| 28 | 28 |
| 29 @override | 29 @override |
| 30 Future<BuildResult> readResult(BuildUri buildUri) { | 30 Future<BuildResult> readResult(BuildUri buildUri) async { |
| 31 return readBuildResultFromHttp(_client, buildUri); | 31 try { |
| 32 return await readBuildResultFromHttp(_client, buildUri); |
| 33 } on HttpException { |
| 34 return null; |
| 35 } |
| 32 } | 36 } |
| 33 | 37 |
| 34 int get mostRecentBuildNumber => -2; | 38 int get mostRecentBuildNumber => -2; |
| 35 | 39 |
| 36 @override | 40 @override |
| 37 void close() { | 41 void close() { |
| 38 _client.close(); | 42 _client.close(); |
| 39 } | 43 } |
| 40 } | 44 } |
| 41 | 45 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 buildUri = buildUri.withBuildNumber(buildNumber); | 87 buildUri = buildUri.withBuildNumber(buildNumber); |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 } | 90 } |
| 87 | 91 |
| 88 @override | 92 @override |
| 89 void close() { | 93 void close() { |
| 90 // Nothing to do. | 94 // Nothing to do. |
| 91 } | 95 } |
| 92 } | 96 } |
| OLD | NEW |