| OLD | NEW |
| 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.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 abstract class _BaseDataInputStream { | 7 abstract class _BaseDataInputStream { |
| 8 int available(); | 8 int available(); |
| 9 | 9 |
| 10 List<int> read([int len]) { | 10 List<int> read([int len]) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 | 213 |
| 214 class _InputStreamController extends StreamController<List<int>> { | 214 class _InputStreamController extends StreamController<List<int>> { |
| 215 _InputStreamController(InputStream this._inputStream) { | 215 _InputStreamController(InputStream this._inputStream) { |
| 216 _inputStream.onClosed = close; | 216 _inputStream.onClosed = close; |
| 217 _inputStream.onError = (error) => signalError(new AsyncError(error)); | 217 _inputStream.onError = (error) => signalError(new AsyncError(error)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void onPauseStateChange() { | 220 void onPauseStateChange() { |
| 221 if (isPaused) { | 221 if (isPaused) { |
| 222 unlisten(); | 222 _unlisten(); |
| 223 } else { | 223 } else { |
| 224 listen(); | 224 _listen(); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void onSubscriptionStateChange() { | 228 void onSubscriptionStateChange() { |
| 229 if (hasSubscribers) listen(); | 229 if (hasSubscribers) _listen(); |
| 230 // TODO(ajohnsen): Else destroy? | 230 // TODO(ajohnsen): Else destroy? |
| 231 } | 231 } |
| 232 | 232 |
| 233 void listen() { | 233 void _listen() { |
| 234 _inputStream.onData = () { | 234 _inputStream.onData = () { |
| 235 add(_inputStream.read()); | 235 add(_inputStream.read()); |
| 236 }; | 236 }; |
| 237 } | 237 } |
| 238 | 238 |
| 239 void unlisten() { | 239 void _unlisten() { |
| 240 _inputStream.onData = null; | 240 _inputStream.onData = null; |
| 241 } | 241 } |
| 242 | 242 |
| 243 InputStream _inputStream; | 243 InputStream _inputStream; |
| 244 } | 244 } |
| OLD | NEW |