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

Side by Side Diff: runtime/bin/service_object_patch.dart

Issue 300883002: Add Proces owner of socket and fix printing of non-network sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 final Map _servicePathMap = { 6 final Map _servicePathMap = {
7 'http' : { 7 'http' : {
8 'servers' : _httpServersServiceObject, 8 'servers' : _httpServersServiceObject,
9 }, 9 },
10 'sockets' : _socketsServiceObject, 10 'sockets' : _socketsServiceObject,
11 'websockets' : _webSocketsServiceObject, 11 'websockets' : _webSocketsServiceObject,
12 'file' : { 12 'file' : {
13 'randomaccessfiles' : _randomAccessFilesServiceObject 13 'randomaccessfiles' : _randomAccessFilesServiceObject
14 }, 14 },
15 'processes' : _processesServiceObject, 15 'processes' : _processesServiceObject,
16 }; 16 };
17 17
18 String _serviceObjectHandler(List<String> paths, 18 String _serviceObjectHandler(List<String> paths,
19 List<String> keys, 19 List<String> keys,
20 List<String> values) { 20 List<String> values) {
21 assert(keys.length == values.length); 21 assert(keys.length == values.length);
22 badPath() {
23 throw "Invalid path '${paths.join("/")}'";
24 }
25 if (paths.isEmpty) { 22 if (paths.isEmpty) {
26 return JSON.encode(_ioServiceObject()); 23 return JSON.encode(_ioServiceObject());
27 } 24 }
28 int i = 0; 25 int i = 0;
29 var current = _servicePathMap; 26 var current = _servicePathMap;
30 do { 27 do {
31 current = current[paths[i]]; 28 current = current[paths[i]];
32 i++; 29 i++;
33 } while (i < paths.length && current is Map); 30 } while (i < paths.length && current is Map);
34 if (current is! Function) { 31 if (current is! Function) {
35 badPath(); 32 return JSON.encode(_makeServiceError('Unrecognized path'));
36 } 33 }
37 var query = new Map(); 34 var query = new Map();
38 for (int i = 0; i < keys.length; i++) { 35 for (int i = 0; i < keys.length; i++) {
39 query[keys[i]] = values[i]; 36 query[keys[i]] = values[i];
40 } 37 }
41 return JSON.encode(current(paths.sublist(i))); 38 return JSON.encode(current(paths.sublist(i)));
42 } 39 }
43 40
41 Map _makeServiceError(String message, [String kind]) {
42 var error = {
43 'type': 'Error',
44 'id': '',
45 'message': message,
46 };
47 if (kind != null) {
48 error['kind'] = kind;
49 }
50 return error;
51 }
52
44 Map _ioServiceObject() { 53 Map _ioServiceObject() {
45 return { 54 return {
46 'id': 'io', 55 'id': 'io',
47 'type': 'IO', 56 'type': 'IO',
48 'name': 'io', 57 'name': 'io',
49 'user_name': 'io', 58 'user_name': 'io',
50 }; 59 };
51 } 60 }
52 61
53 Map _httpServersServiceObject(args) { 62 Map _httpServersServiceObject(args) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 131 }
123 return process._toJSON(false); 132 return process._toJSON(false);
124 } 133 }
125 return { 134 return {
126 'id': 'io/processes', 135 'id': 'io/processes',
127 'type': 'ProcessList', 136 'type': 'ProcessList',
128 'members': _ProcessImpl._processes.values 137 'members': _ProcessImpl._processes.values
129 .map((p) => p._toJSON(true)).toList(), 138 .map((p) => p._toJSON(true)).toList(),
130 }; 139 };
131 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698