Index: tools/dom/src/native_DOMPublic.dart |
diff --git a/tools/dom/src/native_DOMPublic.dart b/tools/dom/src/native_DOMPublic.dart |
index 5044945387b2bc1a40465d218c35733f44ec656a..4034d9165ebd438dde081c59beb1ab02a7f384de 100644 |
--- a/tools/dom/src/native_DOMPublic.dart |
+++ b/tools/dom/src/native_DOMPublic.dart |
@@ -4,8 +4,7 @@ |
part of html; |
-// This API is exploratory. |
-Future<SendPort> spawnDomFunction(Function topLevelFunction) { |
+_makeSendPortFuture(spawnRequest) { |
final completer = new Completer<SendPort>(); |
final port = new ReceivePort(); |
port.receive((result, _) { |
@@ -13,10 +12,17 @@ Future<SendPort> spawnDomFunction(Function topLevelFunction) { |
port.close(); |
}); |
// TODO: SendPort.hashCode is ugly way to access port id. |
- _Utils.spawnDomFunction(topLevelFunction, port.toSendPort().hashCode); |
+ spawnRequest(port.toSendPort().hashCode); |
return completer.future; |
} |
+// This API is exploratory. |
+Future<SendPort> spawnDomFunction(Function f) => |
+ _makeSendPortFuture((portId) { _Utils.spawnDomFunction(f, portId); }); |
+ |
+Future<SendPort> spawnDomUri(String uri) => |
+ _makeSendPortFuture((portId) { _Utils.spawnDomUri(uri, portId); }); |
+ |
// testRunner implementation. |
// FIXME: provide a separate lib for testRunner. |