| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/filter.h" | 5 #include "net/base/filter.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/base/gzip_filter.h" | 9 #include "net/base/gzip_filter.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 FILTER_TYPE_GZIP_HELPING_SDCH); | 315 FILTER_TYPE_GZIP_HELPING_SDCH); |
| 316 encoding_types->insert(encoding_types->begin(), FILTER_TYPE_SDCH_POSSIBLE); | 316 encoding_types->insert(encoding_types->begin(), FILTER_TYPE_SDCH_POSSIBLE); |
| 317 return; | 317 return; |
| 318 } | 318 } |
| 319 | 319 |
| 320 Filter::Filter() | 320 Filter::Filter() |
| 321 : stream_buffer_(NULL), | 321 : stream_buffer_(NULL), |
| 322 stream_buffer_size_(0), | 322 stream_buffer_size_(0), |
| 323 next_stream_data_(NULL), | 323 next_stream_data_(NULL), |
| 324 stream_data_len_(0), | 324 stream_data_len_(0), |
| 325 next_filter_(NULL), | 325 last_status_(FILTER_NEED_MORE_DATA) {} |
| 326 last_status_(FILTER_NEED_MORE_DATA) { | |
| 327 } | |
| 328 | 326 |
| 329 Filter::FilterStatus Filter::CopyOut(char* dest_buffer, int* dest_len) { | 327 Filter::FilterStatus Filter::CopyOut(char* dest_buffer, int* dest_len) { |
| 330 int out_len; | 328 int out_len; |
| 331 int input_len = *dest_len; | 329 int input_len = *dest_len; |
| 332 *dest_len = 0; | 330 *dest_len = 0; |
| 333 | 331 |
| 334 if (0 == stream_data_len_) | 332 if (0 == stream_data_len_) |
| 335 return Filter::FILTER_NEED_MORE_DATA; | 333 return Filter::FILTER_NEED_MORE_DATA; |
| 336 | 334 |
| 337 out_len = std::min(input_len, stream_data_len_); | 335 out_len = std::min(input_len, stream_data_len_); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 397 |
| 400 void Filter::PushDataIntoNextFilter() { | 398 void Filter::PushDataIntoNextFilter() { |
| 401 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 399 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
| 402 int next_size = next_filter_->stream_buffer_size(); | 400 int next_size = next_filter_->stream_buffer_size(); |
| 403 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 401 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
| 404 if (FILTER_ERROR != last_status_) | 402 if (FILTER_ERROR != last_status_) |
| 405 next_filter_->FlushStreamBuffer(next_size); | 403 next_filter_->FlushStreamBuffer(next_size); |
| 406 } | 404 } |
| 407 | 405 |
| 408 } // namespace net | 406 } // namespace net |
| OLD | NEW |