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

Unified Diff: runtime/bin/builtin.dart

Issue 983713002: Remove 'dart:io' import in builtin.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « no previous file | runtime/bin/builtin_natives.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index d8c586cb77bea4d29cd2fb153d371dd917538157..86b7fb0445a4292212362c586255ebbf420f0ee7 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -8,78 +8,6 @@ import 'dart:convert';
import 'dart:isolate';
Ivan Posva 2015/03/05 17:58:36 Please make a note here to NOT import dart:io.
Cutch 2015/03/06 00:02:18 Done.
-//////////////////////
-/* Support for loading within the isolate via dart:io */
-import 'dart:io';
-
-// Enable by setting the #define LOAD_VIA_SERVICE_ISOLATE (see dartutils.cc)
-bool _load_via_service_isolate = false;
-
-var _httpClient;
-void _httpGet(int tag,
- Uri uri,
- String libraryUri,
- loadCallback(List<int> data)) {
- if (_httpClient == null) {
- _httpClient = new HttpClient()..maxConnectionsPerHost = 6;
- }
- _httpClient.getUrl(uri)
- .then((HttpClientRequest request) => request.close())
- .then((HttpClientResponse response) {
- var builder = new BytesBuilder(copy: false);
- response.listen(
- builder.add,
- onDone: () {
- if (response.statusCode != 200) {
- var msg = 'Failure getting $uri: '
- '${response.statusCode} ${response.reasonPhrase}';
- _asyncLoadError(tag, uri.toString(), libraryUri, msg);
- }
- loadCallback(builder.takeBytes());
- },
- onError: (error) {
- _asyncLoadError(tag, uri.toString(), libraryUri, error);
- });
- })
- .catchError((error) {
- _asyncLoadError(tag, uri.toString(), libraryUri, error);
- });
- // TODO(floitsch): remove this line. It's just here to push an event on the
- // event loop so that we invoke the scheduled microtasks. Also remove the
- // import of dart:async when this line is not needed anymore.
- Timer.run(() {});
-}
-
-
-void _cleanup() {
- if (_httpClient != null) {
- _httpClient.close();
- _httpClient = null;
- }
-}
-
-_loadDataAsyncDartIO(int tag,
- String uri,
- String libraryUri,
- Uri resourceUri) {
- _startingOneLoadRequest(uri);
- if ((resourceUri.scheme == 'http') || (resourceUri.scheme == 'https')) {
- _httpGet(tag, resourceUri, libraryUri, (data) {
- _loadScript(tag, uri, libraryUri, data);
- });
- } else {
- var sourceFile = new File(resourceUri.toFilePath());
- sourceFile.readAsBytes().then((data) {
- _loadScript(tag, uri, libraryUri, data);
- },
- onError: (e) {
- _asyncLoadError(tag, uri, libraryUri, e);
- });
- }
-}
-
-//////////////////////
-
/* See Dart_LibraryTag in dart_api.h */
const Dart_kScriptTag = null;
const Dart_kImportTag = 0;
@@ -112,7 +40,7 @@ class _Logger {
_getPrintClosure() => _print;
-_getCurrentDirectoryPath() native "Directory_Current";
+_getCurrentDirectoryPath() native "Builtin_GetCurrentDirectory";
// Corelib 'Uri.base' implementation.
Uri _uriBase() {
@@ -120,10 +48,6 @@ Uri _uriBase() {
// on dart:io. This code is the same as:
// return new Uri.file(Directory.current.path + "/");
var result = _getCurrentDirectoryPath();
- if (result is OSError) {
- throw new FileSystemException(
- "Getting current working directory failed", "", result);
- }
return new Uri.file(result + "/");
}
@@ -316,7 +240,6 @@ void _finishedOneLoadRequest(String uri) {
}
if (_numOutstandingLoadRequests == 0) {
_signalDoneLoading();
- _cleanup();
}
}
@@ -400,12 +323,7 @@ _loadDataAsync(int tag, String uri, String libraryUri) {
Uri resourceUri = _createUri(uri);
- if (_load_via_service_isolate) {
- _loadDataAsyncLoadPort(tag, uri, libraryUri, resourceUri);
- } else {
- _loadDataAsyncDartIO(tag, uri, libraryUri, resourceUri);
- }
-
+ _loadDataAsyncLoadPort(tag, uri, libraryUri, resourceUri);
}
// Returns either a file path or a URI starting with http[s]:, as a String.
« no previous file with comments | « no previous file | runtime/bin/builtin_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698