xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/http2/adapter/nghttp2_session.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 #ifndef QUICHE_HTTP2_ADAPTER_NGHTTP2_SESSION_H_
2 #define QUICHE_HTTP2_ADAPTER_NGHTTP2_SESSION_H_
3 
4 #include <cstdint>
5 
6 #include "quiche/http2/adapter/http2_session.h"
7 #include "quiche/http2/adapter/nghttp2.h"
8 #include "quiche/http2/adapter/nghttp2_util.h"
9 #include "quiche/common/platform/api/quiche_export.h"
10 
11 namespace http2 {
12 namespace adapter {
13 
14 // A C++ wrapper around common nghttp2_session operations.
15 class QUICHE_EXPORT NgHttp2Session : public Http2Session {
16  public:
17   // Does not take ownership of |options|.
18   NgHttp2Session(Perspective perspective,
19                  nghttp2_session_callbacks_unique_ptr callbacks,
20                  const nghttp2_option* options, void* userdata);
21   ~NgHttp2Session() override;
22 
23   int64_t ProcessBytes(absl::string_view bytes) override;
24 
25   int Consume(Http2StreamId stream_id, size_t num_bytes) override;
26 
27   bool want_read() const override;
28   bool want_write() const override;
29   int GetRemoteWindowSize() const override;
30 
raw_ptr()31   nghttp2_session* raw_ptr() const { return session_.get(); }
32 
33  private:
34   nghttp2_session_unique_ptr session_;
35   Perspective perspective_;
36 };
37 
38 }  // namespace adapter
39 }  // namespace http2
40 
41 #endif  // QUICHE_HTTP2_ADAPTER_NGHTTP2_SESSION_H_
42