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

Unified Diff: runtime/bin/process_impl.dart

Issue 11091070: Change Process.start to return a future that completes with a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index 47ccd8d8ff386aad0014c91a082ef125a392ca57..0e33800064e516f9ac454bae2722232cd7515a80 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -14,12 +14,26 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
static Future<ProcessResult> run(String path,
List<String> arguments,
[ProcessOptions options]) {
- return new _NonInteractiveProcess._start(path, arguments, options)._result;
+ return new _NonInteractiveProcess(path, arguments, options)._result;
}
- _Process.start(String path,
- List<String> arguments,
- ProcessOptions options) {
+ static Future<Process> start(String path,
+ List<String> arguments,
+ ProcessOptions options) {
+ Completer completer = new Completer();
+ _Process process = new _Process(path, arguments, options);
+ process._onStart = () {
+ process.onError = null;
+ completer.complete(process);
+ };
+ process.onError = (e) {
+ process.onError = null;
+ completer.completeException(e);
+ };
+ return completer.future;
+ }
+
+ _Process(String path, List<String> arguments, ProcessOptions options) {
if (path is !String) {
throw new ArgumentError("Path is not a String: $path");
}
@@ -269,10 +283,6 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
_onError = callback;
}
- void set onStart(void callback()) {
- _onStart = callback;
- }
-
void _reportError(e) {
if (_onError != null) {
_onError(e);
@@ -304,9 +314,9 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
// _NonInteractiveProcess is used to implement the Process.run
// method.
class _NonInteractiveProcess {
- _NonInteractiveProcess._start(String path,
- List<String> arguments,
- ProcessOptions options) {
+ _NonInteractiveProcess(String path,
+ List<String> arguments,
+ ProcessOptions options) {
_completer = new Completer<ProcessResult>();
// Extract output encoding options and verify arguments.
var stdoutEncoding = Encoding.UTF_8;
@@ -329,10 +339,10 @@ class _NonInteractiveProcess {
}
// Start the underlying process.
- _process = new _Process.start(path, arguments, options);
+ _process = new _Process(path, arguments, options);
// Make sure stdin is closed.
- _process.onStart = _process.stdin.close;
+ _process._onStart = _process.stdin.close;
// Setup process error handling.
_process.onError = (e) => _completer.completeException(e);

Powered by Google App Engine
This is Rietveld 408576698