Chromium Code Reviews| 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 // Filter performs filtering on data streams. Sample usage: | 5 // Filter performs filtering on data streams. Sample usage: |
| 6 // | 6 // |
| 7 // IStream* pre_filter_source; | 7 // IStream* pre_filter_source; |
| 8 // ... | 8 // ... |
| 9 // Filter* filter = Filter::Factory(filter_type, size); | 9 // Filter* filter = Filter::Factory(filter_type, size); |
| 10 // int pre_filter_data_len = filter->stream_buffer_size(); | 10 // int pre_filter_data_len = filter->stream_buffer_size(); |
| 11 // pre_filter_source->read(filter->stream_buffer(), pre_filter_data_len); | 11 // pre_filter_source->read(filter->stream_buffer(), pre_filter_data_len); |
| 12 // | 12 // |
| 13 // filter->FlushStreamBuffer(pre_filter_data_len); | 13 // filter->FlushStreamBuffer(pre_filter_data_len); |
| 14 // | 14 // |
| 15 // char post_filter_buf[kBufferSize]; | 15 // char post_filter_buf[kBufferSize]; |
| 16 // int post_filter_data_len = kBufferSize; | 16 // int post_filter_data_len = kBufferSize; |
| 17 // filter->ReadFilteredData(post_filter_buf, &post_filter_data_len); | 17 // filter->ReadFilteredData(post_filter_buf, &post_filter_data_len); |
| 18 // | 18 // |
| 19 // To filter a data stream, the caller first gets filter's stream_buffer_ | 19 // To filter a data stream, the caller first gets filter's stream_buffer_ |
| 20 // through its accessor and fills in stream_buffer_ with pre-filter data, next | 20 // through its accessor and fills in stream_buffer_ with pre-filter data, next |
| 21 // calls FlushStreamBuffer to notify Filter, then calls ReadFilteredData | 21 // calls FlushStreamBuffer to notify Filter, then calls ReadFilteredData |
| 22 // repeatedly to get all the filtered data. After all data have been fitlered | 22 // repeatedly to get all the filtered data. After all data have been fitlered |
|
Bence
2014/10/29 20:00:24
s/fitlered/filtered/ once you are here. Thanks.
Randy Smith (Not in Mondays)
2014/10/30 18:35:42
Done.
| |
| 23 // and read out, the caller may fill in stream_buffer_ again. This | 23 // and read out, the caller may fill in stream_buffer_ again. This |
| 24 // WriteBuffer-Flush-Read cycle is repeated until reaching the end of data | 24 // WriteBuffer-Flush-Read cycle is repeated until reaching the end of data |
| 25 // stream. | 25 // stream. |
| 26 // | 26 // |
| 27 // A return of FILTER_OK from ReadData() means that more data is | |
| 28 // available to a future ReadData() call and data may not be written | |
| 29 // into stream_buffer(). A return of FILTER_NEED_MORE_DATA from ReadData() | |
| 30 // means that the buffer at stream_buffer() is available for writing. | |
| 31 // | |
| 27 // The lifetime of a Filter instance is completely controlled by its caller. | 32 // The lifetime of a Filter instance is completely controlled by its caller. |
| 28 | 33 |
| 29 #ifndef NET_FILTER_FILTER_H__ | 34 #ifndef NET_FILTER_FILTER_H__ |
| 30 #define NET_FILTER_FILTER_H__ | 35 #define NET_FILTER_FILTER_H__ |
| 31 | 36 |
| 32 #include <string> | 37 #include <string> |
| 33 #include <vector> | 38 #include <vector> |
| 34 | 39 |
| 35 #include "base/basictypes.h" | 40 #include "base/basictypes.h" |
| 36 #include "base/gtest_prod_util.h" | 41 #include "base/gtest_prod_util.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 // Remember what status or local filter last returned so we can better handle | 280 // Remember what status or local filter last returned so we can better handle |
| 276 // chained filters. | 281 // chained filters. |
| 277 FilterStatus last_status_; | 282 FilterStatus last_status_; |
| 278 | 283 |
| 279 DISALLOW_COPY_AND_ASSIGN(Filter); | 284 DISALLOW_COPY_AND_ASSIGN(Filter); |
| 280 }; | 285 }; |
| 281 | 286 |
| 282 } // namespace net | 287 } // namespace net |
| 283 | 288 |
| 284 #endif // NET_FILTER_FILTER_H__ | 289 #endif // NET_FILTER_FILTER_H__ |
| OLD | NEW |