Index: sdk/lib/developer/extension.dart |
diff --git a/sdk/lib/developer/extension.dart b/sdk/lib/developer/extension.dart |
index 05eeae7d855e48e422e47c8a9a5e212d44eed30c..93ff9d8e905c32462d7b568a4823c75acf156679 100644 |
--- a/sdk/lib/developer/extension.dart |
+++ b/sdk/lib/developer/extension.dart |
@@ -112,80 +112,3 @@ void registerExtension(String method, ServiceExtensionHandler handler) { |
// LookupServiceExtensionHandler and RegisterServiceExtensionHandler. |
external ServiceExtensionHandler _lookupExtension(String method); |
external _registerExtension(String method, ServiceExtensionHandler handler); |
- |
-// This code is only invoked when there is no other Dart code on the stack. |
-_runExtension(ServiceExtensionHandler handler, |
- String method, |
- List<String> parameterKeys, |
- List<String> parameterValues, |
- SendPort replyPort, |
- Object id) { |
- var parameters = {}; |
- for (var i = 0; i < parameterKeys.length; i++) { |
- parameters[parameterKeys[i]] = parameterValues[i]; |
- } |
- var response; |
- try { |
- response = handler(method, parameters); |
- } catch (e, st) { |
- var errorDetails = (st == null) ? '$e' : '$e\n$st'; |
- response = new ServiceExtensionResponse.error( |
- ServiceExtensionResponse.kExtensionError, |
- errorDetails); |
- _postResponse(replyPort, id, response); |
- return; |
- } |
- if (response is! Future) { |
- response = new ServiceExtensionResponse.error( |
- ServiceExtensionResponse.kExtensionError, |
- "Extension handler must return a Future"); |
- _postResponse(replyPort, id, response); |
- return; |
- } |
- response.catchError((e, st) { |
- // Catch any errors eagerly and wrap them in a ServiceExtensionResponse. |
- var errorDetails = (st == null) ? '$e' : '$e\n$st'; |
- return new ServiceExtensionResponse.error( |
- ServiceExtensionResponse.kExtensionError, |
- errorDetails); |
- }).then((response) { |
- // Post the valid response or the wrapped error after verifying that |
- // the response is a ServiceExtensionResponse. |
- if (response is! ServiceExtensionResponse) { |
- response = new ServiceExtensionResponse.error( |
- ServiceExtensionResponse.kExtensionError, |
- "Extension handler must complete to a ServiceExtensionResponse"); |
- } |
- _postResponse(replyPort, id, response); |
- }).catchError((e, st) { |
- // We do not expect any errors to occur in the .then or .catchError blocks |
- // but, suppress them just in case. |
- }); |
-} |
- |
-// This code is only invoked by _runExtension. |
-_postResponse(SendPort replyPort, |
- Object id, |
- ServiceExtensionResponse response) { |
- assert(replyPort != null); |
- if (id == null) { |
- // No id -> no response. |
- replyPort.send(null); |
- return; |
- } |
- assert(id != null); |
- StringBuffer sb = new StringBuffer(); |
- sb.write('{"jsonrpc":"2.0",'); |
- if (response._isError()) { |
- sb.write('"error":'); |
- } else { |
- sb.write('"result":'); |
- } |
- sb.write('${response._toString()},'); |
- if (id is String) { |
- sb.write('"id":"$id"}'); |
- } else { |
- sb.write('"id":$id}'); |
- } |
- replyPort.send(sb.toString()); |
-} |