Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Unified Diff: lib/src/resource_loader.dart

Issue 1612003002: Add browser-compatible version. (Closed) Base URL: https://github.com/dart-lang/resource.git@master
Patch Set: Made test run Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/resource.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/resource_loader.dart
diff --git a/lib/src/resource_loader.dart b/lib/src/resource_loader.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1a189e15f86b08e29d24c44f9d35b49989176f88
--- /dev/null
+++ b/lib/src/resource_loader.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:async" show Future, Stream;
+import "dart:convert" show Encoding;
+
+/// Resource loading strategy.
+///
+/// An abstraction of the functionality needed to load resources.
+///
+/// Implementations of this interface decide which URI schemes they support.
+abstract class ResourceLoader {
+ /// Reads the file located by [uri] as a stream of bytes.
+ Stream<List<int>> openRead(Uri uri);
+
+ /// Reads the file located by [uri] as a list of bytes.
+ Future<List<int>> readAsBytes(Uri uri);
+
+ /// Reads the file located by [uri] as a [String].
+ ///
+ /// The file bytes are decoded using [encoding], if provided.
+ ///
+ /// If [encoding] is omitted, the default for the `file:` scheme is UTF-8.
+ /// For `http`, `https` and `data` URIs, the Content-Type header's charset
+ /// is used, if available and recognized by [Encoding.getByName],
+ /// otherwise it defaults to Latin-1 for `http` and `https`
+ /// and to ASCII for `data` URIs.
+ Future<String> readAsString(Uri uri, {Encoding encoding});
+}
+
« no previous file with comments | « lib/src/resource.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698