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

Side by Side Diff: tools/dom/src/native_DOMPublic.dart

Issue 12887009: Support asynchronuous spawnDomFunction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of html; 5 part of html;
6 6
7 // This API is exploratory. 7 // This API is exploratory.
8 spawnDomFunction(Function topLevelFunction) => _Utils.spawnDomFunctionImpl(topLe velFunction); 8 Future<SendPort> spawnDomFunction(Function topLevelFunction) {
9 final completer = new Completer<SendPort>();
10 final port = new ReceivePort();
11 port.receive((result, _) {
12 completer.complete(result);
13 port.close();
14 });
15 // TODO: SendPort.hashCode is ugly way to access port id.
16 _Utils.spawnDomFunction(topLevelFunction, port.toSendPort().hashCode);
vsm 2013/03/26 19:13:37 Yuck... Is a Handle -> Port API coming in the VM?
Anton Muhin 2013/03/26 19:15:37 Absolutely w/ you here, I've already asked Siva to
17 return completer.future;
18 }
9 19
10 // testRunner implementation. 20 // testRunner implementation.
11 // FIXME: provide a separate lib for testRunner. 21 // FIXME: provide a separate lib for testRunner.
12 22
13 var _testRunner; 23 var _testRunner;
14 24
15 TestRunner get testRunner { 25 TestRunner get testRunner {
16 if (_testRunner == null) 26 if (_testRunner == null)
17 _testRunner = new TestRunner._(_NPObject.retrieve("testRunner")); 27 _testRunner = new TestRunner._(_NPObject.retrieve("testRunner"));
18 return _testRunner; 28 return _testRunner;
19 } 29 }
20 30
21 class TestRunner { 31 class TestRunner {
22 final _NPObject _npObject; 32 final _NPObject _npObject;
23 33
24 TestRunner._(this._npObject); 34 TestRunner._(this._npObject);
25 35
26 display() => _npObject.invoke('display'); 36 display() => _npObject.invoke('display');
27 dumpAsText() => _npObject.invoke('dumpAsText'); 37 dumpAsText() => _npObject.invoke('dumpAsText');
28 notifyDone() => _npObject.invoke('notifyDone'); 38 notifyDone() => _npObject.invoke('notifyDone');
29 setCanOpenWindows() => _npObject.invoke('setCanOpenWindows'); 39 setCanOpenWindows() => _npObject.invoke('setCanOpenWindows');
30 waitUntilDone() => _npObject.invoke('waitUntilDone'); 40 waitUntilDone() => _npObject.invoke('waitUntilDone');
31 } 41 }
OLDNEW
« samples/isolate_html/isolate_sample.dart ('K') | « tools/dom/src/native_DOMImplementation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698