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

Side by Side Diff: tools/dom/templates/html/impl/impl_ScriptProcessorNode.darttemplate

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 $LIBRARY; 5 part of $LIBRARY;
6 6
7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$NATIVESPEC { 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$NATIVESPEC {
8 Stream<AudioProcessingEvent> _eventStream; 8 Stream<AudioProcessingEvent> _eventStream;
9 9
10 /** 10 /**
11 * Get a Stream that fires events when AudioProcessingEvents occur. 11 * Get a Stream that fires events when AudioProcessingEvents occur.
12 * This particular stream is special in that it only allows one listener to a 12 * This particular stream is special in that it only allows one listener to a
13 * given stream. Converting the returned Stream [asBroadcast] will likely ruin 13 * given stream. Converting the returned Stream [asBroadcast] will likely ruin
14 * the soft-real-time properties which which these events are fired and can 14 * the soft-real-time properties which which these events are fired and can
15 * be processed. 15 * be processed.
16 */ 16 */
17 Stream<AudioProcessingEvent> get onAudioProcess { 17 Stream<AudioProcessingEvent> get onAudioProcess {
18 if (_eventStream == null) { 18 if (_eventStream == null) {
19 var controller = new StreamController(); 19 var controller = new StreamController(sync: true);
20 var callback = (audioData) { 20 var callback = (audioData) {
21 if (controller.hasListener) { 21 if (controller.hasListener) {
22 // This stream is a strange combination of broadcast and single 22 // This stream is a strange combination of broadcast and single
23 // subscriber streams. We only allow one listener, but if there is 23 // subscriber streams. We only allow one listener, but if there is
24 // no listener, we don't queue up events, we just drop them on the 24 // no listener, we don't queue up events, we just drop them on the
25 // floor. 25 // floor.
26 controller.add(audioData); 26 controller.add(audioData);
27 } 27 }
28 }; 28 };
29 _setEventListener(callback); 29 _setEventListener(callback);
30 _eventStream = controller.stream; 30 _eventStream = controller.stream;
31 } 31 }
32 return _eventStream; 32 return _eventStream;
33 } 33 }
34 34
35 $if DART2JS 35 $if DART2JS
36 _setEventListener(callback) { 36 _setEventListener(callback) {
37 JS('void', '#.onaudioprocess = #', this, 37 JS('void', '#.onaudioprocess = #', this,
38 convertDartClosureToJS(callback, 1)); 38 convertDartClosureToJS(callback, 1));
39 } 39 }
40 $endif 40 $endif
41 41
42 $!MEMBERS 42 $!MEMBERS
43 } 43 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate ('k') | tools/dom/templates/html/impl/impl_Window.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698