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

Unified Diff: lib/isolate/timer.dart

Issue 10828410: Unify dart:isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix mapping to dart:isolate. Created 8 years, 4 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
« no previous file with comments | « lib/isolate/serialization.dart ('k') | lib/isolate/timer_hook.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate/timer.dart
diff --git a/lib/isolate/timer.dart b/lib/isolate/timer.dart
index 95de18eb3b1c12b064f689f8e96bdcb95d2a8cc0..76f98a1c2cd610ed00ffdbb84d6a6c1b65be3363 100644
--- a/lib/isolate/timer.dart
+++ b/lib/isolate/timer.dart
@@ -20,3 +20,34 @@ interface Timer default _TimerFactory {
*/
void cancel();
}
+
+// TODO(ajohnsen): Patch timer once we have support for patching named
+// factory constructors in the VM.
+
+typedef Timer _TimerFactoryClosure(int milliSeconds,
+ void callback(Timer timer),
+ bool repeating);
+
+// _TimerFactory provides a hook which allows various implementations of this
+// library to provide a concrete class for the Timer interface.
+class _TimerFactory {
+ factory Timer(int milliSeconds, void callback(Timer timer)) {
+ if (_factory == null) {
+ throw new UnsupportedOperationException("Timer interface not supported.");
+ }
+ return _factory(milliSeconds, callback, false);
+ }
+
+ factory Timer.repeating(int milliSeconds, void callback(Timer timer)) {
+ if (_factory == null) {
+ throw new UnsupportedOperationException("Timer interface not supported.");
+ }
+ return _factory(milliSeconds, callback, true);
+ }
+
+ static _TimerFactoryClosure _factory;
+}
+
+void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
+ _TimerFactory._factory = closure;
+}
« no previous file with comments | « lib/isolate/serialization.dart ('k') | lib/isolate/timer_hook.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698