Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c4a112

Browse filesBrowse 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
Copy full SHA for 1c4a112

File tree

Expand file treeCollapse file tree

8 files changed

+192
-175
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+192
-175
lines changed
Open diff view settings
Collapse file

‎src/node_http2.cc‎

Copy file name to clipboardExpand all lines: src/node_http2.cc
+10Lines 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
namespace node {
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
namespace http2 {
Collapse file

‎src/node_http2.h‎

Copy file name to clipboardExpand all lines: src/node_http2.h
+48-52Lines 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
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();
@@ -876,15 +869,16 @@ class Http2Session : public AsyncWrap,
876869
friend class Http2StreamListener;
877870
};
878871

879-
class Http2SessionPerformanceEntry : public PerformanceEntry {
872+
class Http2SessionPerformanceEntry : public performance::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
double stream_average_duration() const { return stream_average_duration_; }
906900
nghttp2_session_type type() const { return session_type_; }
907901

908-
void Notify(Local<Value> obj) {
909-
PerformanceEntry::Notify(env(), kind(), obj);
902+
void Notify(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-
class Http2StreamPerformanceEntry : public PerformanceEntry {
918+
class Http2StreamPerformanceEntry
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_t sent_bytes() const { return sent_bytes_; }
945941
uint64_t received_bytes() const { return received_bytes_; }
946942

947-
void Notify(Local<Value> obj) {
948-
PerformanceEntry::Notify(env(), kind(), obj);
943+
void Notify(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
void Done(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
static void RefreshDefaults(Environment* env);
@@ -1018,9 +1014,9 @@ class Http2Session::Http2Settings : public AsyncWrap {
10181014

10191015
class Origins {
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.