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

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

Issue 293013008: Add missing files. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/io/service_object.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5
6 final Map _servicePathMap = {
7 'http' : {
8 'servers' : _httpServersServiceObject
9 }
10 };
11
12 String _serviceObjectHandler(List<String> paths,
13 List<String> keys,
14 List<String> values) {
15 assert(keys.length == values.length);
16 badPath() {
17 throw "Invalid path '${paths.join("/")}'";
18 }
19 if (paths.isEmpty) {
20 badPath();
21 }
22 int i = 0;
23 var current = _servicePathMap;
24 do {
25 current = current[paths[i]];
26 i++;
27 } while (i < paths.length && current is Map);
28 if (current is! Function) {
29 badPath();
30 }
31 var query = new Map();
32 for (int i = 0; i < keys.length; i++) {
33 query[keys[i]] = values[i];
34 }
35 return JSON.encode(current(paths.sublist(i)));
36 }
37
38 Map _httpServersServiceObject(args) {
39 if (args.length == 1) {
40 var server = _HttpServer._servers[int.parse(args.first)];
41 if (server == null) {
42 return {};
43 }
44 return server._toJSON(false);
45 }
46 return {
47 'id': 'io/http/servers',
48 'type': 'HttpServerList',
49 'members': _HttpServer._servers.values
50 .map((server) => server._toJSON(true)).toList(),
51 };
52 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/service_object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698