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

Side by Side Diff: runtime/lib/timer_patch.dart

Issue 12793003: Rename Timer.repeating to Timer.periodic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class Timer { 5 patch class Timer {
6 /* patch */ factory Timer(Duration duration, void callback()) { 6 /* patch */ factory Timer(Duration duration, void callback()) {
7 if (_TimerFactory._factory == null) { 7 if (_TimerFactory._factory == null) {
8 throw new UnsupportedError("Timer interface not supported."); 8 throw new UnsupportedError("Timer interface not supported.");
9 } 9 }
10 int milliseconds = duration.inMilliseconds; 10 int milliseconds = duration.inMilliseconds;
11 if (milliseconds < 0) milliseconds = 0; 11 if (milliseconds < 0) milliseconds = 0;
12 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false); 12 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
13 } 13 }
14 14
15 /* patch */ factory Timer.repeating(Duration duration, 15 /* patch */ factory Timer.periodic(Duration duration,
16 void callback(Timer timer)) { 16 void callback(Timer timer)) {
17 if (_TimerFactory._factory == null) { 17 if (_TimerFactory._factory == null) {
18 throw new UnsupportedError("Timer interface not supported."); 18 throw new UnsupportedError("Timer interface not supported.");
19 } 19 }
20 int milliseconds = duration.inMilliseconds; 20 int milliseconds = duration.inMilliseconds;
21 if (milliseconds < 0) milliseconds = 0; 21 if (milliseconds < 0) milliseconds = 0;
22 return _TimerFactory._factory(milliseconds, callback, true); 22 return _TimerFactory._factory(milliseconds, callback, true);
23 } 23 }
24 } 24 }
25 25
26 typedef Timer _TimerFactoryClosure(int milliseconds, 26 typedef Timer _TimerFactoryClosure(int milliseconds,
27 void callback(Timer timer), 27 void callback(Timer timer),
28 bool repeating); 28 bool repeating);
29 29
30 class _TimerFactory { 30 class _TimerFactory {
31 static _TimerFactoryClosure _factory; 31 static _TimerFactoryClosure _factory;
32 } 32 }
33 33
34 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets 34 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets
35 // [_TimerFactory._factory] directly. 35 // [_TimerFactory._factory] directly.
36 void _setTimerFactoryClosure(_TimerFactoryClosure closure) { 36 void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
37 _TimerFactory._factory = closure; 37 _TimerFactory._factory = closure;
38 } 38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698