Skip to content

Commit 1c4a112

Browse files
jasnellMylesBorins
authored andcommitted
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 7904ecd commit 1c4a112

8 files changed

Lines changed: 192 additions & 175 deletions

File tree

‎src/node_http2.cc‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,37 @@
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
namespacenode {
1718

19+
using v8::Array;
1820
using v8::ArrayBuffer;
1921
using v8::ArrayBufferView;
2022
using v8::Boolean;
2123
using v8::Context;
2224
using v8::Float64Array;
2325
using v8::Function;
26+
using v8::FunctionCallbackInfo;
27+
using v8::FunctionTemplate;
28+
using v8::HandleScope;
2429
using v8::Integer;
30+
using v8::Isolate;
31+
using v8::Local;
32+
using v8::MaybeLocal;
2533
using v8::NewStringType;
2634
using v8::Number;
35+
using v8::Object;
2736
using v8::ObjectTemplate;
2837
using v8::String;
2938
using v8::Uint32;
3039
using v8::Uint32Array;
3140
using v8::Uint8Array;
3241
using v8::Undefined;
42+
using v8::Value;
3343

3444
using node::performance::PerformanceEntry;
3545
namespacehttp2 {

‎src/node_http2.h‎

Lines changed: 48 additions & 52 deletions
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
namespacenode {
2121
namespacehttp2 {
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
classHttp2Priority {
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() constoverride;
411404

412405
// JavaScript API
413-
staticvoidGetID(const FunctionCallbackInfo<Value>& args);
414-
staticvoidDestroy(const FunctionCallbackInfo<Value>& args);
415-
staticvoidPriority(const FunctionCallbackInfo<Value>& args);
416-
staticvoidPushPromise(const FunctionCallbackInfo<Value>& args);
417-
staticvoidRefreshState(const FunctionCallbackInfo<Value>& args);
418-
staticvoidInfo(const FunctionCallbackInfo<Value>& args);
419-
staticvoidTrailers(const FunctionCallbackInfo<Value>& args);
420-
staticvoidRespond(const FunctionCallbackInfo<Value>& args);
421-
staticvoidRstStream(const FunctionCallbackInfo<Value>& args);
406+
staticvoidGetID(constv8::FunctionCallbackInfo<v8::Value>& args);
407+
staticvoidDestroy(constv8::FunctionCallbackInfo<v8::Value>& args);
408+
staticvoidPriority(constv8::FunctionCallbackInfo<v8::Value>& args);
409+
staticvoidPushPromise(constv8::FunctionCallbackInfo<v8::Value>& args);
410+
staticvoidRefreshState(constv8::FunctionCallbackInfo<v8::Value>& args);
411+
staticvoidInfo(constv8::FunctionCallbackInfo<v8::Value>& args);
412+
staticvoidTrailers(constv8::FunctionCallbackInfo<v8::Value>& args);
413+
staticvoidRespond(constv8::FunctionCallbackInfo<v8::Value>& args);
414+
staticvoidRstStream(constv8::FunctionCallbackInfo<v8::Value>& args);
422415

423416
classProvider;
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
voidClose(uint32_t code = NGHTTP2_NO_ERROR,
557550
bool socket_closed = false);
558-
voidConsume(Local<Object> stream);
551+
voidConsume(v8::Local<v8::Object> stream);
559552
voidGoaway(uint32_t code, int32_t lastStreamID,
560553
constuint8_t* data, size_t len);
561554
voidAltSvc(int32_t id,
@@ -652,21 +645,21 @@ class Http2Session : public AsyncWrap,
652645
voidDecreaseAllocatedSize(size_t size);
653646

654647
// The JavaScript API
655-
staticvoidNew(const FunctionCallbackInfo<Value>& args);
656-
staticvoidConsume(const FunctionCallbackInfo<Value>& args);
657-
staticvoidDestroy(const FunctionCallbackInfo<Value>& args);
658-
staticvoidSettings(const FunctionCallbackInfo<Value>& args);
659-
staticvoidRequest(const FunctionCallbackInfo<Value>& args);
660-
staticvoidSetNextStreamID(const FunctionCallbackInfo<Value>& args);
661-
staticvoidGoaway(const FunctionCallbackInfo<Value>& args);
662-
staticvoidUpdateChunksSent(const FunctionCallbackInfo<Value>& args);
663-
staticvoidRefreshState(const FunctionCallbackInfo<Value>& args);
664-
staticvoidPing(const FunctionCallbackInfo<Value>& args);
665-
staticvoidAltSvc(const FunctionCallbackInfo<Value>& args);
666-
staticvoidOrigin(const FunctionCallbackInfo<Value>& args);
648+
staticvoidNew(constv8::FunctionCallbackInfo<v8::Value>& args);
649+
staticvoidConsume(constv8::FunctionCallbackInfo<v8::Value>& args);
650+
staticvoidDestroy(constv8::FunctionCallbackInfo<v8::Value>& args);
651+
staticvoidSettings(constv8::FunctionCallbackInfo<v8::Value>& args);
652+
staticvoidRequest(constv8::FunctionCallbackInfo<v8::Value>& args);
653+
staticvoidSetNextStreamID(constv8::FunctionCallbackInfo<v8::Value>& args);
654+
staticvoidGoaway(constv8::FunctionCallbackInfo<v8::Value>& args);
655+
staticvoidUpdateChunksSent(constv8::FunctionCallbackInfo<v8::Value>& args);
656+
staticvoidRefreshState(constv8::FunctionCallbackInfo<v8::Value>& args);
657+
staticvoidPing(constv8::FunctionCallbackInfo<v8::Value>& args);
658+
staticvoidAltSvc(constv8::FunctionCallbackInfo<v8::Value>& args);
659+
staticvoidOrigin(constv8::FunctionCallbackInfo<v8::Value>& args);
667660

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

671664
uv_loop_t* event_loop() const {
672665
returnenv()->event_loop();
@@ -876,15 +869,16 @@ class Http2Session : public AsyncWrap,
876869
friendclassHttp2StreamListener;
877870
};
878871

879-
classHttp2SessionPerformanceEntry : publicPerformanceEntry {
872+
classHttp2SessionPerformanceEntry : publicperformance::PerformanceEntry {
880873
public:
881874
Http2SessionPerformanceEntry(
882875
Environment* env,
883876
const Http2Session::Statistics& stats,
884877
nghttp2_session_type type) :
885-
PerformanceEntry(env, "Http2Session", "http2",
886-
stats.start_time,
887-
stats.end_time),
878+
performance::PerformanceEntry(
879+
env, "Http2Session", "http2",
880+
stats.start_time,
881+
stats.end_time),
888882
ping_rtt_(stats.ping_rtt),
889883
data_sent_(stats.data_sent),
890884
data_received_(stats.data_received),
@@ -905,8 +899,8 @@ class Http2SessionPerformanceEntry : public PerformanceEntry {
905899
doublestream_average_duration() const { return stream_average_duration_; }
906900
nghttp2_session_type type() const { return session_type_; }
907901

908-
voidNotify(Local<Value> obj) {
909-
PerformanceEntry::Notify(env(), kind(), obj);
902+
voidNotify(v8::Local<v8::Value> obj) {
903+
performance::PerformanceEntry::Notify(env(), kind(), obj);
910904
}
911905

912906
private:
@@ -921,15 +915,17 @@ class Http2SessionPerformanceEntry : public PerformanceEntry {
921915
nghttp2_session_type session_type_;
922916
};
923917

924-
classHttp2StreamPerformanceEntry : publicPerformanceEntry {
918+
classHttp2StreamPerformanceEntry
919+
: public performance::PerformanceEntry {
925920
public:
926921
Http2StreamPerformanceEntry(
927922
Environment* env,
928923
int32_t id,
929924
const Http2Stream::Statistics& stats) :
930-
PerformanceEntry(env, "Http2Stream", "http2",
931-
stats.start_time,
932-
stats.end_time),
925+
performance::PerformanceEntry(
926+
env, "Http2Stream", "http2",
927+
stats.start_time,
928+
stats.end_time),
933929
id_(id),
934930
first_header_(stats.first_header),
935931
first_byte_(stats.first_byte),
@@ -944,8 +940,8 @@ class Http2StreamPerformanceEntry : public PerformanceEntry {
944940
uint64_tsent_bytes() const { return sent_bytes_; }
945941
uint64_treceived_bytes() const { return received_bytes_; }
946942

947-
voidNotify(Local<Value> obj) {
948-
PerformanceEntry::Notify(env(), kind(), obj);
943+
voidNotify(v8::Local<v8::Value> obj) {
944+
performance::PerformanceEntry::Notify(env(), kind(), obj);
949945
}
950946

951947
private:
@@ -998,7 +994,7 @@ class Http2Session::Http2Settings : public AsyncWrap {
998994
voidDone(bool ack);
999995

1000996
// Returns a Buffer instance with the serialized SETTINGS payload
1001-
Local<Value> Pack();
997+
v8::Local<v8::Value> Pack();
1002998

1003999
// Resets the default values in the settings buffer
10041000
staticvoidRefreshDefaults(Environment* env);
@@ -1018,9 +1014,9 @@ class Http2Session::Http2Settings : public AsyncWrap {
10181014

10191015
classOrigins {
10201016
public:
1021-
Origins(Isolate* isolate,
1022-
Local<Context> context,
1023-
Local<v8::String> origin_string,
1017+
Origins(v8::Isolate* isolate,
1018+
v8::Local<v8::Context> context,
1019+
v8::Local<v8::String> origin_string,
10241020
size_t origin_count);
10251021
~Origins() = default;
10261022

0 commit comments

Comments
 (0)