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

Side by Side Diff: sdk/lib/_internal/lib/async_patch.dart

Issue 15764003: Add Zone support for Timers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload Created 7 years, 6 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | sdk/lib/async/event_loop.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 file for the dart:async library. 5 // Patch file for the dart:async library.
6 6
7 import 'dart:_isolate_helper' show IsolateNatives, TimerImpl; 7 import 'dart:_isolate_helper' show IsolateNatives, TimerImpl;
8 import 'dart:_foreign_helper' show JS, DART_CLOSURE_TO_JS; 8 import 'dart:_foreign_helper' show JS, DART_CLOSURE_TO_JS;
9 9
10 patch class Timer { 10 patch Timer _createTimer(Duration duration, void callback()) {
11 patch factory Timer(Duration duration, void callback()) { 11 int milliseconds = duration.inMilliseconds;
12 int milliseconds = duration.inMilliseconds; 12 if (milliseconds < 0) milliseconds = 0;
13 if (milliseconds < 0) milliseconds = 0; 13 return new TimerImpl(milliseconds, callback);
14 return new TimerImpl(milliseconds, callback); 14 }
15 }
16 15
17 patch factory Timer.periodic(Duration duration, void callback(Timer timer)) { 16 patch Timer _createPeriodicTimer(Duration duration,
18 int milliseconds = duration.inMilliseconds; 17 void callback(Timer timer)) {
19 if (milliseconds < 0) milliseconds = 0; 18 int milliseconds = duration.inMilliseconds;
20 return new TimerImpl.periodic(milliseconds, callback); 19 if (milliseconds < 0) milliseconds = 0;
21 } 20 return new TimerImpl.periodic(milliseconds, callback);
22 } 21 }
23 22
24 patch class _AsyncRun { 23 patch class _AsyncRun {
25 patch static void _enqueueImmediate(void callback()) { 24 patch static void _enqueueImmediate(void callback()) {
26 // TODO(9002): don't use the Timer to enqueue the immediate callback. 25 // TODO(9002): don't use the Timer to enqueue the immediate callback.
27 Timer.run(callback); 26 _createTimer(Duration.ZERO, callback);
28 } 27 }
29 } 28 }
30 29
31 patch class DeferredLibrary { 30 patch class DeferredLibrary {
32 patch Future<bool> load() { 31 patch Future<bool> load() {
33 return _load(libraryName, uri); 32 return _load(libraryName, uri);
34 } 33 }
35 } 34 }
36 35
37 // TODO(ahe): This should not only apply to this isolate. 36 // TODO(ahe): This should not only apply to this isolate.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return completer.future; 75 return completer.future;
77 } 76 }
78 77
79 /// Used to implement deferred loading. Used as callback on "load" 78 /// Used to implement deferred loading. Used as callback on "load"
80 /// event above in [load]. 79 /// event above in [load].
81 _onDeferredLibraryLoad(Completer<bool> completer, event) { 80 _onDeferredLibraryLoad(Completer<bool> completer, event) {
82 completer.complete(true); 81 completer.complete(true);
83 } 82 }
84 83
85 bool get _hasDocument => JS('String', 'typeof document') == 'object'; 84 bool get _hasDocument => JS('String', 'typeof document') == 'object';
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | sdk/lib/async/event_loop.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698