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

Unified Diff: dart/lib/isolate/timer.dart

Issue 11098069: Remove Timer factory class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698