| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; | 33 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; |
| 34 int dartCharactersRead = 0; | 34 int dartCharactersRead = 0; |
| 35 | 35 |
| 36 Future<String> readStringFromUri(Uri resourceUri) { | 36 Future<String> readStringFromUri(Uri resourceUri) { |
| 37 return readUtf8BytesFromUri(resourceUri).then(UTF8.decode); | 37 return readUtf8BytesFromUri(resourceUri).then(UTF8.decode); |
| 38 } | 38 } |
| 39 | 39 |
| 40 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) { | 40 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) { |
| 41 if (resourceUri.scheme == 'file') { | 41 if (resourceUri.scheme == 'file') { |
| 42 return _readFromFile(resourceUri); | 42 return _readFromFile(resourceUri); |
| 43 } else if (resourceUri.scheme == 'http') { | 43 } else if (resourceUri.scheme == 'http' || resourceUri.scheme == 'https') { |
| 44 return _readFromHttp(resourceUri); | 44 return _readFromHttp(resourceUri); |
| 45 } else { | 45 } else { |
| 46 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); | 46 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 Future<List<int>> _readFromFile(Uri resourceUri) { | 50 Future<List<int>> _readFromFile(Uri resourceUri) { |
| 51 assert(resourceUri.scheme == 'file'); | 51 assert(resourceUri.scheme == 'file'); |
| 52 List<int> source; | 52 List<int> source; |
| 53 try { | 53 try { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 var onAdd, onClose; | 313 var onAdd, onClose; |
| 314 | 314 |
| 315 EventSinkWrapper(this.onAdd, this.onClose); | 315 EventSinkWrapper(this.onAdd, this.onClose); |
| 316 | 316 |
| 317 void add(String data) => onAdd(data); | 317 void add(String data) => onAdd(data); |
| 318 | 318 |
| 319 void addError(error, [StackTrace stackTrace]) => throw error; | 319 void addError(error, [StackTrace stackTrace]) => throw error; |
| 320 | 320 |
| 321 void close() => onClose(); | 321 void close() => onClose(); |
| 322 } | 322 } |
| OLD | NEW |