http2: make Http2Settings constructors delegate
This commit extracts the common code in the existing Http2Settings constructors into a private constructor, allowing the existing ones to delegate to the private constructor it and avoid code duplication. PR-URL: https://github.com/nodejs/node/pull/23326 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
59c7df4a10
commit
972d0beb59
@ -226,32 +226,27 @@ void Http2Session::Http2Settings::Init() {
|
|||||||
count_ = n;
|
count_ = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Http2Session::Http2Settings::Http2Settings(
|
Http2Session::Http2Settings::Http2Settings(Environment* env,
|
||||||
Environment* env)
|
Http2Session* session, uint64_t start_time)
|
||||||
: AsyncWrap(env,
|
: AsyncWrap(env,
|
||||||
env->http2settings_constructor_template()
|
env->http2settings_constructor_template()
|
||||||
->NewInstance(env->context())
|
->NewInstance(env->context())
|
||||||
.ToLocalChecked(),
|
.ToLocalChecked(),
|
||||||
AsyncWrap::PROVIDER_HTTP2SETTINGS),
|
PROVIDER_HTTP2SETTINGS),
|
||||||
session_(nullptr),
|
session_(session),
|
||||||
startTime_(0) {
|
startTime_(start_time) {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Http2Session::Http2Settings::Http2Settings(Environment* env)
|
||||||
|
: Http2Settings(env, nullptr, 0) {}
|
||||||
|
|
||||||
// The Http2Settings class is used to configure a SETTINGS frame that is
|
// The Http2Settings class is used to configure a SETTINGS frame that is
|
||||||
// to be sent to the connected peer. The settings are set using a TypedArray
|
// to be sent to the connected peer. The settings are set using a TypedArray
|
||||||
// that is shared with the JavaScript side.
|
// that is shared with the JavaScript side.
|
||||||
Http2Session::Http2Settings::Http2Settings(
|
Http2Session::Http2Settings::Http2Settings(Http2Session* session)
|
||||||
Http2Session* session)
|
: Http2Settings(session->env(), session, uv_hrtime()) {}
|
||||||
: AsyncWrap(session->env(),
|
|
||||||
session->env()->http2settings_constructor_template()
|
|
||||||
->NewInstance(session->env()->context())
|
|
||||||
.ToLocalChecked(),
|
|
||||||
AsyncWrap::PROVIDER_HTTP2SETTINGS),
|
|
||||||
session_(session),
|
|
||||||
startTime_(uv_hrtime()) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generates a Buffer that contains the serialized payload of a SETTINGS
|
// Generates a Buffer that contains the serialized payload of a SETTINGS
|
||||||
// frame. This can be used, for instance, to create the Base64-encoded
|
// frame. This can be used, for instance, to create the Base64-encoded
|
||||||
|
@ -1136,6 +1136,7 @@ class Http2Session::Http2Settings : public AsyncWrap {
|
|||||||
get_setting fn);
|
get_setting fn);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Http2Settings(Environment* env, Http2Session* session, uint64_t start_time);
|
||||||
void Init();
|
void Init();
|
||||||
Http2Session* session_;
|
Http2Session* session_;
|
||||||
uint64_t startTime_;
|
uint64_t startTime_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user