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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 12887009: Support asynchronuous spawnDomFunction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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:
Download patch
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 9cf898ab378ffc96acaa370448c1230bcccdc1c7..4a8b3b585313f1d168f32b274ec0bd8f56078663 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -36081,7 +36081,17 @@ class _VariableSizeListIterator<T> implements Iterator<T> {
// This API is exploratory.
-spawnDomFunction(Function topLevelFunction) => _Utils.spawnDomFunctionImpl(topLevelFunction);
+Future<SendPort> spawnDomFunction(Function topLevelFunction) {
+ final completer = new Completer<SendPort>();
+ final port = new ReceivePort();
+ port.receive((result, _) {
+ completer.complete(result);
+ port.close();
+ });
+ // TODO: SendPort.hashCode is ugly way to access port id.
+ _Utils.spawnDomFunction(topLevelFunction, port.toSendPort().hashCode);
+ return completer.future;
+}
// testRunner implementation.
// FIXME: provide a separate lib for testRunner.
@@ -36154,7 +36164,7 @@ class _Utils {
static window() native "Utils_window";
static print(String message) native "Utils_print";
static forwardingPrint(String message) native "Utils_forwardingPrint";
- static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_spawnDomFunction";
+ static void spawnDomFunction(Function topLevelFunction, int replyTo) native "Utils_spawnDomFunction";
static int _getNewIsolateId() native "Utils_getNewIsolateId";
static bool shadowRootSupported(Document document) native "Utils_shadowRootSupported";
}

Powered by Google App Engine
This is Rietveld 408576698