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(e, s); | 54 // TODO(floitsch): we are losing the stack trace. |
| 55 sink.addError(e); |
55 sink.close(); | 56 sink.close(); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 void handleDone(EventSink<List<int>> sink) { | 60 void handleDone(EventSink<List<int>> sink) { |
60 if (_closed) return; | 61 if (_closed) return; |
61 if (_empty) _filter.process(const []); | 62 if (_empty) _filter.process(const []); |
62 try { | 63 try { |
63 var out; | 64 var out; |
64 while ((out = _filter.processed()) != null) { | 65 while ((out = _filter.processed()) != null) { |
65 sink.add(out); | 66 sink.add(out); |
66 } | 67 } |
67 } catch (e, s) { | 68 } catch (e, s) { |
68 sink.addError(e, s); | 69 // TODO(floitsch): we are losing the stack trace. |
| 70 sink.addError(e); |
69 _closed = true; | 71 _closed = true; |
70 } | 72 } |
71 if (!_closed) _filter.end(); | 73 if (!_closed) _filter.end(); |
72 _closed = true; | 74 _closed = true; |
73 sink.close(); | 75 sink.close(); |
74 } | 76 } |
75 } | 77 } |
76 | 78 |
77 | 79 |
78 /** | 80 /** |
79 * ZLibDeflater class used to deflate a stream of bytes, using zlib. | 81 * ZLibDeflater class used to deflate a stream of bytes, using zlib. |
80 */ | 82 */ |
81 class ZLibDeflater extends _FilterTransformer { | 83 class ZLibDeflater extends _FilterTransformer { |
82 ZLibDeflater({bool gzip: true, int level: 6}) | 84 ZLibDeflater({bool gzip: true, int level: 6}) |
83 : super(_Filter.newZLibDeflateFilter(gzip, level)); | 85 : super(_Filter.newZLibDeflateFilter(gzip, level)); |
84 } | 86 } |
85 | 87 |
86 | 88 |
87 /** | 89 /** |
88 * ZLibInflater class used to inflate a stream of bytes, using zlib. | 90 * ZLibInflater class used to inflate a stream of bytes, using zlib. |
89 */ | 91 */ |
90 class ZLibInflater extends _FilterTransformer { | 92 class ZLibInflater extends _FilterTransformer { |
91 ZLibInflater() : super(_Filter.newZLibInflateFilter()); | 93 ZLibInflater() : super(_Filter.newZLibInflateFilter()); |
92 } | 94 } |
93 | 95 |
OLD | NEW |