OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // The basic usage of the Filter interface is described in the comment at | 5 // The basic usage of the Filter interface is described in the comment at |
6 // the beginning of filter.h. If Filter::Factory is passed a vector of | 6 // the beginning of filter.h. If Filter::Factory is passed a vector of |
7 // size greater than 1, that interface is implemented by a series of filters | 7 // size greater than 1, that interface is implemented by a series of filters |
8 // connected in a chain. In such a case the first filter | 8 // connected in a chain. In such a case the first filter |
9 // in the chain proxies calls to ReadData() so that its return values | 9 // in the chain proxies calls to ReadData() so that its return values |
10 // apply to the entire chain. | 10 // apply to the entire chain. |
11 // | 11 // |
12 // In a filter chain, the data flows from first filter (held by the | 12 // In a filter chain, the data flows from first filter (held by the |
13 // caller) down the chain. When ReadData() is called on any filter | 13 // caller) down the chain. When ReadData() is called on any filter |
14 // except for the last filter, it proxies the call down the chain, | 14 // except for the last filter, it proxies the call down the chain, |
15 // filling in the input buffers of subsequent filters if needed (== | 15 // filling in the input buffers of subsequent filters if needed (== |
16 // that filter's last_status() value is FILTER_NEED_MORE_DATA) and | 16 // that filter's last_status() value is FILTER_NEED_MORE_DATA) and |
17 // available (== the current filter has data it can output). The last | 17 // available (== the current filter has data it can output). The last |
18 // Filter will then output data if possible, and return | 18 // Filter will then output data if possible, and return |
19 // FILTER_NEED_MORE_DATA if not. Because the indirection pushes | 19 // FILTER_NEED_MORE_DATA if not. Because the indirection pushes |
20 // data along the filter chain at each level if it's available and the | 20 // data along the filter chain at each level if it's available and the |
21 // next filter needs it, a return value of FILTER_NEED_MORE_DATA from the | 21 // next filter needs it, a return value of FILTER_NEED_MORE_DATA from the |
22 // final filter will apply to the entire chain. | 22 // final filter will apply to the entire chain. |
23 | 23 |
24 #include "net/filter/filter.h" | 24 #include "net/filter/filter.h" |
25 | 25 |
26 #include "base/files/file_path.h" | 26 #include "base/files/file_path.h" |
27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/values.h" |
28 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
29 #include "net/base/sdch_net_log_params.h" | 30 #include "net/base/sdch_net_log_params.h" |
30 #include "net/filter/gzip_filter.h" | 31 #include "net/filter/gzip_filter.h" |
31 #include "net/filter/sdch_filter.h" | 32 #include "net/filter/sdch_filter.h" |
32 #include "net/url_request/url_request_context.h" | 33 #include "net/url_request/url_request_context.h" |
33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
34 | 35 |
35 namespace net { | 36 namespace net { |
36 | 37 |
37 namespace { | 38 namespace { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 404 |
404 void Filter::PushDataIntoNextFilter() { | 405 void Filter::PushDataIntoNextFilter() { |
405 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 406 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
406 int next_size = next_filter_->stream_buffer_size(); | 407 int next_size = next_filter_->stream_buffer_size(); |
407 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 408 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
408 if (FILTER_ERROR != last_status_) | 409 if (FILTER_ERROR != last_status_) |
409 next_filter_->FlushStreamBuffer(next_size); | 410 next_filter_->FlushStreamBuffer(next_size); |
410 } | 411 } |
411 | 412 |
412 } // namespace net | 413 } // namespace net |
OLD | NEW |