| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file | 
|  | 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. | 
|  | 4 | 
|  | 5 import "dart:async" show Future, Stream; | 
|  | 6 import "dart:convert" show Encoding; | 
|  | 7 | 
|  | 8 import "../resource_loader.dart" as base; | 
|  | 9 import "../package_loader.dart"as base; | 
|  | 10 import "html_io.dart" as io; | 
|  | 11 | 
|  | 12 /// Resource loading strategy. | 
|  | 13 /// | 
|  | 14 /// An abstraction of the functionality needed to load resources. | 
|  | 15 /// | 
|  | 16 /// Implementations of this interface decide which URI schemes they support. | 
|  | 17 abstract class ResourceLoader implements base.ResourceLoader { | 
|  | 18   /// A resource loader that can load as many of the following URI | 
|  | 19   /// schemes as are supported by the platform: | 
|  | 20   /// * file | 
|  | 21   /// * http | 
|  | 22   /// * https | 
|  | 23   /// * data | 
|  | 24   /// * package | 
|  | 25   /// | 
|  | 26   /// (For example, file: URIs are not supported in the browser). | 
|  | 27   /// Relative URI references are accepted - they are resolved against | 
|  | 28   /// [Uri.base] before being loaded. | 
|  | 29   static ResourceLoader get defaultLoader => | 
|  | 30       const PackageLoader(const DefaultLoader()); | 
|  | 31 } | 
|  | 32 | 
|  | 33 /// Default implementation of [ResourceLoader].. | 
|  | 34 /// | 
|  | 35 /// Uses the system's available loading functionality to implement the | 
|  | 36 /// loading functions. | 
|  | 37 /// | 
|  | 38 /// Supports as many of `http:`, `https:`, `file:` and `data:` URIs as | 
|  | 39 /// possible. | 
|  | 40 class DefaultLoader implements ResourceLoader { | 
|  | 41   const DefaultLoader(); | 
|  | 42 | 
|  | 43   Stream<List<int>> openRead(Uri uri) => io.readAsStream(uri); | 
|  | 44 | 
|  | 45   Future<List<int>> readAsBytes(Uri uri) => io.readAsBytes(uri); | 
|  | 46 | 
|  | 47   Future<String> readAsString(Uri uri, {Encoding encoding}) => | 
|  | 48       io.readAsString(uri, encoding); | 
|  | 49 } | 
|  | 50 | 
|  | 51 // A loader that implements base.PackageLoader *and* ResourceLoader from this | 
|  | 52 // file. | 
|  | 53 class PackageLoader extends base.PackageLoader implements ResourceLoader { | 
|  | 54   const PackageLoader(ResourceLoader loader) : super(loader); | 
|  | 55 } | 
| OLD | NEW | 
|---|