Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit f8a1fda

Browse files
jasnelladuh95
authored andcommitted
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c666056 commit f8a1fda

6 files changed

Lines changed: 57 additions & 35 deletions

File tree

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
2323
using v8::Function;
2424
using v8::FunctionTemplate;
2525
using v8::HandleScope;
26+
using v8::Isolate;
2627
using v8::Local;
2728
using v8::Object;
2829
using v8::String;
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
274275
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
275276
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
276277
voidnghttp3_debug_log(constchar* fmt, va_list args) {
277-
auto isolate = v8::Isolate::GetCurrent();
278+
auto isolate = Isolate::GetCurrent();
278279
if (isolate == nullptr) return;
279280
auto env = Environment::GetCurrent(isolate);
280281
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {

β€Žsrc/quic/data.ccβ€Ž

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ using v8::Array;
1717
using v8::ArrayBuffer;
1818
using v8::ArrayBufferView;
1919
using v8::BackingStore;
20+
using v8::BackingStoreInitializationMode;
21+
using v8::BackingStoreOnFailureMode;
2022
using v8::BigInt;
23+
using v8::Isolate;
2124
using v8::Just;
2225
using v8::Local;
2326
using v8::Maybe;
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
8992
}
9093

9194
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
92-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
95+
Isolate* isolate = Isolate::GetCurrent();
9396
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
9497
auto length = buffer->ByteLength();
9598
auto dest = ArrayBuffer::NewBackingStore(
9699
isolate,
97100
length,
98-
v8::BackingStoreInitializationMode::kUninitialized,
99-
v8::BackingStoreOnFailureMode::kReturnNull);
101+
BackingStoreInitializationMode::kUninitialized,
102+
BackingStoreOnFailureMode::kReturnNull);
100103
if (!dest) {
101104
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
102105
return Nothing<Store>();
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
108111
}
109112

110113
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
111-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
114+
Isolate* isolate = Isolate::GetCurrent();
112115
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
113116
auto length = view->ByteLength();
114117
auto offset = view->ByteOffset();
115118
auto dest = ArrayBuffer::NewBackingStore(
116119
isolate,
117120
length,
118-
v8::BackingStoreInitializationMode::kUninitialized,
119-
v8::BackingStoreOnFailureMode::kReturnNull);
121+
BackingStoreInitializationMode::kUninitialized,
122+
BackingStoreOnFailureMode::kReturnNull);
120123
if (!dest) {
121124
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
122125
return Nothing<Store>();
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
130133
}
131134

132135
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
133-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
Isolate* isolate = Isolate::GetCurrent();
134137
auto backing = buffer->GetBackingStore();
135138
auto length = buffer->ByteLength();
136139
auto dest = ArrayBuffer::NewBackingStore(
137-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
140+
isolate, length, BackingStoreInitializationMode::kUninitialized,
141+
BackingStoreOnFailureMode::kReturnNull);
142+
if (!dest) {
143+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
144+
returnStore();
145+
}
138146
// copy content
139147
memcpy(dest->Data(), backing->Data(), length);
140148
returnStore(std::move(dest), length, 0);
141149
}
142150

143151
Store Store::CopyFrom(Local<ArrayBufferView> view) {
144-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
152+
Isolate* isolate = Isolate::GetCurrent();
145153
auto backing = view->Buffer()->GetBackingStore();
146154
auto length = view->ByteLength();
147155
auto offset = view->ByteOffset();
148156
auto dest = ArrayBuffer::NewBackingStore(
149-
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
157+
isolate, length, BackingStoreInitializationMode::kUninitialized,
158+
BackingStoreOnFailureMode::kReturnNull);
150159
// copy content
160+
if (!dest) {
161+
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
162+
returnStore();
163+
}
151164
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
152165
returnStore(std::move(dest), length, 0);
153166
}

