Skip to content

Commit ffdf1de

Browse files
committed
src: clean up stream_base.h and stream-base-inl.h
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #32307 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent a940143 commit ffdf1de

8 files changed

+192
-175
lines changed

src/node_http2.cc

+10
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,38 @@
99
#include "node_mem-inl.h"
1010
#include "node_perf.h"
1111
#include "node_revert.h"
12+
#include "stream_base-inl.h"
1213
#include "util-inl.h"
1314

1415
#include <algorithm>
1516

1617
namespace node {
1718

19+
using v8::Array;
1820
using v8::ArrayBuffer;
1921
using v8::ArrayBufferView;
2022
using v8::BackingStore;
2123
using v8::Boolean;
2224
using v8::Context;
2325
using v8::Float64Array;
2426
using v8::Function;
27+
using v8::FunctionCallbackInfo;
28+
using v8::FunctionTemplate;
29+
using v8::HandleScope;
2530
using v8::Integer;
31+
using v8::Isolate;
32+
using v8::Local;
33+
using v8::MaybeLocal;
2634
using v8::NewStringType;
2735
using v8::Number;
36+
using v8::Object;
2837
using v8::ObjectTemplate;
2938
using v8::String;
3039
using v8::Uint32;
3140
using v8::Uint32Array;
3241
using v8::Uint8Array;
3342
using v8::Undefined;
43+
using v8::Value;
3444

3545
using node::performance::PerformanceEntry;
3646
namespace http2 {

src/node_http2.h

+48-52
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "node_http_common.h"
1212
#include "node_mem.h"
1313
#include "node_perf.h"
14-
#include "stream_base-inl.h"
14+
#include "stream_base.h"
1515
#include "string_bytes.h"
1616

1717
#include <algorithm>
@@ -20,13 +20,6 @@
2020
namespace node {
2121
namespace http2 {
2222

23-
using v8::Array;
24-
using v8::Context;
25-
using v8::Isolate;
26-
using v8::MaybeLocal;
27-
28-
using performance::PerformanceEntry;
29-
3023
// We strictly limit the number of outstanding unacknowledged PINGS a user
3124
// may send in order to prevent abuse. The current default cap is 10. The
3225
// user may set a different limit using a per Http2Session configuration
@@ -169,7 +162,7 @@ class Http2Scope {
169162

170163
private:
171164
Http2Session* session_ = nullptr;
172-
Local<Object> session_handle_;
165+
v8::Local<v8::Object> session_handle_;
173166
};
174167

175168
// The Http2Options class is used to parse the options object passed in to
@@ -240,9 +233,9 @@ class Http2Options {
240233
class Http2Priority {
241234
public:
242235
Http2Priority(Environment* env,
243-
Local<Value> parent,
244-
Local<Value> weight,
245-
Local<Value> exclusive);
236+
v8::Local<v8::Value> parent,
237+
v8::Local<v8::Value> weight,
238+
v8::Local<v8::Value> exclusive);
246239

247240
nghttp2_priority_spec* operator*() {
248241
return &spec;
@@ -410,15 +403,15 @@ class Http2Stream : public AsyncWrap,
410403
std::string diagnostic_name() const override;
411404

412405
// JavaScript API
413-
static void GetID(const FunctionCallbackInfo<Value>& args);
414-
static void Destroy(const FunctionCallbackInfo<Value>& args);
415-
static void Priority(const FunctionCallbackInfo<Value>& args);
416-
static void PushPromise(const FunctionCallbackInfo<Value>& args);
417-
static void RefreshState(const FunctionCallbackInfo<Value>& args);
418-
static void Info(const FunctionCallbackInfo<Value>& args);
419-
static void Trailers(const FunctionCallbackInfo<Value>& args);
420-
static void Respond(const FunctionCallbackInfo<Value>& args);
421-
static void RstStream(const FunctionCallbackInfo<Value>& args);
406+
static void GetID(const v8::FunctionCallbackInfo<v8::Value>& args);
407+
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
408+
static void Priority(const v8::FunctionCallbackInfo<v8::Value>& args);
409+
static void PushPromise(const v8::FunctionCallbackInfo<v8::Value>& args);
410+
static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
411+
static void Info(const v8::FunctionCallbackInfo<v8::Value>& args);
412+
static void Trailers(const v8::FunctionCallbackInfo<v8::Value>& args);
413+
static void Respond(const v8::FunctionCallbackInfo<v8::Value>& args);
414+
static void RstStream(const v8::FunctionCallbackInfo<v8::Value>& args);
422415

423416
class Provider;
424417

@@ -540,7 +533,7 @@ class Http2Session : public AsyncWrap,
540533
public mem::NgLibMemoryManager<Http2Session, nghttp2_mem> {
541534
public:
542535
Http2Session(Environment* env,
543-
Local<Object> wrap,
536+
v8::Local<v8::Object> wrap,
544537
nghttp2_session_type type = NGHTTP2_SESSION_SERVER);
545538
~Http2Session() override;
546539

@@ -555,7 +548,7 @@ class Http2Session : public AsyncWrap,
555548

556549
void Close(uint32_t code = NGHTTP2_NO_ERROR,
557550
bool socket_closed = false);
558-
void Consume(Local<Object> stream);
551+
void Consume(v8::Local<v8::Object> stream);
559552
void Goaway(uint32_t code, int32_t lastStreamID,
560553
const uint8_t* data, size_t len);
561554
void AltSvc(int32_t id,
@@ -652,21 +645,21 @@ class Http2Session : public AsyncWrap,
652645
void DecreaseAllocatedSize(size_t size);
653646

654647
// The JavaScript API
655-
static void New(const FunctionCallbackInfo<Value>& args);
656-
static void Consume(const FunctionCallbackInfo<Value>& args);
657-
static void Destroy(const FunctionCallbackInfo<Value>& args);
658-
static void Settings(const FunctionCallbackInfo<Value>& args);
659-
static void Request(const FunctionCallbackInfo<Value>& args);
660-
static void SetNextStreamID(const FunctionCallbackInfo<Value>& args);
661-
static void Goaway(const FunctionCallbackInfo<Value>& args);
662-
static void UpdateChunksSent(const FunctionCallbackInfo<Value>& args);
663-
static void RefreshState(const FunctionCallbackInfo<Value>& args);
664-
static void Ping(const FunctionCallbackInfo<Value>& args);
665-
static void AltSvc(const FunctionCallbackInfo<Value>& args);
666-
static void Origin(const FunctionCallbackInfo<Value>& args);
648+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
649+
static void Consume(const v8::FunctionCallbackInfo<v8::Value>& args);
650+
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
651+
static void Settings(const v8::FunctionCallbackInfo<v8::Value>& args);
652+
static void Request(const v8::FunctionCallbackInfo<v8::Value>& args);
653+
static void SetNextStreamID(const v8::FunctionCallbackInfo<v8::Value>& args);
654+
static void Goaway(const v8::FunctionCallbackInfo<v8::Value>& args);
655+
static void UpdateChunksSent(const v8::FunctionCallbackInfo<v8::Value>& args);
656+
static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
657+
static void Ping(const v8::FunctionCallbackInfo<v8::Value>& args);
658+
static void AltSvc(const v8::FunctionCallbackInfo<v8::Value>& args);
659+
static void Origin(const v8::FunctionCallbackInfo<v8::Value>& args);
667660

668661
template <get_setting fn>
669-
static void RefreshSettings(const FunctionCallbackInfo<Value>& args);
662+
static void RefreshSettings(const v8::FunctionCallbackInfo<v8::Value>& args);
670663

671664
uv_loop_t* event_loop() const {
672665
return env()->event_loop();
@@ -877,15 +870,16 @@ class Http2Session : public AsyncWrap,
877870
friend class Http2StreamListener;
878871
};
879872

880-
class Http2SessionPerformanceEntry : public PerformanceEntry {
873+
class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
881874
public:
882875
Http2SessionPerformanceEntry(
883876
Environment* env,
884877
const Http2Session::Statistics& stats,
885878
nghttp2_session_type type) :
886-
PerformanceEntry(env, "Http2Session", "http2",
887-
stats.start_time,
888-
stats.end_time),
879+
performance::PerformanceEntry(
880+
env, "Http2Session", "http2",
881+
stats.start_time,
882+
stats.end_time),
889883
ping_rtt_(stats.ping_rtt),
890884
data_sent_(stats.data_sent),
891885
data_received_(stats.data_received),
@@ -906,8 +900,8 @@ class Http2SessionPerformanceEntry : public PerformanceEntry {
906900
double stream_average_duration() const { return stream_average_duration_; }
907901
nghttp2_session_type type() const { return session_type_; }
908902

909-
void Notify(Local<Value> obj) {
910-
PerformanceEntry::Notify(env(), kind(), obj);
903+
void Notify(v8::Local<v8::Value> obj) {
904+
performance::PerformanceEntry::Notify(env(), kind(), obj);
911905
}
912906

913907
private:
@@ -922,15 +916,17 @@ class Http2SessionPerformanceEntry : public PerformanceEntry {
922916
nghttp2_session_type session_type_;
923917
};
924918

925-
class Http2StreamPerformanceEntry : public PerformanceEntry {
919+
class Http2StreamPerformanceEntry
920+
: public performance::PerformanceEntry {
926921
public:
927922
Http2StreamPerformanceEntry(
928923
Environment* env,
929924
int32_t id,
930925
const Http2Stream::Statistics& stats) :
931-
PerformanceEntry(env, "Http2Stream", "http2",
932-
stats.start_time,
933-
stats.end_time),
926+
performance::PerformanceEntry(
927+
env, "Http2Stream", "http2",
928+
stats.start_time,
929+
stats.end_time),
934930
id_(id),
935931
first_header_(stats.first_header),
936932
first_byte_(stats.first_byte),
@@ -945,8 +941,8 @@ class Http2StreamPerformanceEntry : public PerformanceEntry {
945941
uint64_t sent_bytes() const { return sent_bytes_; }
946942
uint64_t received_bytes() const { return received_bytes_; }
947943

948-
void Notify(Local<Value> obj) {
949-
PerformanceEntry::Notify(env(), kind(), obj);
944+
void Notify(v8::Local<v8::Value> obj) {
945+
performance::PerformanceEntry::Notify(env(), kind(), obj);
950946
}
951947

952948
private:
@@ -999,7 +995,7 @@ class Http2Session::Http2Settings : public AsyncWrap {
999995
void Done(bool ack);
1000996

1001997
// Returns a Buffer instance with the serialized SETTINGS payload
1002-
Local<Value> Pack();
998+
v8::Local<v8::Value> Pack();
1003999

10041000
// Resets the default values in the settings buffer
10051001
static void RefreshDefaults(Environment* env);
@@ -1019,9 +1015,9 @@ class Http2Session::Http2Settings : public AsyncWrap {
10191015

10201016
class Origins {
10211017
public:
1022-
Origins(Isolate* isolate,
1023-
Local<Context> context,
1024-
Local<v8::String> origin_string,
1018+
Origins(v8::Isolate* isolate,
1019+
v8::Local<v8::Context> context,
1020+
v8::Local<v8::String> origin_string,
10251021
size_t origin_count);
10261022
~Origins() = default;
10271023

0 commit comments

Comments
 (0)