| Index: sdk/lib/_internal/js_runtime/lib/core_patch.dart
|
| diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
|
| index 7d6ad7c244533fc8af009361b01a016c19aae16b..a1d2512c37d1840481b77eae583165311b278d2e 100644
|
| --- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart
|
| +++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
|
| @@ -528,104 +528,3 @@ class Uri {
|
| throw new UnsupportedError("'Uri.base' is not supported");
|
| }
|
| }
|
| -
|
| -@patch
|
| -class Resource {
|
| - @patch
|
| - const factory Resource(String uri) = _Resource;
|
| -}
|
| -
|
| -Uri _resolvePackageUri(Uri packageUri) {
|
| - assert(packageUri.scheme == "package");
|
| - if (packageUri.hasAuthority) {
|
| - throw new ArgumentError("Package-URI must not have a host: $packageUri");
|
| - }
|
| - var resolved = Uri.base.resolve("packages/${packageUri.path}");
|
| - return resolved;
|
| -}
|
| -
|
| -class _Resource implements Resource {
|
| - final String _location;
|
| -
|
| - const _Resource(String uri) : _location = uri;
|
| -
|
| - Uri get uri => Uri.base.resolve(_location);
|
| -
|
| - Stream<List<int>> openRead() {
|
| - Uri uri = this.uri;
|
| - if (uri.scheme == "package") {
|
| - uri = _resolvePackageUri(uri);
|
| - }
|
| - if (uri.scheme == "http" || uri.scheme == "https") {
|
| - return _readAsStream(uri);
|
| - }
|
| - throw new StateError("Unable to find resource, unknown scheme: $_location");
|
| - }
|
| -
|
| - Future<List<int>> readAsBytes() {
|
| - Uri uri = this.uri;
|
| - if (uri.scheme == "package") {
|
| - uri = _resolvePackageUri(uri);
|
| - }
|
| - if (uri.scheme == "http" || uri.scheme == "https") {
|
| - return _readAsBytes(uri);
|
| - }
|
| - throw new StateError("Unable to find resource, unknown scheme: $_location");
|
| - }
|
| -
|
| - Future<String> readAsString({Encoding encoding: UTF8}) {
|
| - Uri uri = this.uri;
|
| - if (uri.scheme == "package") {
|
| - uri = _resolvePackageUri(uri);
|
| - }
|
| - if (uri.scheme == "http" || uri.scheme == "https") {
|
| - return _readAsString(uri, encoding);
|
| - }
|
| - throw new StateError("Unable to find resource, unknown scheme: $_location");
|
| - }
|
| -
|
| - // TODO(het): Use a streaming XHR request instead of returning the entire
|
| - // payload in one event.
|
| - Stream<List<int>> _readAsStream(Uri uri) {
|
| - var controller = new StreamController.broadcast();
|
| - // 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(uri).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(Uri uri) {
|
| - return readHttp('$uri').then((data) {
|
| - if (data is NativeUint8List) return data;
|
| - if (data is String) return data.codeUnits;
|
| - throw new StateError(
|
| - "Unable to read Resource, data could not be decoded");
|
| - });
|
| - }
|
| -
|
| - Future<String> _readAsString(Uri uri, Encoding encoding) {
|
| - return readHttp('$uri').then((data) {
|
| - if (data is String) return data;
|
| - if (data is NativeUint8List) {
|
| - return encoding.decode(data);
|
| - };
|
| - throw new StateError(
|
| - "Unable to read Resource, data could not be decoded");
|
| - });
|
| - }
|
| -}
|
|
|