| 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;
|
| +}
|
|
|