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

Side by Side Diff: sdk/lib/async/stream_impl.dart

Issue 104543002: Change the zone that late-added stream subscription callbacks are registered in. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests Created 7 years 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 | tests/lib/async/stream_listen_zone_test.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 part of dart.async; 5 part of dart.async;
6 6
7 /** Abstract and private interface for a place to put events. */ 7 /** Abstract and private interface for a place to put events. */
8 abstract class _EventSink<T> { 8 abstract class _EventSink<T> {
9 void _add(T data); 9 void _add(T data);
10 void _addError(Object error, StackTrace stackTrace); 10 void _addError(Object error, StackTrace stackTrace);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 assert(_isCanceled); 137 assert(_isCanceled);
138 _PendingEvents events = _pending; 138 _PendingEvents events = _pending;
139 _pending = null; 139 _pending = null;
140 return events; 140 return events;
141 } 141 }
142 142
143 // StreamSubscription interface. 143 // StreamSubscription interface.
144 144
145 void onData(void handleData(T event)) { 145 void onData(void handleData(T event)) {
146 if (handleData == null) handleData = _nullDataHandler; 146 if (handleData == null) handleData = _nullDataHandler;
147 _onData = Zone.current.registerUnaryCallback(handleData); 147 _onData = _zone.registerUnaryCallback(handleData);
148 } 148 }
149 149
150 void onError(Function handleError) { 150 void onError(Function handleError) {
151 if (handleError == null) handleError = _nullErrorHandler; 151 if (handleError == null) handleError = _nullErrorHandler;
152 _onError = _registerErrorHandler(handleError, Zone.current); 152 _onError = _registerErrorHandler(handleError, _zone);
153 } 153 }
154 154
155 void onDone(void handleDone()) { 155 void onDone(void handleDone()) {
156 if (handleDone == null) handleDone = _nullDoneHandler; 156 if (handleDone == null) handleDone = _nullDoneHandler;
157 _onDone = Zone.current.registerCallback(handleDone); 157 _onDone = _zone.registerCallback(handleDone);
158 } 158 }
159 159
160 void pause([Future resumeSignal]) { 160 void pause([Future resumeSignal]) {
161 if (_isCanceled) return; 161 if (_isCanceled) return;
162 bool wasPaused = _isPaused; 162 bool wasPaused = _isPaused;
163 bool wasInputPaused = _isInputPaused; 163 bool wasInputPaused = _isInputPaused;
164 // Increment pause count and mark input paused (if it isn't already). 164 // Increment pause count and mark input paused (if it isn't already).
165 _state = (_state + _STATE_PAUSE_COUNT) | _STATE_INPUT_PAUSED; 165 _state = (_state + _STATE_PAUSE_COUNT) | _STATE_INPUT_PAUSED;
166 if (resumeSignal != null) resumeSignal.whenComplete(resume); 166 if (resumeSignal != null) resumeSignal.whenComplete(resume);
167 if (!wasPaused && _pending != null) _pending.cancelSchedule(); 167 if (!wasPaused && _pending != null) _pending.cancelSchedule();
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 _Future<bool> hasNext = _futureOrPrefetch; 1028 _Future<bool> hasNext = _futureOrPrefetch;
1029 _clear(); 1029 _clear();
1030 hasNext._complete(false); 1030 hasNext._complete(false);
1031 return; 1031 return;
1032 } 1032 }
1033 _subscription.pause(); 1033 _subscription.pause();
1034 _futureOrPrefetch = null; 1034 _futureOrPrefetch = null;
1035 _state = _STATE_EXTRA_DONE; 1035 _state = _STATE_EXTRA_DONE;
1036 } 1036 }
1037 } 1037 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/async/stream_listen_zone_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698