| 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 '../shell.dart' as shell; | |
| 6 import 'dart:async'; | 5 import 'dart:async'; |
| 7 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 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 |
| 14 import '../shell.dart' as shell; |
| 15 |
| 14 class Response { | 16 class Response { |
| 15 ByteData body; | 17 ByteData body; |
| 16 | 18 |
| 17 Response(this.body); | 19 Response(this.body); |
| 18 | 20 |
| 19 String bodyAsString() { | 21 String bodyAsString() { |
| 20 return new String.fromCharCodes(new Uint8List.view(body.buffer)); | 22 return new String.fromCharCodes(new Uint8List.view(body.buffer)); |
| 21 } | 23 } |
| 22 } | 24 } |
| 23 | 25 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 return fetch(request); | 45 return fetch(request); |
| 44 } | 46 } |
| 45 | 47 |
| 46 Future<Response> fetchBody(String relativeUrl) async { | 48 Future<Response> fetchBody(String relativeUrl) async { |
| 47 UrlResponse response = await fetchUrl(relativeUrl); | 49 UrlResponse response = await fetchUrl(relativeUrl); |
| 48 if (response.body == null) return new Response(null); | 50 if (response.body == null) return new Response(null); |
| 49 | 51 |
| 50 ByteData data = await core.DataPipeDrainer.drainHandle(response.body); | 52 ByteData data = await core.DataPipeDrainer.drainHandle(response.body); |
| 51 return new Response(data); | 53 return new Response(data); |
| 52 } | 54 } |
| OLD | NEW |