β€Žsrc/quic/preferredaddress.ccβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace node {
1717
using v8::Just;
1818
using v8::Local;
1919
using v8::Maybe;
20+
using v8::Object;
2021
using v8::Value;
2122

2223
namespacequic {
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
131132
: Just(FromV8Value<Policy>(value));
132133
}
133134

134-
voidPreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
135+
voidPreferredAddress::Initialize(Environment* env, Local<Object> target) {
135136
// The QUIC_* constants are expected to be exported out to be used on
136137
// the JavaScript side of the API.
137138
staticconstexprautoPREFERRED_ADDRESS_USE =

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ using v8::Array;
4040
using v8::ArrayBufferView;
4141
using v8::BigInt;
4242
using v8::Boolean;
43+
using v8::Function;
4344
using v8::FunctionCallbackInfo;
45+
using v8::Global;
4446
using v8::HandleScope;
4547
using v8::Int32;
4648
using v8::Integer;
@@ -54,6 +56,7 @@ using v8::Number;
5456
using v8::Object;
5557
using v8::ObjectTemplate;
5658
using v8::String;
59+
using v8::Uint32;
5760
using v8::Undefined;
5861
using v8::Value;
5962

@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
420423
template <typename Opt, uint8_t Opt::*member>
421424
boolSetOption(Environment* env,
422425
Opt* options,
423-
constv8::Local<v8::Object>& object,
424-
constv8::Local<v8::String>& name) {
425-
v8::Local<v8::Value> value;
426+
const Local<Object>& object,
427+
const Local<String>& name) {
428+
Local<Value> value;
426429
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
427430
if (!value->IsUndefined()) {
428431
if (!value->IsUint32()) {
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
431434
env, "The %s option must be an uint8", *nameStr);
432435
returnfalse;
433436
}
434-
uint32_t val = value.As<v8::Uint32>()->Value();
437+
uint32_t val = value.As<Uint32>()->Value();
435438
if (val > 255) {
436439
Utf8Value nameStr(env->isolate(), name);
437440
THROW_ERR_INVALID_ARG_VALUE(
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint,
17261729
Debug(this, "Session created.");
17271730

17281731
{
1729-
constv8::HandleScope handle_scope(env()->isolate());
1732+
const HandleScope handle_scope(env()->isolate());
17301733
JS_DEFINE_READONLY_PROPERTY(
17311734
env(),
17321735
object,
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint,
17361739
env(),
17371740
object,
17381741
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1739-
v8::Integer::NewFromUnsigned(
1742+
Integer::NewFromUnsigned(
17401743
env()->isolate(),
17411744
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
17421745
JS_DEFINE_READONLY_PROPERTY(
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint,
17481751
env(),
17491752
object,
17501753
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1751-
v8::Integer::NewFromUnsigned(
1754+
Integer::NewFromUnsigned(
17521755
env()->isolate(),
17531756
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
17541757
}
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
21352138
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
21362139
if (is_destroyed()) {
21372140
auto isolate = env()->isolate();
2138-
v8::Global<v8::Object> recv(isolate, object());
2139-
v8::Global<v8::Function> cb(
2141+
Global<Object> recv(isolate, object());
2142+
Global<Function> cb(
21402143
isolate, BindingData::Get(env()).session_qlog_callback());
21412144
std::string buf(data);
21422145
env()->SetImmediate([recv = std::move(recv),

β€Žsrc/quic/streams.ccβ€Ž

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using v8::BackingStore;
2626
using v8::BigInt;
2727
using v8::FunctionCallbackInfo;
2828
using v8::Global;
29+
using v8::HandleScope;
2930
using v8::Integer;
3031
using v8::Just;
3132
using v8::Local;
@@ -34,6 +35,7 @@ using v8::Nothing;
3435
using v8::Object;
3536
using v8::ObjectTemplate;
3637
using v8::SharedArrayBuffer;
38+
using v8::String;
3739
using v8::Uint32;
3840
using v8::Uint8Array;
3941
using v8::Value;
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
277279
// object's constructor name is "FileHandle".
278280
if (value->IsObject()) {
279281
auto obj = value.As<Object>();
280-
Local<v8::String> ctor_name;
282+
Local<String> ctor_name;
281283
auto maybe_name = obj->GetConstructorName();
282284
if (!maybe_name.IsEmpty()) {
283285
ctor_name = maybe_name;
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
287289
ASSIGN_OR_RETURN_UNWRAP(
288290
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
289291
Local<Value> path;
290-
if (!v8::String::NewFromUtf8(env->isolate(),
291-
file_handle->original_name().c_str())
292-
.ToLocal(&path)) {
292+
if (!ToV8Value(env->context(), file_handle->original_name())
293+
.ToLocal(&path)) {
293294
return Nothing<std::shared_ptr<DataQueue>>();
294295
}
295296
auto entry = DataQueue::CreateFdEntry(env, path);
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10481049
inbound_->addBackpressureListener(this);
10491050

10501051
{
1051-
constv8::HandleScope handle_scope(env()->isolate());
1052+
const HandleScope handle_scope(env()->isolate());
10521053
// Pass the page's shared views and this slot's byte offset. JS uses
10531054
// the offset to index into the shared view β€” no per-stream V8 object
10541055
// creation.
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10601061
env(),
10611062
object,
10621063
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1063-
v8::Integer::NewFromUnsigned(
1064+
Integer::NewFromUnsigned(
10641065
env()->isolate(),
10651066
static_cast<uint32_t>(state_slot_.GetByteOffset())));
10661067
JS_DEFINE_READONLY_PROPERTY(
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
10721073
env(),
10731074
object,
10741075
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1075-
v8::Integer::NewFromUnsigned(
1076+
Integer::NewFromUnsigned(
10761077
env()->isolate(),
10771078
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
10781079
}
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11071108
inbound_->addBackpressureListener(this);
11081109

11091110
{
1110-
constv8::HandleScope handle_scope(env()->isolate());
1111+
const HandleScope handle_scope(env()->isolate());
11111112
JS_DEFINE_READONLY_PROPERTY(env(),
11121113
object,
11131114
env()->state_string(),
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11161117
env(),
11171118
object,
11181119
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
1119-
v8::Integer::NewFromUnsigned(
1120+
Integer::NewFromUnsigned(
11201121
env()->isolate(),
11211122
static_cast<uint32_t>(state_slot_.GetByteOffset())));
11221123
JS_DEFINE_READONLY_PROPERTY(
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
11281129
env(),
11291130
object,
11301131
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
1131-
v8::Integer::NewFromUnsigned(
1132+
Integer::NewFromUnsigned(
11321133
env()->isolate(),
11331134
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
11341135
}

β€Žsrc/quic/tlscontext.ccβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
3030
using ncrypto::SSLPointer;
3131
using ncrypto::SSLSessionPointer;
3232
using ncrypto::X509Pointer;
33+
using v8::Array;
3334
using v8::ArrayBuffer;
35+
using v8::ArrayBufferView;
3436
using v8::Just;
3537
using v8::Local;
3638
using v8::Maybe;
3739
using v8::MaybeLocal;
3840
using v8::Nothing;
3941
using v8::Object;
42+
using v8::String;
4043
using v8::Undefined;
4144
using v8::Value;
4245

@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
9598
boolSetOption(Environment* env,
9699
Opt* options,
97100
const Local<Object>& object,
98-
const Local<v8::String>& name) {
101+
const Local<String>& name) {
99102
Local<Value> value;
100103
if (!object->Get(env->context(), name).ToLocal(&value)) returnfalse;
101104

@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
105108

106109
if (value->IsArray()) {
107110
auto context = env->context();
108-
auto values = value.As<v8::Array>();
111+
auto values = value.As<Array>();
109112
uint32_t count = values->Length();
110113
for (uint32_t n = 0; n < count; n++) {
111114
Local<Value> item;
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
125128
}
126129
} elseifconstexpr (std::is_same<T, Store>::value) {
127130
if (item->IsArrayBufferView()) {
128-
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
131+
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
129132
(options->*member).push_back(std::move(store));
130133
} elseif (item->IsArrayBuffer()) {
131134
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
154157
}
155158
} elseifconstexpr (std::is_same<T, Store>::value) {
156159
if (value->IsArrayBufferView()) {
157-
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
160+
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
158161
(options->*member).push_back(std::move(store));
159162
} elseif (value->IsArrayBuffer()) {
160163
Store store = Store::CopyFrom(value.As<ArrayBuffer>());

0 commit comments

Comments
Β (0)