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

Unified Diff: runtime/lib/resource_patch.dart

Issue 1374953002: Remove Resource class and support functions. Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove reference to resource class in dart2js compiler. Created 5 years, 3 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
Index: runtime/lib/resource_patch.dart
diff --git a/runtime/lib/resource_patch.dart b/runtime/lib/resource_patch.dart
deleted file mode 100644
index 0643516881ba6b5b7b355cc0ec81ba41a7b43249..0000000000000000000000000000000000000000
--- a/runtime/lib/resource_patch.dart
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2015, 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.
-
-patch class Resource {
- /* patch */ const factory Resource(String uri) = _Resource;
-}
-
-class _Resource implements Resource {
- final String _location;
-
- const _Resource(this._location);
-
- Uri get uri => Uri.base.resolve(_location);
-
- Stream<List<int>> openRead() {
- if (VMLibraryHooks.resourceReadAsBytes == null) {
- throw new UnimplementedError("openRead");
- }
-
- var controller = new StreamController<List<int>>();
- // We only need to implement the listener as there is no way to provide
- // back pressure into the channel.
- controller.onListen = () {
- // Once there is a listener, we kick off the loading of the resource.
- readAsBytes().then((value) {
- // The resource loading implementation sends all of the data in a
- // single message. So the stream will only get a single value posted.
- controller.add(value);
- controller.close();
- },
- onError: (e, s) {
- // In case the future terminates with an error we propagate it to the
- // stream.
- controller.addError(e, s);
- controller.close();
- });
- };
-
- return controller.stream;
- }
-
- Future<List<int>> readAsBytes() {
- if (VMLibraryHooks.resourceReadAsBytes == null) {
- throw new UnimplementedError("readAsBytes");
- }
-
- return VMLibraryHooks.resourceReadAsBytes(this.uri);
- }
-
- Future<String> readAsString({Encoding encoding : UTF8}) {
- if (VMLibraryHooks.resourceReadAsBytes == null) {
- throw new UnimplementedError("readAsString");
- }
-
- var completer = new Completer<String>();
-
- readAsBytes().then((bytes) {
- var str = encoding.decode(bytes);
- completer.complete(str);
- },
- onError: (e, s) {
- completer.completeError(e,s);
- });
-
- return completer.future;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698