| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Helper method used as a callback argument passed to |upstream_->Read()|. | 60 // Helper method used as a callback argument passed to |upstream_->Read()|. |
| 61 void OnIOComplete(int result); | 61 void OnIOComplete(int result); |
| 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 // If FilterData() returns 0, *|consumed_bytes| must be equal to |
| 70 // FilterData() returns 0 or an error. If FilterData() returns 0, | 70 // |input_buffer_size|. Upstream EOF is reached when FilterData() is called |
| 71 // |input_buffer| must be fully drained. Upstream EOF is reached when | 71 // with |upstream_eof_reached| = true. |
| 72 // FilterData() is called with |upstream_eof_reached| = true. | |
| 73 // TODO(xunjieli): consider allowing asynchronous response via callback | 72 // TODO(xunjieli): consider allowing asynchronous response via callback |
| 74 // to support off-thread decompression. | 73 // to support off-thread decompression. |
| 75 virtual int FilterData(IOBuffer* output_buffer, | 74 virtual int FilterData(IOBuffer* output_buffer, |
| 76 int output_buffer_size, | 75 int output_buffer_size, |
| 77 DrainableIOBuffer* input_buffer, | 76 IOBuffer* input_buffer, |
| 77 int input_buffer_size, |
| 78 int* consumed_bytes, |
| 78 bool upstream_eof_reached) = 0; | 79 bool upstream_eof_reached) = 0; |
| 79 | 80 |
| 80 // Returns a string representation of the type of this FilterSourceStream. | 81 // Returns a string representation of the type of this FilterSourceStream. |
| 81 // This is for UMA logging. | 82 // This is for UMA logging. |
| 82 virtual std::string GetTypeAsString() const = 0; | 83 virtual std::string GetTypeAsString() const = 0; |
| 83 | 84 |
| 84 // Returns whether |this| still needs more input data from |upstream_|. | 85 // Returns whether |this| still needs more input data from |upstream_|. |
| 85 // By default, |this| will continue reading until |upstream_| returns an error | 86 // By default, |this| will continue reading until |upstream_| returns an error |
| 86 // or EOF. Subclass can override this to return false to skip reading all the | 87 // or EOF. Subclass can override this to return false to skip reading all the |
| 87 // input from |upstream_|. | 88 // input from |upstream_|. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 109 | 110 |
| 110 // Reading from |upstream_| has returned 0 byte or an error code. | 111 // Reading from |upstream_| has returned 0 byte or an error code. |
| 111 bool upstream_end_reached_; | 112 bool upstream_end_reached_; |
| 112 | 113 |
| 113 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); | 114 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 } // namespace net | 117 } // namespace net |
| 117 | 118 |
| 118 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ | 119 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ |
| OLD | NEW |