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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/io/service_object.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/service_object_patch.dart
diff --git a/runtime/bin/service_object_patch.dart b/runtime/bin/service_object_patch.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f23dd71b472627838b9014dd27fcc7c7e45375a8
--- /dev/null
+++ b/runtime/bin/service_object_patch.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+final Map _servicePathMap = {
+ 'http' : {
+ 'servers' : _httpServersServiceObject
+ }
+};
+
+String _serviceObjectHandler(List<String> paths,
+ List<String> keys,
+ List<String> values) {
+ assert(keys.length == values.length);
+ badPath() {
+ throw "Invalid path '${paths.join("/")}'";
+ }
+ if (paths.isEmpty) {
+ badPath();
+ }
+ int i = 0;
+ var current = _servicePathMap;
+ do {
+ current = current[paths[i]];
+ i++;
+ } while (i < paths.length && current is Map);
+ if (current is! Function) {
+ badPath();
+ }
+ var query = new Map();
+ for (int i = 0; i < keys.length; i++) {
+ query[keys[i]] = values[i];
+ }
+ return JSON.encode(current(paths.sublist(i)));
+}
+
+Map _httpServersServiceObject(args) {
+ if (args.length == 1) {
+ var server = _HttpServer._servers[int.parse(args.first)];
+ if (server == null) {
+ return {};
+ }
+ return server._toJSON(false);
+ }
+ return {
+ 'id': 'io/http/servers',
+ 'type': 'HttpServerList',
+ 'members': _HttpServer._servers.values
+ .map((server) => server._toJSON(true)).toList(),
+ };
+}
« 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