| OLD | NEW |
| 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 dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Private helper-class to handle native filters. | 8 * Private helper-class to handle native filters. |
| 9 */ | 9 */ |
| 10 abstract class _Filter { | 10 abstract class _Filter { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 if (_closed) return; | 44 if (_closed) return; |
| 45 try { | 45 try { |
| 46 _empty = false; | 46 _empty = false; |
| 47 _filter.process(data); | 47 _filter.process(data); |
| 48 var out; | 48 var out; |
| 49 while ((out = _filter.processed(flush: false)) != null) { | 49 while ((out = _filter.processed(flush: false)) != null) { |
| 50 sink.add(out); | 50 sink.add(out); |
| 51 } | 51 } |
| 52 } catch (e, s) { | 52 } catch (e, s) { |
| 53 _closed = true; | 53 _closed = true; |
| 54 sink.addError(new AsyncError(e, s)); | 54 sink.addError(e, s); |
| 55 sink.close(); | 55 sink.close(); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void handleDone(EventSink<List<int>> sink) { | 59 void handleDone(EventSink<List<int>> sink) { |
| 60 if (_closed) return; | 60 if (_closed) return; |
| 61 if (_empty) _filter.process(const []); | 61 if (_empty) _filter.process(const []); |
| 62 try { | 62 try { |
| 63 var out; | 63 var out; |
| 64 while ((out = _filter.processed()) != null) { | 64 while ((out = _filter.processed()) != null) { |
| 65 sink.add(out); | 65 sink.add(out); |
| 66 } | 66 } |
| 67 } catch (e, s) { | 67 } catch (e, s) { |
| 68 sink.addError(new AsyncError(e, s)); | 68 sink.addError(e, s); |
| 69 _closed = true; | 69 _closed = true; |
| 70 } | 70 } |
| 71 if (!_closed) _filter.end(); | 71 if (!_closed) _filter.end(); |
| 72 _closed = true; | 72 _closed = true; |
| 73 sink.close(); | 73 sink.close(); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * ZLibDeflater class used to deflate a stream of bytes, using zlib. | 79 * ZLibDeflater class used to deflate a stream of bytes, using zlib. |
| 80 */ | 80 */ |
| 81 class ZLibDeflater extends _FilterTransformer { | 81 class ZLibDeflater extends _FilterTransformer { |
| 82 ZLibDeflater({bool gzip: true, int level: 6}) | 82 ZLibDeflater({bool gzip: true, int level: 6}) |
| 83 : super(_Filter.newZLibDeflateFilter(gzip, level)); | 83 : super(_Filter.newZLibDeflateFilter(gzip, level)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * ZLibInflater class used to inflate a stream of bytes, using zlib. | 88 * ZLibInflater class used to inflate a stream of bytes, using zlib. |
| 89 */ | 89 */ |
| 90 class ZLibInflater extends _FilterTransformer { | 90 class ZLibInflater extends _FilterTransformer { |
| 91 ZLibInflater() : super(_Filter.newZLibInflateFilter()); | 91 ZLibInflater() : super(_Filter.newZLibInflateFilter()); |
| 92 } | 92 } |
| 93 | 93 |
| OLD | NEW |