| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign; | |||
| 23 | 23 | using v8::Function; | |
| 24 | 24 | using v8::FunctionTemplate; | |
| 25 | 25 | using v8::HandleScope; | |
| 26 | + using v8::Isolate; | ||
| 26 | 27 | using v8::Local; | |
| 27 | 28 | using v8::Object; | |
| 28 | 29 | using v8::String; | |
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) { | |||
| 274 | 275 | // Forwards detailed(verbose) debugging information from nghttp3. Enabled using | |
| 275 | 276 | // the NODE_DEBUG_NATIVE=NGHTTP3 category. | |
| 276 | 277 | void nghttp3_debug_log(const char* fmt, va_list args) { | |
| 277 | - auto isolate = v8::Isolate::GetCurrent(); | ||
| 278 | + auto isolate = Isolate::GetCurrent(); | ||
| 278 | 279 | if (isolate == nullptr) return; | |
| 279 | 280 | auto env = Environment::GetCurrent(isolate); | |
| 280 | 281 | if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,10 @@ using v8::Array; | |||
| 17 | 17 | using v8::ArrayBuffer; | |
| 18 | 18 | using v8::ArrayBufferView; | |
| 19 | 19 | using v8::BackingStore; | |
| 20 | + using v8::BackingStoreInitializationMode; | ||
| 21 | + using v8::BackingStoreOnFailureMode; | ||
| 20 | 22 | using v8::BigInt; | |
| 23 | + using v8::Isolate; | ||
| 21 | 24 | using v8::Just; | |
| 22 | 25 | using v8::Local; | |
| 23 | 26 | using v8::Maybe; | |
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset) | |||
| 89 | 92 | } | |
| 90 | 93 | ||
| 91 | 94 | Maybe<Store> Store::From(Local<ArrayBuffer> buffer) { | |
| 92 | - v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 95 | + Isolate* isolate = Isolate::GetCurrent(); | ||
| 93 | 96 | Environment* env = Environment::GetCurrent(isolate->GetCurrentContext()); | |
| 94 | 97 | auto length = buffer->ByteLength(); | |
| 95 | 98 | auto dest = ArrayBuffer::NewBackingStore( | |
| 96 | 99 | isolate, | |
| 97 | 100 | length, | |
| 98 | - v8::BackingStoreInitializationMode::kUninitialized, | ||
| 99 | - v8::BackingStoreOnFailureMode::kReturnNull); | ||
| 101 | + BackingStoreInitializationMode::kUninitialized, | ||
| 102 | + BackingStoreOnFailureMode::kReturnNull); | ||
| 100 | 103 | if (!dest) { | |
| 101 | 104 | THROW_ERR_MEMORY_ALLOCATION_FAILED(env); | |
| 102 | 105 | return Nothing<Store>(); | |
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) { | |||
| 108 | 111 | } | |
| 109 | 112 | ||
| 110 | 113 | Maybe<Store> Store::From(Local<ArrayBufferView> view) { | |
| 111 | - v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 114 | + Isolate* isolate = Isolate::GetCurrent(); | ||
| 112 | 115 | Environment* env = Environment::GetCurrent(isolate->GetCurrentContext()); | |
| 113 | 116 | auto length = view->ByteLength(); | |
| 114 | 117 | auto offset = view->ByteOffset(); | |
| 115 | 118 | auto dest = ArrayBuffer::NewBackingStore( | |
| 116 | 119 | isolate, | |
| 117 | 120 | length, | |
| 118 | - v8::BackingStoreInitializationMode::kUninitialized, | ||
| 119 | - v8::BackingStoreOnFailureMode::kReturnNull); | ||
| 121 | + BackingStoreInitializationMode::kUninitialized, | ||
| 122 | + BackingStoreOnFailureMode::kReturnNull); | ||
| 120 | 123 | if (!dest) { | |
| 121 | 124 | THROW_ERR_MEMORY_ALLOCATION_FAILED(env); | |
| 122 | 125 | return Nothing<Store>(); | |
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) { | |||
| 130 | 133 | } | |
| 131 | 134 | ||
| 132 | 135 | Store Store::CopyFrom(Local<ArrayBuffer> buffer) { | |
| 133 | - v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 136 | + Isolate* isolate = Isolate::GetCurrent(); | ||
| 134 | 137 | auto backing = buffer->GetBackingStore(); | |
| 135 | 138 | auto length = buffer->ByteLength(); | |
| 136 | 139 | 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 | + return Store(); | ||
| 145 | + } | ||
| 138 | 146 | // copy content | |
| 139 | 147 | memcpy(dest->Data(), backing->Data(), length); | |
| 140 | 148 | return Store(std::move(dest), length, 0); | |
| 141 | 149 | } | |
| 142 | 150 | ||
| 143 | 151 | Store Store::CopyFrom(Local<ArrayBufferView> view) { | |
| 144 | - v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 152 | + Isolate* isolate = Isolate::GetCurrent(); | ||
| 145 | 153 | auto backing = view->Buffer()->GetBackingStore(); | |
| 146 | 154 | auto length = view->ByteLength(); | |
| 147 | 155 | auto offset = view->ByteOffset(); | |
| 148 | 156 | auto dest = ArrayBuffer::NewBackingStore( | |
| 149 | - isolate, length, v8::BackingStoreInitializationMode::kUninitialized); | ||
| 157 | + isolate, length, BackingStoreInitializationMode::kUninitialized, | ||
| 158 | + BackingStoreOnFailureMode::kReturnNull); | ||
| 150 | 159 | // copy content | |
| 160 | + if (!dest) { | ||
| 161 | + THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate)); | ||
| 162 | + return Store(); | ||
| 163 | + } | ||
| 151 | 164 | memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length); | |
| 152 | 165 | return Store(std::move(dest), length, 0); | |
| 153 | 166 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ namespace node { | |||
| 17 | 17 | using v8::Just; | |
| 18 | 18 | using v8::Local; | |
| 19 | 19 | using v8::Maybe; | |
| 20 | + using v8::Object; | ||
| 20 | 21 | using v8::Value; | |
| 21 | 22 | ||
| 22 | 23 | namespace quic { | |
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy( | |||
| 131 | 132 | : Just(FromV8Value<Policy>(value)); | |
| 132 | 133 | } | |
| 133 | 134 | ||
| 134 | - void PreferredAddress::Initialize(Environment* env, Local<v8::Object> target) { | ||
| 135 | + void PreferredAddress::Initialize(Environment* env, Local<Object> target) { | ||
| 135 | 136 | // The QUIC_* constants are expected to be exported out to be used on | |
| 136 | 137 | // the JavaScript side of the API. | |
| 137 | 138 | static constexpr auto PREFERRED_ADDRESS_USE = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,9 @@ using v8::Array; | |||
| 40 | 40 | using v8::ArrayBufferView; | |
| 41 | 41 | using v8::BigInt; | |
| 42 | 42 | using v8::Boolean; | |
| 43 | + using v8::Function; | ||
| 43 | 44 | using v8::FunctionCallbackInfo; | |
| 45 | + using v8::Global; | ||
| 44 | 46 | using v8::HandleScope; | |
| 45 | 47 | using v8::Int32; | |
| 46 | 48 | using v8::Integer; | |
@@ -54,6 +56,7 @@ using v8::Number; | |||
| 54 | 56 | using v8::Object; | |
| 55 | 57 | using v8::ObjectTemplate; | |
| 56 | 58 | using v8::String; | |
| 59 | + using v8::Uint32; | ||
| 57 | 60 | using v8::Undefined; | |
| 58 | 61 | using v8::Value; | |
| 59 | 62 | ||
@@ -420,9 +423,9 @@ bool SetOption(Environment* env, | |||
| 420 | 423 | template <typename Opt, uint8_t Opt::*member> | |
| 421 | 424 | bool SetOption(Environment* env, | |
| 422 | 425 | Opt* options, | |
| 423 | - const v8::Local<v8::Object>& object, | ||
| 424 | - const v8::Local<v8::String>& name) { | ||
| 425 | - v8::Local<v8::Value> value; | ||
| 426 | + const Local<Object>& object, | ||
| 427 | + const Local<String>& name) { | ||
| 428 | + Local<Value> value; | ||
| 426 | 429 | if (!object->Get(env->context(), name).ToLocal(&value)) return false; | |
| 427 | 430 | if (!value->IsUndefined()) { | |
| 428 | 431 | if (!value->IsUint32()) { | |
@@ -431,7 +434,7 @@ bool SetOption(Environment* env, | |||
| 431 | 434 | env, "The %s option must be an uint8", *nameStr); | |
| 432 | 435 | return false; | |
| 433 | 436 | } | |
| 434 | - uint32_t val = value.As<v8::Uint32>()->Value(); | ||
| 437 | + uint32_t val = value.As<Uint32>()->Value(); | ||
| 435 | 438 | if (val > 255) { | |
| 436 | 439 | Utf8Value nameStr(env->isolate(), name); | |
| 437 | 440 | THROW_ERR_INVALID_ARG_VALUE( | |
@@ -1726,7 +1729,7 @@ Session::Session(Endpoint* endpoint, | |||
| 1726 | 1729 | Debug(this, "Session created."); | |
| 1727 | 1730 | ||
| 1728 | 1731 | { | |
| 1729 | - const v8::HandleScope handle_scope(env()->isolate()); | ||
| 1732 | + const HandleScope handle_scope(env()->isolate()); | ||
| 1730 | 1733 | JS_DEFINE_READONLY_PROPERTY( | |
| 1731 | 1734 | env(), | |
| 1732 | 1735 | object, | |
@@ -1736,7 +1739,7 @@ Session::Session(Endpoint* endpoint, | |||
| 1736 | 1739 | env(), | |
| 1737 | 1740 | object, | |
| 1738 | 1741 | FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"), | |
| 1739 | - v8::Integer::NewFromUnsigned( | ||
| 1742 | + Integer::NewFromUnsigned( | ||
| 1740 | 1743 | env()->isolate(), | |
| 1741 | 1744 | static_cast<uint32_t>(impl_->state_slot_.GetByteOffset()))); | |
| 1742 | 1745 | JS_DEFINE_READONLY_PROPERTY( | |
@@ -1748,7 +1751,7 @@ Session::Session(Endpoint* endpoint, | |||
| 1748 | 1751 | env(), | |
| 1749 | 1752 | object, | |
| 1750 | 1753 | FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"), | |
| 1751 | - v8::Integer::NewFromUnsigned( | ||
| 1754 | + Integer::NewFromUnsigned( | ||
| 1752 | 1755 | env()->isolate(), | |
| 1753 | 1756 | static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset()))); | |
| 1754 | 1757 | } | |
@@ -2135,8 +2138,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) { | |||
| 2135 | 2138 | // ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate. | |
| 2136 | 2139 | if (is_destroyed()) { | |
| 2137 | 2140 | 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( | ||
| 2140 | 2143 | isolate, BindingData::Get(env()).session_qlog_callback()); | |
| 2141 | 2144 | std::string buf(data); | |
| 2142 | 2145 | env()->SetImmediate([recv = std::move(recv), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ using v8::BackingStore; | |||
| 26 | 26 | using v8::BigInt; | |
| 27 | 27 | using v8::FunctionCallbackInfo; | |
| 28 | 28 | using v8::Global; | |
| 29 | + using v8::HandleScope; | ||
| 29 | 30 | using v8::Integer; | |
| 30 | 31 | using v8::Just; | |
| 31 | 32 | using v8::Local; | |
@@ -34,6 +35,7 @@ using v8::Nothing; | |||
| 34 | 35 | using v8::Object; | |
| 35 | 36 | using v8::ObjectTemplate; | |
| 36 | 37 | using v8::SharedArrayBuffer; | |
| 38 | + using v8::String; | ||
| 37 | 39 | using v8::Uint32; | |
| 38 | 40 | using v8::Uint8Array; | |
| 39 | 41 | using v8::Value; | |
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource( | |||
| 277 | 279 | // object's constructor name is "FileHandle". | |
| 278 | 280 | if (value->IsObject()) { | |
| 279 | 281 | auto obj = value.As<Object>(); | |
| 280 | - Local<v8::String> ctor_name; | ||
| 282 | + Local<String> ctor_name; | ||
| 281 | 283 | auto maybe_name = obj->GetConstructorName(); | |
| 282 | 284 | if (!maybe_name.IsEmpty()) { | |
| 283 | 285 | ctor_name = maybe_name; | |
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource( | |||
| 287 | 289 | ASSIGN_OR_RETURN_UNWRAP( | |
| 288 | 290 | &file_handle, value, Nothing<std::shared_ptr<DataQueue>>()); | |
| 289 | 291 | 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)) { | ||
| 293 | 294 | return Nothing<std::shared_ptr<DataQueue>>(); | |
| 294 | 295 | } | |
| 295 | 296 | auto entry = DataQueue::CreateFdEntry(env, path); | |
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1048 | 1049 | inbound_->addBackpressureListener(this); | |
| 1049 | 1050 | ||
| 1050 | 1051 | { | |
| 1051 | - const v8::HandleScope handle_scope(env()->isolate()); | ||
| 1052 | + const HandleScope handle_scope(env()->isolate()); | ||
| 1052 | 1053 | // Pass the page's shared views and this slot's byte offset. JS uses | |
| 1053 | 1054 | // the offset to index into the shared view — no per-stream V8 object | |
| 1054 | 1055 | // creation. | |
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1060 | 1061 | env(), | |
| 1061 | 1062 | object, | |
| 1062 | 1063 | FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"), | |
| 1063 | - v8::Integer::NewFromUnsigned( | ||
| 1064 | + Integer::NewFromUnsigned( | ||
| 1064 | 1065 | env()->isolate(), | |
| 1065 | 1066 | static_cast<uint32_t>(state_slot_.GetByteOffset()))); | |
| 1066 | 1067 | JS_DEFINE_READONLY_PROPERTY( | |
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1072 | 1073 | env(), | |
| 1073 | 1074 | object, | |
| 1074 | 1075 | FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"), | |
| 1075 | - v8::Integer::NewFromUnsigned( | ||
| 1076 | + Integer::NewFromUnsigned( | ||
| 1076 | 1077 | env()->isolate(), | |
| 1077 | 1078 | static_cast<uint32_t>(stats_slot_.GetByteOffset()))); | |
| 1078 | 1079 | } | |
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1107 | 1108 | inbound_->addBackpressureListener(this); | |
| 1108 | 1109 | ||
| 1109 | 1110 | { | |
| 1110 | - const v8::HandleScope handle_scope(env()->isolate()); | ||
| 1111 | + const HandleScope handle_scope(env()->isolate()); | ||
| 1111 | 1112 | JS_DEFINE_READONLY_PROPERTY(env(), | |
| 1112 | 1113 | object, | |
| 1113 | 1114 | env()->state_string(), | |
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1116 | 1117 | env(), | |
| 1117 | 1118 | object, | |
| 1118 | 1119 | FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"), | |
| 1119 | - v8::Integer::NewFromUnsigned( | ||
| 1120 | + Integer::NewFromUnsigned( | ||
| 1120 | 1121 | env()->isolate(), | |
| 1121 | 1122 | static_cast<uint32_t>(state_slot_.GetByteOffset()))); | |
| 1122 | 1123 | JS_DEFINE_READONLY_PROPERTY( | |
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session, | |||
| 1128 | 1129 | env(), | |
| 1129 | 1130 | object, | |
| 1130 | 1131 | FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"), | |
| 1131 | - v8::Integer::NewFromUnsigned( | ||
| 1132 | + Integer::NewFromUnsigned( | ||
| 1132 | 1133 | env()->isolate(), | |
| 1133 | 1134 | static_cast<uint32_t>(stats_slot_.GetByteOffset()))); | |
| 1134 | 1135 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer; | |||
| 30 | 30 | using ncrypto::SSLPointer; | |
| 31 | 31 | using ncrypto::SSLSessionPointer; | |
| 32 | 32 | using ncrypto::X509Pointer; | |
| 33 | + using v8::Array; | ||
| 33 | 34 | using v8::ArrayBuffer; | |
| 35 | + using v8::ArrayBufferView; | ||
| 34 | 36 | using v8::Just; | |
| 35 | 37 | using v8::Local; | |
| 36 | 38 | using v8::Maybe; | |
| 37 | 39 | using v8::MaybeLocal; | |
| 38 | 40 | using v8::Nothing; | |
| 39 | 41 | using v8::Object; | |
| 42 | + using v8::String; | ||
| 40 | 43 | using v8::Undefined; | |
| 41 | 44 | using v8::Value; | |
| 42 | 45 | ||
@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member> | |||
| 95 | 98 | bool SetOption(Environment* env, | |
| 96 | 99 | Opt* options, | |
| 97 | 100 | const Local<Object>& object, | |
| 98 | - const Local<v8::String>& name) { | ||
| 101 | + const Local<String>& name) { | ||
| 99 | 102 | Local<Value> value; | |
| 100 | 103 | if (!object->Get(env->context(), name).ToLocal(&value)) return false; | |
| 101 | 104 | ||
@@ -105,7 +108,7 @@ bool SetOption(Environment* env, | |||
| 105 | 108 | ||
| 106 | 109 | if (value->IsArray()) { | |
| 107 | 110 | auto context = env->context(); | |
| 108 | - auto values = value.As<v8::Array>(); | ||
| 111 | + auto values = value.As<Array>(); | ||
| 109 | 112 | uint32_t count = values->Length(); | |
| 110 | 113 | for (uint32_t n = 0; n < count; n++) { | |
| 111 | 114 | Local<Value> item; | |
@@ -125,7 +128,7 @@ bool SetOption(Environment* env, | |||
| 125 | 128 | } | |
| 126 | 129 | } else if constexpr (std::is_same<T, Store>::value) { | |
| 127 | 130 | if (item->IsArrayBufferView()) { | |
| 128 | - Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>()); | ||
| 131 | + Store store = Store::CopyFrom(item.As<ArrayBufferView>()); | ||
| 129 | 132 | (options->*member).push_back(std::move(store)); | |
| 130 | 133 | } else if (item->IsArrayBuffer()) { | |
| 131 | 134 | Store store = Store::CopyFrom(item.As<ArrayBuffer>()); | |
@@ -154,7 +157,7 @@ bool SetOption(Environment* env, | |||
| 154 | 157 | } | |
| 155 | 158 | } else if constexpr (std::is_same<T, Store>::value) { | |
| 156 | 159 | if (value->IsArrayBufferView()) { | |
| 157 | - Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>()); | ||
| 160 | + Store store = Store::CopyFrom(value.As<ArrayBufferView>()); | ||
| 158 | 161 | (options->*member).push_back(std::move(store)); | |
| 159 | 162 | } else if (value->IsArrayBuffer()) { | |
| 160 | 163 | Store store = Store::CopyFrom(value.As<ArrayBuffer>()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments