| #ifndef QUICHE_HTTP2_ADAPTER_DATA_SOURCE_H_ |
| #define QUICHE_HTTP2_ADAPTER_DATA_SOURCE_H_ |
| #include "absl/strings/string_view.h" |
| // Represents a HTTP message body. |
| // The source is not done, but cannot currently provide more data. |
| // The source can provide more data. |
| State state() const { return state_; } |
| // The next range of data provided by this data source. |
| virtual absl::string_view NextData() const = 0; |
| // Indicates that |bytes| bytes have been consumed by the caller. |
| virtual void Consume(size_t bytes) = 0; |
| State state_ = NOT_READY; |
| // A simple implementation constructible from a string_view or std::string. |
| class StringDataSource : public DataSource { |
| explicit StringDataSource(std::string data); |
| absl::string_view NextData() const override; |
| void Consume(size_t bytes) override; |
| absl::string_view remaining_; |
| #endif // QUICHE_HTTP2_ADAPTER_DATA_SOURCE_H_ |