OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/bzip2_filter.h" | 5 #include "net/base/bzip2_filter.h" |
6 | 6 |
7 BZip2Filter::BZip2Filter(const FilterContext& filter_context) | 7 BZip2Filter::BZip2Filter(const FilterContext& filter_context) |
8 : Filter(filter_context), | 8 : Filter(filter_context), |
9 decoding_status_(DECODING_UNINITIALIZED), | 9 decoding_status_(DECODING_UNINITIALIZED), |
10 bzip2_data_stream_(NULL) { | 10 bzip2_data_stream_(NULL) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (DECODING_DONE == decoding_status_) { | 49 if (DECODING_DONE == decoding_status_) { |
50 // this logic just follow gzip_filter, which be used to deal wth some | 50 // this logic just follow gzip_filter, which be used to deal wth some |
51 // server might send extra data after finish sending compress data | 51 // server might send extra data after finish sending compress data |
52 return CopyOut(dest_buffer, dest_len); | 52 return CopyOut(dest_buffer, dest_len); |
53 } | 53 } |
54 | 54 |
55 if (decoding_status_ != DECODING_IN_PROGRESS) | 55 if (decoding_status_ != DECODING_IN_PROGRESS) |
56 return status; | 56 return status; |
57 | 57 |
58 // Make sure we have valid input data | 58 // Make sure we have valid input data |
59 if (!next_stream_data_ || stream_data_len_ <= 0) | 59 if (!next_stream_data_ || stream_data_len_ <= 0) { |
60 return status; | 60 *dest_len = 0; |
| 61 return Filter::FILTER_NEED_MORE_DATA; |
| 62 } |
61 | 63 |
62 // Fill in bzip2 control block | 64 // Fill in bzip2 control block |
63 int ret, output_len = *dest_len; | 65 int ret, output_len = *dest_len; |
64 *dest_len = 0; | 66 *dest_len = 0; |
65 | 67 |
66 bzip2_data_stream_->next_in = next_stream_data_; | 68 bzip2_data_stream_->next_in = next_stream_data_; |
67 bzip2_data_stream_->avail_in = stream_data_len_; | 69 bzip2_data_stream_->avail_in = stream_data_len_; |
68 bzip2_data_stream_->next_out = dest_buffer; | 70 bzip2_data_stream_->next_out = dest_buffer; |
69 bzip2_data_stream_->avail_out = output_len; | 71 bzip2_data_stream_->avail_out = output_len; |
70 | 72 |
(...skipping 17 matching lines...) Expand all Loading... |
88 status = Filter::FILTER_NEED_MORE_DATA; | 90 status = Filter::FILTER_NEED_MORE_DATA; |
89 } else if (BZ_STREAM_END == ret) { | 91 } else if (BZ_STREAM_END == ret) { |
90 status = Filter::FILTER_DONE; | 92 status = Filter::FILTER_DONE; |
91 decoding_status_ = DECODING_DONE; | 93 decoding_status_ = DECODING_DONE; |
92 } else { | 94 } else { |
93 decoding_status_ = DECODING_ERROR; | 95 decoding_status_ = DECODING_ERROR; |
94 } | 96 } |
95 | 97 |
96 return status; | 98 return status; |
97 } | 99 } |
OLD | NEW |