| Index: dart/lib/isolate/timer.dart
|
| diff --git a/dart/lib/isolate/timer.dart b/dart/lib/isolate/timer.dart
|
| index 76f98a1c2cd610ed00ffdbb84d6a6c1b65be3363..a90c2d000aacb2265752f44bd54354e8ce848316 100644
|
| --- a/dart/lib/isolate/timer.dart
|
| +++ b/dart/lib/isolate/timer.dart
|
| @@ -2,23 +2,35 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -interface Timer default _TimerFactory {
|
| +abstract class Timer {
|
| /**
|
| * Creates a new timer. The [callback] callback is invoked after
|
| * [milliSeconds] milliseconds.
|
| */
|
| - Timer(int milliSeconds, void callback(Timer timer));
|
| + factory Timer(int milliSeconds, void callback(Timer timer)) {
|
| + if (_factory == null) {
|
| + throw new UnsupportedOperationException("Timer interface not supported.");
|
| + }
|
| + return _factory(milliSeconds, callback, false);
|
| + }
|
|
|
| /**
|
| * Creates a new repeating timer. The [callback] is invoked every
|
| * [milliSeconds] millisecond until cancelled.
|
| */
|
| - Timer.repeating(int milliSeconds, void callback(Timer timer));
|
| + factory Timer.repeating(int milliSeconds, void callback(Timer timer)) {
|
| + if (_factory == null) {
|
| + throw new UnsupportedOperationException("Timer interface not supported.");
|
| + }
|
| + return _factory(milliSeconds, callback, true);
|
| + }
|
|
|
| /**
|
| * Cancels the timer.
|
| */
|
| void cancel();
|
| +
|
| + static _TimerFactoryClosure _factory;
|
| }
|
|
|
| // TODO(ajohnsen): Patch timer once we have support for patching named
|
| @@ -28,26 +40,6 @@ 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;
|
| + Timer._factory = closure;
|
| }
|
|
|