| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
| 9 import 'package:mojom/mojo/network_service.mojom.dart'; | 9 import 'package:mojom/mojo/network_service.mojom.dart'; |
| 10 import 'package:mojom/mojo/url_loader.mojom.dart'; | 10 import 'package:mojom/mojo/url_loader.mojom.dart'; |
| 11 import 'package:mojom/mojo/url_request.mojom.dart'; | 11 import 'package:mojom/mojo/url_request.mojom.dart'; |
| 12 import 'package:mojom/mojo/url_response.mojom.dart'; | 12 import 'package:mojom/mojo/url_response.mojom.dart'; |
| 13 | 13 import 'package:sky/mojo/shell.dart' as shell; |
| 14 import '../shell.dart' as shell; | |
| 15 | 14 |
| 16 class Response { | 15 class Response { |
| 17 ByteData body; | 16 ByteData body; |
| 18 | 17 |
| 19 Response(this.body); | 18 Response(this.body); |
| 20 | 19 |
| 21 String bodyAsString() { | 20 String bodyAsString() { |
| 22 if (body == null) | 21 if (body == null) |
| 23 return null; | 22 return null; |
| 24 return new String.fromCharCodes(new Uint8List.view(body.buffer)); | 23 return new String.fromCharCodes(new Uint8List.view(body.buffer)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (response.body == null) return new Response(null); | 55 if (response.body == null) return new Response(null); |
| 57 | 56 |
| 58 ByteData data = await core.DataPipeDrainer.drainHandle(response.body); | 57 ByteData data = await core.DataPipeDrainer.drainHandle(response.body); |
| 59 return new Response(data); | 58 return new Response(data); |
| 60 } | 59 } |
| 61 | 60 |
| 62 Future<String> fetchString(String relativeUrl) async { | 61 Future<String> fetchString(String relativeUrl) async { |
| 63 Response response = await fetchBody(relativeUrl); | 62 Response response = await fetchBody(relativeUrl); |
| 64 return response.bodyAsString(); | 63 return response.bodyAsString(); |
| 65 } | 64 } |
| OLD | NEW |