Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-03-05 04:16:06 +0300
committerAnna Henningsen <anna@addaleax.net>2020-04-06 03:06:37 +0300
commitf54b5b2fe4731ca491f9a7284cf2c8042966ac22 (patch)
tree835e5d67bb16826b193a466792d7c1bf584905b6 /src/node_http2.h
parent6576b9b9d0f3de931e5e867a7b4b43319b187955 (diff)
src: move HTTP/2 state out of Environment
Moves state that is specific to HTTP/2 into the HTTP/2 implementation as a cleanup. PR-URL: https://github.com/nodejs/node/pull/32538 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r--src/node_http2.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/node_http2.h b/src/node_http2.h
index b07f9cf4130..f9a0cae85ff 100644
--- a/src/node_http2.h
+++ b/src/node_http2.h
@@ -189,7 +189,8 @@ class Http2Scope {
// configured.
class Http2Options {
public:
- Http2Options(Environment* env, nghttp2_session_type type);
+ Http2Options(Http2State* http2_state,
+ nghttp2_session_type type);
~Http2Options() = default;
@@ -541,7 +542,7 @@ class Http2Session : public AsyncWrap,
public StreamListener,
public mem::NgLibMemoryManager<Http2Session, nghttp2_mem> {
public:
- Http2Session(Environment* env,
+ Http2Session(Http2State* http2_state,
v8::Local<v8::Object> wrap,
nghttp2_session_type type = NGHTTP2_SESSION_SERVER);
~Http2Session() override;
@@ -674,6 +675,9 @@ class Http2Session : public AsyncWrap,
return env()->event_loop();
}
+ Http2State* http2_state() {
+ return http2_state_.get();
+ }
BaseObjectPtr<Http2Ping> PopPing();
Http2Ping* AddPing(BaseObjectPtr<Http2Ping> ping);
@@ -871,6 +875,9 @@ class Http2Session : public AsyncWrap,
uint32_t invalid_frame_count_ = 0;
void PushOutgoingBuffer(NgHttp2StreamWrite&& write);
+
+ BaseObjectPtr<Http2State> http2_state_;
+
void CopyDataIntoOutgoing(const uint8_t* src, size_t src_length);
void ClearOutgoing(int status);
@@ -881,11 +888,11 @@ class Http2Session : public AsyncWrap,
class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
public:
Http2SessionPerformanceEntry(
- Environment* env,
+ Http2State* http2_state,
const Http2Session::Statistics& stats,
nghttp2_session_type type) :
performance::PerformanceEntry(
- env, "Http2Session", "http2",
+ http2_state->env(), "Http2Session", "http2",
stats.start_time,
stats.end_time),
ping_rtt_(stats.ping_rtt),
@@ -896,7 +903,8 @@ class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
stream_count_(stats.stream_count),
max_concurrent_streams_(stats.max_concurrent_streams),
stream_average_duration_(stats.stream_average_duration),
- session_type_(type) { }
+ session_type_(type),
+ http2_state_(http2_state) { }
uint64_t ping_rtt() const { return ping_rtt_; }
uint64_t data_sent() const { return data_sent_; }
@@ -907,6 +915,7 @@ class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
size_t max_concurrent_streams() const { return max_concurrent_streams_; }
double stream_average_duration() const { return stream_average_duration_; }
nghttp2_session_type type() const { return session_type_; }
+ Http2State* http2_state() const { return http2_state_.get(); }
void Notify(v8::Local<v8::Value> obj) {
performance::PerformanceEntry::Notify(env(), kind(), obj);
@@ -922,17 +931,18 @@ class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
size_t max_concurrent_streams_;
double stream_average_duration_;
nghttp2_session_type session_type_;
+ BaseObjectPtr<Http2State> http2_state_;
};
class Http2StreamPerformanceEntry
: public performance::PerformanceEntry {
public:
Http2StreamPerformanceEntry(
- Environment* env,
+ Http2State* http2_state,
int32_t id,
const Http2Stream::Statistics& stats) :
performance::PerformanceEntry(
- env, "Http2Stream", "http2",
+ http2_state->env(), "Http2Stream", "http2",
stats.start_time,
stats.end_time),
id_(id),
@@ -940,7 +950,8 @@ class Http2StreamPerformanceEntry
first_byte_(stats.first_byte),
first_byte_sent_(stats.first_byte_sent),
sent_bytes_(stats.sent_bytes),
- received_bytes_(stats.received_bytes) { }
+ received_bytes_(stats.received_bytes),
+ http2_state_(http2_state) { }
int32_t id() const { return id_; }
uint64_t first_header() const { return first_header_; }
@@ -948,6 +959,7 @@ class Http2StreamPerformanceEntry
uint64_t first_byte_sent() const { return first_byte_sent_; }
uint64_t sent_bytes() const { return sent_bytes_; }
uint64_t received_bytes() const { return received_bytes_; }
+ Http2State* http2_state() const { return http2_state_.get(); }
void Notify(v8::Local<v8::Value> obj) {
performance::PerformanceEntry::Notify(env(), kind(), obj);
@@ -960,6 +972,7 @@ class Http2StreamPerformanceEntry
uint64_t first_byte_sent_;
uint64_t sent_bytes_;
uint64_t received_bytes_;
+ BaseObjectPtr<Http2State> http2_state_;
};
class Http2Session::Http2Ping : public AsyncWrap {
@@ -987,7 +1000,7 @@ class Http2Session::Http2Ping : public AsyncWrap {
// structs.
class Http2Session::Http2Settings : public AsyncWrap {
public:
- Http2Settings(Environment* env,
+ Http2Settings(Http2State* http2_state,
Http2Session* session,
v8::Local<v8::Object> obj,
uint64_t start_time = uv_hrtime());
@@ -1006,15 +1019,14 @@ class Http2Session::Http2Settings : public AsyncWrap {
v8::Local<v8::Value> Pack();
// Resets the default values in the settings buffer
- static void RefreshDefaults(Environment* env);
+ static void RefreshDefaults(Http2State* http2_state);
// Update the local or remote settings for the given session
- static void Update(Environment* env,
- Http2Session* session,
+ static void Update(Http2Session* session,
get_setting fn);
private:
- void Init();
+ void Init(Http2State* http2_state);
Http2Session* session_;
uint64_t startTime_;
size_t count_ = 0;