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

Unified Diff: lib/isolate/frog/isolateimpl.dart

Issue 9677019: Enable isolate tests with leg and legium. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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:
View side-by-side diff with in-line comments
Download patch
Index: lib/isolate/frog/isolateimpl.dart
===================================================================
--- lib/isolate/frog/isolateimpl.dart (revision 5352)
+++ lib/isolate/frog/isolateimpl.dart (working copy)
@@ -197,6 +197,16 @@
}
}
+// We don't want to import the DOM library just because of window.setTimeout,
+// so we reconstruct the Window class here. The only conflict that could happen
+// with the other DOMWindow class would be because of subclasses.
+// Currently, none of the two Dart classes have subclasses.
ngeoffray 2012/03/12 23:18:36 This is more of a cleanup than a hack IMO. Siggi,
Siggi Cherem (dart-lang) 2012/03/12 23:40:58 looks good to me. I'm working on adding Timer to c
ngeoffray 2012/03/13 12:51:37 Sounds good.
Siggi Cherem (dart-lang) 2012/03/14 23:23:12 It would be supported standalone in the VM, but no
ngeoffray 2012/03/15 09:30:56 Oh I see. So I guess you want to throw a runtime e
+typedef void _TimeoutHandler();
+class _Window native "@*DOMWindow" {
+ int setTimeout(_TimeoutHandler handler, int timeout) native;
Siggi Cherem (dart-lang) 2012/03/12 23:40:58 is this _TimeoutHandler needed, or can we simply d
ngeoffray 2012/03/13 12:51:37 Leg does not handle function type parameters very
Siggi Cherem (dart-lang) 2012/03/14 23:23:12 good to know. Thx.
+}
+_Window get _window() native
+ """return typeof window != 'undefined' ? window : (void 0);""";
/** Represent the event loop on a javascript thread (DOM or worker). */
class _EventLoop {
@@ -224,23 +234,16 @@
return true;
}
- /** Function equivalent to [:window.setTimeout:] when available, or null. */
- static Function _wrapSetTimeout() native """
- return typeof window != 'undefined' ?
- function(a, b) { window.setTimeout(a, b); } : undefined;
- """;
-
/**
* Runs multiple iterations of the run-loop. If possible, each iteration is
* run asynchronously.
*/
void _runHelper() {
- final setTimeout = _wrapSetTimeout();
- if (setTimeout != null) {
+ if (_window != null) {
// Run each iteration from the browser's top event loop.
void next() {
if (!runIteration()) return;
- setTimeout(next, 0);
+ _window.setTimeout(next, 0);
}
next();
} else {

Powered by Google App Engine
This is Rietveld 408576698