OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef NET_FILTER_FILTER_SOURCE_STREAM_H_ | 5 #ifndef NET_FILTER_FILTER_SOURCE_STREAM_H_ |
6 #define NET_FILTER_FILTER_SOURCE_STREAM_H_ | 6 #define NET_FILTER_FILTER_SOURCE_STREAM_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Subclasses should implement this method to filter data from | 63 // Subclasses should implement this method to filter data from |
64 // |input_buffer| and write to |output_buffer|. | 64 // |input_buffer| and write to |output_buffer|. |
65 // This method must complete synchronously (i.e. It cannot return | 65 // This method must complete synchronously (i.e. It cannot return |
66 // ERR_IO_PENDING). If an unrecoverable error occurred, this should return | 66 // ERR_IO_PENDING). If an unrecoverable error occurred, this should return |
67 // ERR_CONTENT_DECODING_FAILED or a more specific error code. | 67 // ERR_CONTENT_DECODING_FAILED or a more specific error code. |
68 // | 68 // |
69 // FilterData() will be repeatedly invoked with the same |input_buffer| until | 69 // FilterData() will be repeatedly invoked with the same |input_buffer| until |
70 // FilterData() returns 0 or an error. If FilterData() returns 0, | 70 // FilterData() returns 0 or an error. If FilterData() returns 0, |
71 // |input_buffer| must be fully drained. Upstream EOF is reached when | 71 // |input_buffer| must be fully drained. Upstream EOF is reached when |
72 // FilterData() is called with |input_buffer->BytesRemaining() == 0|. | 72 // FilterData() is called with |upstream_eof_reached| = true. |
73 // TODO(xunjieli): consider allowing asynchronous response via callback | 73 // TODO(xunjieli): consider allowing asynchronous response via callback |
74 // to support off-thread decompression. | 74 // to support off-thread decompression. |
75 virtual int FilterData(IOBuffer* output_buffer, | 75 virtual int FilterData(IOBuffer* output_buffer, |
76 int output_buffer_size, | 76 int output_buffer_size, |
77 DrainableIOBuffer* input_buffer) = 0; | 77 DrainableIOBuffer* input_buffer, |
| 78 bool upstream_eof_reached) = 0; |
78 | 79 |
79 // Returns a string representation of the type of this FilterSourceStream. | 80 // Returns a string representation of the type of this FilterSourceStream. |
80 // This is for UMA logging. | 81 // This is for UMA logging. |
81 virtual std::string GetTypeAsString() const = 0; | 82 virtual std::string GetTypeAsString() const = 0; |
82 | 83 |
83 // Returns whether |this| still needs more input data from |upstream_|. | 84 // Returns whether |this| still needs more input data from |upstream_|. |
84 // By default, |this| will continue reading until |upstream_| returns an error | 85 // By default, |this| will continue reading until |upstream_| returns an error |
85 // or EOF. Subclass can override this to return false to skip reading all the | 86 // or EOF. Subclass can override this to return false to skip reading all the |
86 // input from |upstream_|. | 87 // input from |upstream_|. |
87 virtual bool NeedMoreData() const; | 88 virtual bool NeedMoreData() const; |
(...skipping 20 matching lines...) Expand all Loading... |
108 | 109 |
109 // Reading from |upstream_| has returned 0 byte or an error code. | 110 // Reading from |upstream_| has returned 0 byte or an error code. |
110 bool upstream_end_reached_; | 111 bool upstream_end_reached_; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); | 113 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); |
113 }; | 114 }; |
114 | 115 |
115 } // namespace net | 116 } // namespace net |
116 | 117 |
117 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ | 118 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ |
OLD | NEW |