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

Unified Diff: runtime/bin/process_patch.dart

Issue 307503002: Add processes to Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/service_object_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_patch.dart
diff --git a/runtime/bin/process_patch.dart b/runtime/bin/process_patch.dart
index 970bb659a2caeb592fab6552d14f104c96902140..c1f483ea088eae34102aa52101219600f0a117d8 100644
--- a/runtime/bin/process_patch.dart
+++ b/runtime/bin/process_patch.dart
@@ -157,13 +157,22 @@ class _ProcessStartStatus {
}
-class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
+// The NativeFieldWrapperClass1 can not be used with a mixin, due to missing
+// implicit constructor.
+class _ProcessImplNativeWrapper extends NativeFieldWrapperClass1 {}
+
+class _ProcessImpl extends _ProcessImplNativeWrapper with _ServiceObject
+ implements Process {
+ // Use default Map so we keep order.
+ static Map<int, _ProcessImpl> _processes = new Map<int, _ProcessImpl>();
+
_ProcessImpl(String path,
List<String> arguments,
String this._workingDirectory,
Map<String, String> environment,
bool includeParentEnvironment,
- bool runInShell) {
+ bool runInShell) : super() {
+ _processes[_serviceId] = this;
if (runInShell) {
arguments = _getShellArguments(path, arguments);
path = _getShellCommand();
@@ -230,6 +239,29 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
_started = false;
}
+ String get _serviceTypePath => 'io/processes';
+ String get _serviceTypeName => 'Process';
+
+ Map _toJSON(bool ref) {
+ var r = {
+ 'id': _servicePath,
+ 'type': _serviceType(ref),
+ 'name': '$_path',
+ 'user_name': '$_path',
+ 'pid': '$pid',
+ 'arguments': _arguments.join(' '),
+ };
+ if (ref) {
+ return r;
+ }
+ r['started'] = _started;
+ r['ended'] = _ended;
+ r['path'] = _path;
+ r['environment'] = _environment;
+ r['workingDirectory'] = _workingDirectory == null ? '.' : _workingDirectory;
+ return r;
+ }
+
static String _getShellCommand() {
if (Platform.isWindows) {
return 'cmd.exe';
@@ -338,11 +370,6 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
status._errorCode));
return;
}
- // Reset values which are no longer needed.
- _path = null;
- _arguments = null;
- _workingDirectory = null;
- _environment = null;
_started = true;
@@ -365,6 +392,7 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
_exitCode.complete(exitCode(exitDataBuffer));
// Kill stdin, helping hand if the user forgot to do it.
_stdin._sink.destroy();
+ _processes.remove(_serviceId);
}
exitDataBuffer.setRange(exitDataRead, exitDataRead + data.length, data);
@@ -397,11 +425,6 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
status._errorMessage,
status._errorCode);
}
- // Reset values which are no longer needed.
- _path = null;
- _arguments = null;
- _workingDirectory = null;
- _environment = null;
var result = _wait(
_stdin._sink._nativeSocket,
« no previous file with comments | « no previous file | runtime/bin/service_object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698