GeezerVison is showing github.com — src: remove redundant qualifiers in src/quic · nodejs/node@4d86a42
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/quic/application.cc +9-10Lines changed: 9 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -155,7 +155,7 @@ bool Session::Application::CanAddHeader(size_t current_count, | 155 | 155 |
| 156 | 156 | bool Session::Application::SendHeaders(const Stream& stream, | 157 | 157 | HeadersKind kind, | 158 | | - const v8::Local<v8::Array>& headers, | | 158 | + const Local<v8::Array>& headers, | 159 | 159 | HeadersFlags flags) { | 160 | 160 | // By default do nothing. | 161 | 161 | return false; | @@ -184,10 +184,9 @@ void Session::Application::CollectSessionTicketAppData( | 184 | 184 |
| 185 | 185 | SessionTicket::AppData::Status | 186 | 186 | Session::Application::ExtractSessionTicketAppData( | 187 | | - const SessionTicket::AppData& app_data, | 188 | | - SessionTicket::AppData::Source::Flag flag) { | | 187 | + const SessionTicket::AppData& app_data, Flag flag) { | 189 | 188 | // By default we do not have any application data to retrieve. | 190 | | - return flag == SessionTicket::AppData::Source::Flag::STATUS_RENEW | | 189 | + return flag == Flag::STATUS_RENEW | 191 | 190 | ? SessionTicket::AppData::Status::TICKET_USE_RENEW | 192 | 191 | : SessionTicket::AppData::Status::TICKET_USE; | 193 | 192 | } | @@ -285,15 +284,15 @@ void Session::Application::SendPendingData() { | 285 | 284 | Debug(session_, "Failed to create packet for stream data"); | 286 | 285 | // Doh! Could not create a packet. Time to bail. | 287 | 286 | session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | 288 | | - return session_->Close(Session::CloseMethod::SILENT); | | 287 | + return session_->Close(CloseMethod::SILENT); | 289 | 288 | } | 290 | 289 |
| 291 | 290 | // The stream_data is the next block of data from the application stream. | 292 | 291 | if (GetStreamData(&stream_data) < 0) { | 293 | 292 | Debug(session_, "Application failed to get stream data"); | 294 | 293 | packet->Done(UV_ECANCELED); | 295 | 294 | session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | 296 | | - return session_->Close(Session::CloseMethod::SILENT); | | 295 | + return session_->Close(CloseMethod::SILENT); | 297 | 296 | } | 298 | 297 |
| 299 | 298 | // If we got here, we were at least successful in checking for stream data. | @@ -374,7 +373,7 @@ void Session::Application::SendPendingData() { | 374 | 373 | ngtcp2_strerror(nwrite)); | 375 | 374 | packet->Done(UV_ECANCELED); | 376 | 375 | session_->SetLastError(QuicError::ForNgtcp2Error(nwrite)); | 377 | | - return session_->Close(Session::CloseMethod::SILENT); | | 376 | + return session_->Close(CloseMethod::SILENT); | 378 | 377 | } else if (ndatalen >= 0 && !StreamCommit(&stream_data, ndatalen)) { | 379 | 378 | packet->Done(UV_ECANCELED); | 380 | 379 | session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | @@ -601,13 +600,13 @@ class DefaultApplication final : public Session::Application { | 601 | 600 | }; | 602 | 601 |
| 603 | 602 | std::unique_ptr<Session::Application> Session::SelectApplication( | 604 | | - Session* session, const Session::Config& config) { | | 603 | + Session* session, const Config& config) { | 605 | 604 | if (config.options.application_provider) { | 606 | 605 | return config.options.application_provider->Create(session); | 607 | 606 | } | 608 | 607 |
| 609 | | - return std::make_unique<DefaultApplication>( | 610 | | - session, Session::Application_Options::kDefault); | | 608 | + return std::make_unique<DefaultApplication>(session, | | 609 | + Application_Options::kDefault); | 611 | 610 | } | 612 | 611 |
| 613 | 612 | } // namespace quic | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/bindingdata.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -143,7 +143,7 @@ QUIC_JS_CALLBACKS(V) | 143 | 143 | void BindingData::SetCallbacks(const FunctionCallbackInfo<Value>& args) { | 144 | 144 | auto env = Environment::GetCurrent(args); | 145 | 145 | auto isolate = env->isolate(); | 146 | | - auto& state = BindingData::Get(env); | | 146 | + auto& state = Get(env); | 147 | 147 | CHECK(args[0]->IsObject()); | 148 | 148 | Local<Object> obj = args[0].As<Object>(); | 149 | 149 |
| @@ -164,7 +164,7 @@ void BindingData::SetCallbacks(const FunctionCallbackInfo<Value>& args) { | 164 | 164 |
| 165 | 165 | void BindingData::FlushPacketFreelist(const FunctionCallbackInfo<Value>& args) { | 166 | 166 | auto env = Environment::GetCurrent(args); | 167 | | - auto& state = BindingData::Get(env); | | 167 | + auto& state = Get(env); | 168 | 168 | state.packet_freelist.clear(); | 169 | 169 | } | 170 | 170 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/quic/data.cc +11-16Lines changed: 11 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,14 +88,14 @@ Store::Store(std::unique_ptr<v8::BackingStore> store, | 88 | 88 | CHECK_LE(length_, store_->ByteLength() - offset_); | 89 | 89 | } | 90 | 90 |
| 91 | | -Store::Store(v8::Local<v8::ArrayBuffer> buffer, Option option) | | 91 | +Store::Store(Local<v8::ArrayBuffer> buffer, Option option) | 92 | 92 | : Store(buffer->GetBackingStore(), buffer->ByteLength()) { | 93 | 93 | if (option == Option::DETACH) { | 94 | 94 | USE(buffer->Detach(Local<Value>())); | 95 | 95 | } | 96 | 96 | } | 97 | 97 |
| 98 | | -Store::Store(v8::Local<v8::ArrayBufferView> view, Option option) | | 98 | +Store::Store(Local<v8::ArrayBufferView> view, Option option) | 99 | 99 | : Store(view->Buffer()->GetBackingStore(), | 100 | 100 | view->ByteLength(), | 101 | 101 | view->ByteOffset()) { | @@ -104,7 +104,7 @@ Store::Store(v8::Local<v8::ArrayBufferView> view, Option option) | 104 | 104 | } | 105 | 105 | } | 106 | 106 |
| 107 | | -v8::Local<v8::Uint8Array> Store::ToUint8Array(Environment* env) const { | | 107 | +Local<Uint8Array> Store::ToUint8Array(Environment* env) const { | 108 | 108 | return !store_ | 109 | 109 | ? Uint8Array::New(v8::ArrayBuffer::New(env->isolate(), 0), 0, 0) | 110 | 110 | : Uint8Array::New(v8::ArrayBuffer::New(env->isolate(), store_), | @@ -257,11 +257,9 @@ std::optional<int> QuicError::crypto_error() const { | 257 | 257 | } | 258 | 258 |
| 259 | 259 | MaybeLocal<Value> QuicError::ToV8Value(Environment* env) const { | 260 | | - if ((type() == QuicError::Type::TRANSPORT && code() == NGTCP2_NO_ERROR) || | 261 | | - (type() == QuicError::Type::APPLICATION && | 262 | | - code() == NGTCP2_APP_NOERROR) || | 263 | | - (type() == QuicError::Type::APPLICATION && | 264 | | - code() == NGHTTP3_H3_NO_ERROR)) { | | 260 | + if ((type() == Type::TRANSPORT && code() == NGTCP2_NO_ERROR) || | | 261 | + (type() == Type::APPLICATION && code() == NGTCP2_APP_NOERROR) || | | 262 | + (type() == Type::APPLICATION && code() == NGHTTP3_H3_NO_ERROR)) { | 265 | 263 | return Undefined(env->isolate()); | 266 | 264 | } | 267 | 265 |
| @@ -331,14 +329,11 @@ QuicError QuicError::FromConnectionClose(ngtcp2_conn* session) { | 331 | 329 | return QuicError(ngtcp2_conn_get_ccerr(session)); | 332 | 330 | } | 333 | 331 |
| 334 | | -QuicError QuicError::TRANSPORT_NO_ERROR = | 335 | | - QuicError::ForTransport(QuicError::QUIC_NO_ERROR); | 336 | | -QuicError QuicError::APPLICATION_NO_ERROR = | 337 | | - QuicError::ForApplication(QuicError::QUIC_APP_NO_ERROR); | 338 | | -QuicError QuicError::VERSION_NEGOTIATION = QuicError::ForVersionNegotiation(); | 339 | | -QuicError QuicError::IDLE_CLOSE = QuicError::ForIdleClose(); | 340 | | -QuicError QuicError::INTERNAL_ERROR = | 341 | | - QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL); | | 332 | +QuicError QuicError::TRANSPORT_NO_ERROR = ForTransport(QUIC_NO_ERROR); | | 333 | +QuicError QuicError::APPLICATION_NO_ERROR = ForApplication(QUIC_APP_NO_ERROR); | | 334 | +QuicError QuicError::VERSION_NEGOTIATION = ForVersionNegotiation(); | | 335 | +QuicError QuicError::IDLE_CLOSE = ForIdleClose(); | | 336 | +QuicError QuicError::INTERNAL_ERROR = ForNgtcp2Error(NGTCP2_ERR_INTERNAL); | 342 | 337 |
| 343 | 338 | } // namespace quic | 344 | 339 | } // namespace node | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/endpoint.cc +8-10Lines changed: 8 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -177,7 +177,7 @@ bool SetOption(Environment* env, | 177 | 177 | Maybe<Endpoint::Options> Endpoint::Options::From(Environment* env, | 178 | 178 | Local<Value> value) { | 179 | 179 | if (value.IsEmpty() || !value->IsObject()) { | 180 | | - if (value->IsUndefined()) return Just(Endpoint::Options()); | | 180 | + if (value->IsUndefined()) return Just(Options()); | 181 | 181 | THROW_ERR_INVALID_ARG_TYPE(env, "options must be an object"); | 182 | 182 | return Nothing<Options>(); | 183 | 183 | } | @@ -213,7 +213,7 @@ Maybe<Endpoint::Options> Endpoint::Options::From(Environment* env, | 213 | 213 | "The address option must be a SocketAddress"); | 214 | 214 | return Nothing<Options>(); | 215 | 215 | } | 216 | | - auto addr = FromJSObject<SocketAddressBase>(address.As<v8::Object>()); | | 216 | + auto addr = FromJSObject<SocketAddressBase>(address.As<Object>()); | 217 | 217 | options.local_address = addr->address(); | 218 | 218 | } else { | 219 | 219 | options.local_address = std::make_shared<SocketAddress>(); | @@ -286,8 +286,7 @@ class Endpoint::UDP::Impl final : public HandleWrap { | 286 | 286 | if (tmpl.IsEmpty()) { | 287 | 287 | tmpl = NewFunctionTemplate(env->isolate(), IllegalConstructor); | 288 | 288 | tmpl->Inherit(HandleWrap::GetConstructorTemplate(env)); | 289 | | - tmpl->InstanceTemplate()->SetInternalFieldCount( | 290 | | - HandleWrap::kInternalFieldCount); | | 289 | + tmpl->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount); | 291 | 290 | tmpl->SetClassName(state.endpoint_udp_string()); | 292 | 291 | state.set_udp_constructor_template(tmpl); | 293 | 292 | } | @@ -317,7 +316,7 @@ class Endpoint::UDP::Impl final : public HandleWrap { | 317 | 316 | : HandleWrap(endpoint->env(), | 318 | 317 | object, | 319 | 318 | reinterpret_cast<uv_handle_t*>(&handle_), | 320 | | - AsyncWrap::PROVIDER_QUIC_UDP), | | 319 | + PROVIDER_QUIC_UDP), | 321 | 320 | endpoint_(endpoint) { | 322 | 321 | CHECK_EQ(uv_udp_init(endpoint->env()->event_loop(), &handle_), 0); | 323 | 322 | handle_.data = this; | @@ -376,7 +375,7 @@ Endpoint::UDP::~UDP() { | 376 | 375 | Close(); | 377 | 376 | } | 378 | 377 |
| 379 | | -int Endpoint::UDP::Bind(const Endpoint::Options& options) { | | 378 | +int Endpoint::UDP::Bind(const Options& options) { | 380 | 379 | if (is_bound_) return UV_EALREADY; | 381 | 380 | if (is_closed_or_closing()) return UV_EBADF; | 382 | 381 |
| @@ -521,8 +520,7 @@ Local<FunctionTemplate> Endpoint::GetConstructorTemplate(Environment* env) { | 521 | 520 | tmpl = NewFunctionTemplate(isolate, New); | 522 | 521 | tmpl->Inherit(AsyncWrap::GetConstructorTemplate(env)); | 523 | 522 | tmpl->SetClassName(state.endpoint_string()); | 524 | | - tmpl->InstanceTemplate()->SetInternalFieldCount( | 525 | | - Endpoint::kInternalFieldCount); | | 523 | + tmpl->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount); | 526 | 524 | SetProtoMethod(isolate, tmpl, "listen", DoListen); | 527 | 525 | SetProtoMethod(isolate, tmpl, "closeGracefully", DoCloseGracefully); | 528 | 526 | SetProtoMethod(isolate, tmpl, "connect", DoConnect); | @@ -612,8 +610,8 @@ void Endpoint::RegisterExternalReferences(ExternalReferenceRegistry* registry) { | 612 | 610 |
| 613 | 611 | Endpoint::Endpoint(Environment* env, | 614 | 612 | Local<Object> object, | 615 | | - const Endpoint::Options& options) | 616 | | - : AsyncWrap(env, object, AsyncWrap::PROVIDER_QUIC_ENDPOINT), | | 613 | + const Options& options) | | 614 | + : AsyncWrap(env, object, PROVIDER_QUIC_ENDPOINT), | 617 | 615 | stats_(env->isolate()), | 618 | 616 | state_(env->isolate()), | 619 | 617 | options_(options), | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/http3.cc +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,8 +42,7 @@ Local<FunctionTemplate> Http3Application::GetConstructorTemplate( | 42 | 42 | auto isolate = env->isolate(); | 43 | 43 | tmpl = NewFunctionTemplate(isolate, New); | 44 | 44 | tmpl->SetClassName(state.http3application_string()); | 45 | | - tmpl->InstanceTemplate()->SetInternalFieldCount( | 46 | | - Http3Application::kInternalFieldCount); | | 45 | + tmpl->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount); | 47 | 46 | state.set_http3application_constructor_template(tmpl); | 48 | 47 | } | 49 | 48 | return tmpl; | @@ -169,8 +168,7 @@ using Http3Header = NgHeader<Http3HeaderTraits>; | 169 | 168 | // Implements the low-level HTTP/3 Application semantics. | 170 | 169 | class Http3ApplicationImpl final : public Session::Application { | 171 | 170 | public: | 172 | | - Http3ApplicationImpl(Session* session, | 173 | | - const Session::Application::Options& options) | | 171 | + Http3ApplicationImpl(Session* session, const Options& options) | 174 | 172 | : Application(session, options), | 175 | 173 | allocator_(BindingData::Get(env())), | 176 | 174 | options_(options), | @@ -403,7 +401,7 @@ class Http3ApplicationImpl final : public Session::Application { | 403 | 401 |
| 404 | 402 | bool SendHeaders(const Stream& stream, | 405 | 403 | HeadersKind kind, | 406 | | - const v8::Local<v8::Array>& headers, | | 404 | + const Local<v8::Array>& headers, | 407 | 405 | HeadersFlags flags = HeadersFlags::NONE) override { | 408 | 406 | Session::SendPendingDataScope send_scope(&session()); | 409 | 407 | Http3Headers nva(env(), headers); | @@ -728,7 +726,7 @@ class Http3ApplicationImpl final : public Session::Application { | 728 | 726 |
| 729 | 727 | bool started_ = false; | 730 | 728 | nghttp3_mem allocator_; | 731 | | - Session::Application::Options options_; | | 729 | + Options options_; | 732 | 730 | Http3ConnectionPointer conn_; | 733 | 731 | int64_t control_stream_id_ = -1; | 734 | 732 | int64_t qpack_dec_stream_id_ = -1; | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/logstream.cc +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,7 +35,7 @@ Local<FunctionTemplate> LogStream::GetConstructorTemplate(Environment* env) { | 35 | 35 | } | 36 | 36 |
| 37 | 37 | BaseObjectPtr<LogStream> LogStream::Create(Environment* env) { | 38 | | - v8::Local<v8::Object> obj; | | 38 | + Local<Object> obj; | 39 | 39 | if (!GetConstructorTemplate(env) | 40 | 40 | ->InstanceTemplate() | 41 | 41 | ->NewInstance(env->context()) | @@ -46,9 +46,9 @@ BaseObjectPtr<LogStream> LogStream::Create(Environment* env) { | 46 | 46 | } | 47 | 47 |
| 48 | 48 | LogStream::LogStream(Environment* env, Local<Object> obj) | 49 | | - : AsyncWrap(env, obj, AsyncWrap::PROVIDER_QUIC_LOGSTREAM), StreamBase(env) { | | 49 | + : AsyncWrap(env, obj, PROVIDER_QUIC_LOGSTREAM), StreamBase(env) { | 50 | 50 | MakeWeak(); | 51 | | - StreamBase::AttachToObject(GetObject()); | | 51 | + AttachToObject(GetObject()); | 52 | 52 | } | 53 | 53 |
| 54 | 54 | void LogStream::Emit(const uint8_t* data, size_t len, EmitOption option) { | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/packet.cc +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -102,8 +102,7 @@ Local<FunctionTemplate> Packet::GetConstructorTemplate(Environment* env) { | 102 | 102 | if (tmpl.IsEmpty()) { | 103 | 103 | tmpl = NewFunctionTemplate(env->isolate(), IllegalConstructor); | 104 | 104 | tmpl->Inherit(ReqWrap<uv_udp_send_t>::GetConstructorTemplate(env)); | 105 | | - tmpl->InstanceTemplate()->SetInternalFieldCount( | 106 | | - Packet::kInternalFieldCount); | | 105 | + tmpl->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount); | 107 | 106 | tmpl->SetClassName(state.packetwrap_string()); | 108 | 107 | state.set_packet_constructor_template(tmpl); | 109 | 108 | } | @@ -174,7 +173,7 @@ Packet::Packet(Environment* env, | 174 | 173 | Local<Object> object, | 175 | 174 | const SocketAddress& destination, | 176 | 175 | std::shared_ptr<Data> data) | 177 | | - : ReqWrap<uv_udp_send_t>(env, object, AsyncWrap::PROVIDER_QUIC_PACKET), | | 176 | + : ReqWrap<uv_udp_send_t>(env, object, PROVIDER_QUIC_PACKET), | 178 | 177 | listener_(listener), | 179 | 178 | destination_(destination), | 180 | 179 | data_(std::move(data)) { | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/preferredaddress.cc +9-6Lines changed: 9 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,14 +55,14 @@ void copy_to_transport_params(ngtcp2_transport_params* params, | 55 | 55 | const sockaddr* addr) { | 56 | 56 | params->preferred_addr_present = true; | 57 | 57 | if constexpr (FAMILY == AF_INET) { | 58 | | - const sockaddr_in* src = reinterpret_cast<const sockaddr_in*>(addr); | | 58 | + const auto* src = reinterpret_cast<const sockaddr_in*>(addr); | 59 | 59 | params->preferred_addr.ipv4.sin_port = SocketAddress::GetPort(addr); | 60 | 60 | memcpy(¶ms->preferred_addr.ipv4.sin_addr, | 61 | 61 | &src->sin_addr, | 62 | 62 | sizeof(params->preferred_addr.ipv4.sin_addr)); | 63 | 63 | } else { | 64 | 64 | DCHECK_EQ(FAMILY, AF_INET6); | 65 | | - const sockaddr_in6* src = reinterpret_cast<const sockaddr_in6*>(addr); | | 65 | + const auto* src = reinterpret_cast<const sockaddr_in6*>(addr); | 66 | 66 | params->preferred_addr.ipv6.sin6_port = SocketAddress::GetPort(addr); | 67 | 67 | memcpy(¶ms->preferred_addr.ipv6.sin6_addr, | 68 | 68 | &src->sin6_addr, | @@ -136,29 +136,32 @@ void PreferredAddress::Set(ngtcp2_transport_params* params, | 136 | 136 | return copy_to_transport_params<AF_INET>(params, addr); | 137 | 137 | case AF_INET6: | 138 | 138 | return copy_to_transport_params<AF_INET6>(params, addr); | | 139 | + default: | | 140 | + UNREACHABLE("Unreachable"); | 139 | 141 | } | 140 | 142 | // Any other value is just ignored. | 141 | 143 | } | 142 | 144 |
| 143 | 145 | Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy( | 144 | 146 | Environment* env, Local<Value> value) { | 145 | 147 | if (value->IsUndefined()) { | 146 | | - return Just(PreferredAddress::Policy::USE_PREFERRED); | | 148 | + return Just(Policy::USE_PREFERRED); | 147 | 149 | } | 148 | 150 | if (value->IsUint32()) { | 149 | 151 | switch (value.As<Uint32>()->Value()) { | 150 | 152 | case PREFERRED_ADDRESS_IGNORE: | 151 | 153 | return Just(Policy::IGNORE_PREFERRED); | 152 | 154 | case PREFERRED_ADDRESS_USE: | 153 | 155 | return Just(Policy::USE_PREFERRED); | | 156 | + default: | | 157 | + UNREACHABLE("Unreachable"); | 154 | 158 | } | 155 | 159 | } | 156 | 160 | THROW_ERR_INVALID_ARG_VALUE(env, "invalid preferred address policy"); | 157 | | - return Nothing<PreferredAddress::Policy>(); | | 161 | + return Nothing<Policy>(); | 158 | 162 | } | 159 | 163 |
| 160 | | -void PreferredAddress::Initialize(Environment* env, | 161 | | - v8::Local<v8::Object> target) { | | 164 | +void PreferredAddress::Initialize(Environment* env, Local<v8::Object> target) { | 162 | 165 | NODE_DEFINE_CONSTANT(target, PREFERRED_ADDRESS_IGNORE); | 163 | 166 | NODE_DEFINE_CONSTANT(target, PREFERRED_ADDRESS_USE); | 164 | 167 | NODE_DEFINE_CONSTANT(target, DEFAULT_PREFERRED_ADDRESS_POLICY); | |
|