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

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

Issue 2230383003: Implement @patch annotation for patch class members (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: wip Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/lib/symbol_patch.dart ('k') | runtime/lib/uri_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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*/ static Timer _createTimer(Duration duration, void callback()) { 6 @patch static Timer _createTimer(Duration duration, void callback()) {
7 // TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively. 7 // TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively.
8 if (_TimerFactory._factory == null) { 8 if (_TimerFactory._factory == null) {
9 _TimerFactory._factory = VMLibraryHooks.timerFactory; 9 _TimerFactory._factory = VMLibraryHooks.timerFactory;
10 } 10 }
11 if (_TimerFactory._factory == null) { 11 if (_TimerFactory._factory == null) {
12 throw new UnsupportedError("Timer interface not supported."); 12 throw new UnsupportedError("Timer interface not supported.");
13 } 13 }
14 int milliseconds = duration.inMilliseconds; 14 int milliseconds = duration.inMilliseconds;
15 if (milliseconds < 0) milliseconds = 0; 15 if (milliseconds < 0) milliseconds = 0;
16 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false); 16 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
17 } 17 }
18 18
19 /*@patch*/ static Timer _createPeriodicTimer(Duration duration, 19 @patch static Timer _createPeriodicTimer(Duration duration,
20 void callback(Timer timer)) { 20 void callback(Timer timer)) {
21 // TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively. 21 // TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively.
22 if (_TimerFactory._factory == null) { 22 if (_TimerFactory._factory == null) {
23 _TimerFactory._factory = VMLibraryHooks.timerFactory; 23 _TimerFactory._factory = VMLibraryHooks.timerFactory;
24 } 24 }
25 if (_TimerFactory._factory == null) { 25 if (_TimerFactory._factory == null) {
26 throw new UnsupportedError("Timer interface not supported."); 26 throw new UnsupportedError("Timer interface not supported.");
27 } 27 }
28 int milliseconds = duration.inMilliseconds; 28 int milliseconds = duration.inMilliseconds;
29 if (milliseconds < 0) milliseconds = 0; 29 if (milliseconds < 0) milliseconds = 0;
30 return _TimerFactory._factory(milliseconds, callback, true); 30 return _TimerFactory._factory(milliseconds, callback, true);
31 } 31 }
32 } 32 }
33 33
34 typedef Timer _TimerFactoryClosure(int milliseconds, 34 typedef Timer _TimerFactoryClosure(int milliseconds,
35 void callback(Timer timer), 35 void callback(Timer timer),
36 bool repeating); 36 bool repeating);
37 37
38 // Warning: Dartium sets _TimerFactory._factory instead of setting things up 38 // Warning: Dartium sets _TimerFactory._factory instead of setting things up
39 // through VMLibraryHooks.timerFactory. 39 // through VMLibraryHooks.timerFactory.
40 class _TimerFactory { 40 class _TimerFactory {
41 static _TimerFactoryClosure _factory; 41 static _TimerFactoryClosure _factory;
42 } 42 }
OLDNEW
« no previous file with comments | « runtime/lib/symbol_patch.dart ('k') | runtime/lib/uri_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698