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

Side by Side Diff: tools/dom/src/Microtask.dart

Issue 25925002: Fix Microtask.dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 part of html; 5 part of html;
6 6
7 typedef void _MicrotaskCallback(); 7 typedef void _MicrotaskCallback();
8 8
9 /** 9 /**
10 * This class attempts to invoke a callback as soon as the current event stack 10 * This class attempts to invoke a callback as soon as the current event stack
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 _nextMicrotaskFrameScheduled = false; 55 _nextMicrotaskFrameScheduled = false;
56 this._callback(); 56 this._callback();
57 } 57 }
58 } 58 }
59 59
60 /** 60 /**
61 * Scheduler which uses window.postMessage to schedule events. 61 * Scheduler which uses window.postMessage to schedule events.
62 */ 62 */
63 class _PostMessageScheduler extends _MicrotaskScheduler { 63 class _PostMessageScheduler extends _MicrotaskScheduler {
64 const _MICROTASK_MESSAGE = "DART-MICROTASK"; 64 final _MICROTASK_MESSAGE = "DART-MICROTASK";
65 65
66 _PostMessageScheduler(_MicrotaskCallback callback): super(callback) { 66 _PostMessageScheduler(_MicrotaskCallback callback): super(callback) {
67 // Messages from other windows do not cause a security risk as 67 // Messages from other windows do not cause a security risk as
68 // all we care about is that _handleMessage is called 68 // all we care about is that _handleMessage is called
69 // after the current event loop is unwound and calling the function is 69 // after the current event loop is unwound and calling the function is
70 // a noop when zero requests are pending. 70 // a noop when zero requests are pending.
71 window.onMessage.listen(this._handleMessage); 71 window.onMessage.listen(this._handleMessage);
72 } 72 }
73 73
74 void _schedule() { 74 void _schedule() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 /** 147 /**
148 * Complete all pending microtasks. 148 * Complete all pending microtasks.
149 */ 149 */
150 void _completeMicrotasks() { 150 void _completeMicrotasks() {
151 var callbacks = _pendingMicrotasks; 151 var callbacks = _pendingMicrotasks;
152 _pendingMicrotasks = null; 152 _pendingMicrotasks = null;
153 for (var callback in callbacks) { 153 for (var callback in callbacks) {
154 callback(); 154 callback();
155 } 155 }
156 } 156 }
OLDNEW
« 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