From 17a4a55da4a6e0fdb0122ca8af49b6eebab2f049 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 1 Apr 2024 16:47:37 -0700 Subject: [PATCH] [misc] add `final` on a bunch of classes that should not have subclasses (#36212) Closes #36212 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36212 from markdroth:subclass_final 7626ccd691e2218ae4f926e1e73defa1035c63ff PiperOrigin-RevId: 620990528 --- .../client_channel/client_channel_channelz.h | 2 +- .../client_channel/client_channel_filter.cc | 38 ++++++++++--------- .../client_channel/client_channel_filter.h | 9 +++-- .../client_channel/client_channel_internal.h | 2 +- .../client_channel_service_config.h | 7 ++-- src/core/client_channel/config_selector.h | 2 +- src/core/client_channel/dynamic_filters.h | 2 +- src/core/client_channel/http_proxy_mapper.h | 2 +- src/core/client_channel/retry_filter.h | 2 +- .../retry_filter_legacy_call_data.cc | 2 +- .../retry_filter_legacy_call_data.h | 6 +-- .../client_channel/retry_service_config.h | 6 +-- src/core/client_channel/retry_throttle.h | 5 ++- src/core/client_channel/subchannel.cc | 2 +- src/core/client_channel/subchannel.h | 8 ++-- .../subchannel_pool_interface.h | 2 +- .../client_channel/subchannel_stream_client.h | 4 +- src/core/ext/xds/certificate_provider_store.h | 5 ++- ...ile_watcher_certificate_provider_factory.h | 4 +- src/core/ext/xds/xds_api.h | 2 +- src/core/ext/xds/xds_audit_logger_registry.cc | 3 +- src/core/ext/xds/xds_audit_logger_registry.h | 2 +- src/core/ext/xds/xds_bootstrap_grpc.cc | 2 +- src/core/ext/xds/xds_bootstrap_grpc.h | 8 ++-- src/core/ext/xds/xds_certificate_provider.cc | 4 +- src/core/ext/xds/xds_certificate_provider.h | 2 +- src/core/ext/xds/xds_channel_stack_modifier.h | 3 +- src/core/ext/xds/xds_client.cc | 20 +++++----- src/core/ext/xds/xds_client.h | 2 +- src/core/ext/xds/xds_client_grpc.cc | 2 +- src/core/ext/xds/xds_client_grpc.h | 2 +- src/core/ext/xds/xds_client_stats.h | 7 ++-- .../ext/xds/xds_cluster_specifier_plugin.h | 4 +- src/core/ext/xds/xds_endpoint.h | 4 +- src/core/ext/xds/xds_health_status.h | 4 +- src/core/ext/xds/xds_http_fault_filter.h | 2 +- src/core/ext/xds/xds_http_filters.h | 4 +- src/core/ext/xds/xds_http_rbac_filter.h | 2 +- .../xds/xds_http_stateful_session_filter.h | 2 +- src/core/ext/xds/xds_lb_policy_registry.cc | 10 ++--- src/core/ext/xds/xds_lb_policy_registry.h | 2 +- src/core/ext/xds/xds_listener.h | 2 +- src/core/ext/xds/xds_route_config.h | 2 +- src/core/ext/xds/xds_routing.h | 2 +- src/core/ext/xds/xds_server_config_fetcher.cc | 22 ++++++----- src/core/ext/xds/xds_transport_grpc.cc | 2 +- src/core/ext/xds/xds_transport_grpc.h | 6 +-- src/core/lib/channel/channelz.h | 12 +++--- src/core/lib/channel/channelz_registry.h | 2 +- src/core/lib/surface/legacy_channel.cc | 4 +- src/core/lib/surface/legacy_channel.h | 2 +- src/core/load_balancing/address_filtering.cc | 2 +- src/core/load_balancing/address_filtering.h | 2 +- .../load_balancing/child_policy_handler.cc | 2 +- src/core/load_balancing/endpoint_list.cc | 2 +- .../grpclb/client_load_reporting_filter.h | 4 +- src/core/load_balancing/grpclb/grpclb.cc | 31 ++++++++------- .../grpclb/grpclb_client_stats.h | 2 +- .../load_balancing/health_check_client.cc | 6 +-- .../health_check_client_internal.h | 6 +-- src/core/load_balancing/lb_policy.h | 4 +- src/core/load_balancing/lb_policy_registry.h | 4 +- src/core/load_balancing/oob_backend_metric.cc | 6 +-- .../oob_backend_metric_internal.h | 4 +- .../outlier_detection/outlier_detection.cc | 22 +++++------ .../load_balancing/pick_first/pick_first.cc | 18 ++++----- src/core/load_balancing/priority/priority.cc | 15 ++++---- .../load_balancing/ring_hash/ring_hash.cc | 16 ++++---- src/core/load_balancing/ring_hash/ring_hash.h | 2 +- src/core/load_balancing/rls/rls.cc | 26 ++++++------- .../load_balancing/round_robin/round_robin.cc | 12 +++--- .../static_stride_scheduler.h | 2 +- .../weighted_round_robin.cc | 18 ++++----- .../weighted_target/weighted_target.cc | 14 +++---- src/core/load_balancing/xds/cds.cc | 8 ++-- .../load_balancing/xds/xds_cluster_impl.cc | 18 ++++----- .../load_balancing/xds/xds_cluster_manager.cc | 12 +++--- .../load_balancing/xds/xds_override_host.cc | 23 +++++------ .../load_balancing/xds/xds_override_host.h | 2 +- .../load_balancing/xds/xds_wrr_locality.cc | 6 +-- src/core/resolver/binder/binder_resolver.cc | 4 +- .../resolver/dns/c_ares/dns_resolver_ares.cc | 15 ++++---- .../dns/c_ares/grpc_ares_ev_driver_posix.cc | 4 +- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 6 +-- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 2 +- .../event_engine_client_channel_resolver.cc | 4 +- .../event_engine_client_channel_resolver.h | 4 +- src/core/resolver/dns/native/dns_resolver.cc | 6 +-- src/core/resolver/endpoint_addresses.h | 8 ++-- src/core/resolver/fake/fake_resolver.cc | 4 +- src/core/resolver/fake/fake_resolver.h | 2 +- .../google_c2p/google_c2p_resolver.cc | 7 ++-- src/core/resolver/resolver_registry.h | 4 +- .../resolver/sockaddr/sockaddr_resolver.cc | 12 +++--- .../resolver/xds/xds_dependency_manager.cc | 14 ++++--- .../resolver/xds/xds_dependency_manager.h | 6 +-- src/core/resolver/xds/xds_resolver.cc | 18 ++++----- .../resolver/xds/xds_resolver_attributes.h | 2 +- .../service_config_channel_arg_filter.cc | 2 +- .../service_config/service_config_parser.h | 2 +- 100 files changed, 352 insertions(+), 322 deletions(-) diff --git a/src/core/client_channel/client_channel_channelz.h b/src/core/client_channel/client_channel_channelz.h index d9601c118ee..8311b61356d 100644 --- a/src/core/client_channel/client_channel_channelz.h +++ b/src/core/client_channel/client_channel_channelz.h @@ -41,7 +41,7 @@ namespace grpc_core { namespace channelz { -class SubchannelNode : public BaseNode { +class SubchannelNode final : public BaseNode { public: SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes); ~SubchannelNode() override; diff --git a/src/core/client_channel/client_channel_filter.cc b/src/core/client_channel/client_channel_filter.cc index df6bc239955..16f94347e4e 100644 --- a/src/core/client_channel/client_channel_filter.cc +++ b/src/core/client_channel/client_channel_filter.cc @@ -191,7 +191,7 @@ class ClientChannelFilter::CallData { RefCountedPtr dynamic_filters_; }; -class ClientChannelFilter::FilterBasedCallData +class ClientChannelFilter::FilterBasedCallData final : public ClientChannelFilter::CallData { public: static grpc_error_handle Init(grpc_call_element* elem, @@ -311,7 +311,7 @@ class ClientChannelFilter::FilterBasedCallData grpc_error_handle cancel_error_; }; -class ClientChannelFilter::PromiseBasedCallData +class ClientChannelFilter::PromiseBasedCallData final : public ClientChannelFilter::CallData { public: explicit PromiseBasedCallData(ClientChannelFilter* chand) : chand_(chand) {} @@ -451,7 +451,7 @@ ClientChannelServiceConfigCallData* GetServiceConfigCallData( context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value); } -class DynamicTerminationFilter { +class DynamicTerminationFilter final { public: class CallData; @@ -496,7 +496,7 @@ class DynamicTerminationFilter { ClientChannelFilter* chand_; }; -class DynamicTerminationFilter::CallData { +class DynamicTerminationFilter::CallData final { public: static grpc_error_handle Init(grpc_call_element* elem, const grpc_call_element_args* args) { @@ -593,7 +593,7 @@ const grpc_channel_filter DynamicTerminationFilter::kFilterVtable = { // ClientChannelFilter::ResolverResultHandler // -class ClientChannelFilter::ResolverResultHandler +class ClientChannelFilter::ResolverResultHandler final : public Resolver::ResultHandler { public: explicit ResolverResultHandler(ClientChannelFilter* chand) : chand_(chand) { @@ -628,7 +628,8 @@ class ClientChannelFilter::ResolverResultHandler // underlying subchannel is shared between channels, this wrapper will only // be used within one channel, so it will always be synchronized by the // control plane work_serializer. -class ClientChannelFilter::SubchannelWrapper : public SubchannelInterface { +class ClientChannelFilter::SubchannelWrapper final + : public SubchannelInterface { public: SubchannelWrapper(ClientChannelFilter* chand, RefCountedPtr subchannel) @@ -771,7 +772,8 @@ class ClientChannelFilter::SubchannelWrapper : public SubchannelInterface { // This class handles things like hopping into the WorkSerializer // before passing notifications to the LB policy and propagating // keepalive information betwen subchannels. - class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface { + class WatcherWrapper final + : public Subchannel::ConnectivityStateWatcherInterface { public: WatcherWrapper( std::unique_ptr @@ -1024,7 +1026,7 @@ void ClientChannelFilter::ExternalConnectivityWatcher::RemoveWatcherLocked() { // ClientChannelFilter::ConnectivityWatcherAdder // -class ClientChannelFilter::ConnectivityWatcherAdder { +class ClientChannelFilter::ConnectivityWatcherAdder final { public: ConnectivityWatcherAdder( ClientChannelFilter* chand, grpc_connectivity_state initial_state, @@ -1057,7 +1059,7 @@ class ClientChannelFilter::ConnectivityWatcherAdder { // ClientChannelFilter::ConnectivityWatcherRemover // -class ClientChannelFilter::ConnectivityWatcherRemover { +class ClientChannelFilter::ConnectivityWatcherRemover final { public: ConnectivityWatcherRemover(ClientChannelFilter* chand, AsyncConnectivityStateWatcherInterface* watcher) @@ -1087,7 +1089,7 @@ class ClientChannelFilter::ConnectivityWatcherRemover { // ClientChannelFilter::ClientChannelControlHelper // -class ClientChannelFilter::ClientChannelControlHelper +class ClientChannelFilter::ClientChannelControlHelper final : public LoadBalancingPolicy::ChannelControlHelper { public: explicit ClientChannelControlHelper(ClientChannelFilter* chand) @@ -2478,7 +2480,8 @@ void ClientChannelFilter::FilterBasedCallData::PendingBatchesResume() { // A class to handle the call combiner cancellation callback for a // queued pick. -class ClientChannelFilter::FilterBasedCallData::ResolverQueuedCallCanceller { +class ClientChannelFilter::FilterBasedCallData::ResolverQueuedCallCanceller + final { public: explicit ResolverQueuedCallCanceller(FilterBasedCallData* calld) : calld_(calld) { @@ -2599,7 +2602,7 @@ void ClientChannelFilter::FilterBasedCallData:: // ClientChannelFilter::LoadBalancedCall::LbCallState // -class ClientChannelFilter::LoadBalancedCall::LbCallState +class ClientChannelFilter::LoadBalancedCall::LbCallState final : public ClientChannelLbCallState { public: explicit LbCallState(LoadBalancedCall* lb_call) : lb_call_(lb_call) {} @@ -2621,7 +2624,7 @@ class ClientChannelFilter::LoadBalancedCall::LbCallState // ClientChannelFilter::LoadBalancedCall::Metadata // -class ClientChannelFilter::LoadBalancedCall::Metadata +class ClientChannelFilter::LoadBalancedCall::Metadata final : public LoadBalancingPolicy::MetadataInterface { public: explicit Metadata(grpc_metadata_batch* batch) : batch_(batch) {} @@ -2661,7 +2664,7 @@ class ClientChannelFilter::LoadBalancedCall::Metadata } private: - class Encoder { + class Encoder final { public: void Encode(const Slice& key, const Slice& value) { out_.emplace_back(std::string(key.as_string_view()), @@ -2714,7 +2717,7 @@ ClientChannelFilter::LoadBalancedCall::LbCallState::GetCallAttemptTracer() // ClientChannelFilter::LoadBalancedCall::BackendMetricAccessor // -class ClientChannelFilter::LoadBalancedCall::BackendMetricAccessor +class ClientChannelFilter::LoadBalancedCall::BackendMetricAccessor final : public LoadBalancingPolicy::BackendMetricAccessor { public: BackendMetricAccessor(LoadBalancedCall* lb_call, @@ -2735,7 +2738,7 @@ class ClientChannelFilter::LoadBalancedCall::BackendMetricAccessor } private: - class BackendMetricAllocator : public BackendMetricAllocatorInterface { + class BackendMetricAllocator final : public BackendMetricAllocatorInterface { public: explicit BackendMetricAllocator(Arena* arena) : arena_(arena) {} @@ -3390,7 +3393,8 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: // because there may be multiple LB picks happening in parallel. // Instead, we will probably need to maintain a list in the CallData // object of pending LB picks to be cancelled when the closure runs. -class ClientChannelFilter::FilterBasedLoadBalancedCall::LbQueuedCallCanceller { +class ClientChannelFilter::FilterBasedLoadBalancedCall::LbQueuedCallCanceller + final { public: explicit LbQueuedCallCanceller( RefCountedPtr lb_call) diff --git a/src/core/client_channel/client_channel_filter.h b/src/core/client_channel/client_channel_filter.h index c9d983c2529..b3fc9839945 100644 --- a/src/core/client_channel/client_channel_filter.h +++ b/src/core/client_channel/client_channel_filter.h @@ -101,7 +101,7 @@ namespace grpc_core { -class ClientChannelFilter { +class ClientChannelFilter final { public: static const grpc_channel_filter kFilterVtableWithPromises; static const grpc_channel_filter kFilterVtableWithoutPromises; @@ -184,7 +184,8 @@ class ClientChannelFilter { // Represents a pending connectivity callback from an external caller // via grpc_client_channel_watch_connectivity_state(). - class ExternalConnectivityWatcher : public ConnectivityStateWatcherInterface { + class ExternalConnectivityWatcher final + : public ConnectivityStateWatcherInterface { public: ExternalConnectivityWatcher(ClientChannelFilter* chand, grpc_polling_entity pollent, @@ -469,7 +470,7 @@ class ClientChannelFilter::LoadBalancedCall grpc_call_context_element* const call_context_; }; -class ClientChannelFilter::FilterBasedLoadBalancedCall +class ClientChannelFilter::FilterBasedLoadBalancedCall final : public ClientChannelFilter::LoadBalancedCall { public: // If on_call_destruction_complete is non-null, then it will be @@ -595,7 +596,7 @@ class ClientChannelFilter::FilterBasedLoadBalancedCall grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; }; -class ClientChannelFilter::PromiseBasedLoadBalancedCall +class ClientChannelFilter::PromiseBasedLoadBalancedCall final : public ClientChannelFilter::LoadBalancedCall { public: PromiseBasedLoadBalancedCall(ClientChannelFilter* chand, diff --git a/src/core/client_channel/client_channel_internal.h b/src/core/client_channel/client_channel_internal.h index fc61b6685d9..3fdb7184b79 100644 --- a/src/core/client_channel/client_channel_internal.h +++ b/src/core/client_channel/client_channel_internal.h @@ -54,7 +54,7 @@ class ClientChannelLbCallState : public LoadBalancingPolicy::CallState { }; // Internal type for ServiceConfigCallData. Handles call commits. -class ClientChannelServiceConfigCallData : public ServiceConfigCallData { +class ClientChannelServiceConfigCallData final : public ServiceConfigCallData { public: ClientChannelServiceConfigCallData(Arena* arena, grpc_call_context_element* call_context) diff --git a/src/core/client_channel/client_channel_service_config.h b/src/core/client_channel/client_channel_service_config.h index 070d2bce315..c79e3e6ed8c 100644 --- a/src/core/client_channel/client_channel_service_config.h +++ b/src/core/client_channel/client_channel_service_config.h @@ -41,7 +41,7 @@ namespace grpc_core { namespace internal { -class ClientChannelGlobalParsedConfig +class ClientChannelGlobalParsedConfig final : public ServiceConfigParser::ParsedConfig { public: RefCountedPtr parsed_lb_config() const { @@ -72,7 +72,7 @@ class ClientChannelGlobalParsedConfig HealthCheckConfig health_check_config_; }; -class ClientChannelMethodParsedConfig +class ClientChannelMethodParsedConfig final : public ServiceConfigParser::ParsedConfig { public: Duration timeout() const { return timeout_; } @@ -86,7 +86,8 @@ class ClientChannelMethodParsedConfig absl::optional wait_for_ready_; }; -class ClientChannelServiceConfigParser : public ServiceConfigParser::Parser { +class ClientChannelServiceConfigParser final + : public ServiceConfigParser::Parser { public: absl::string_view name() const override { return parser_name(); } diff --git a/src/core/client_channel/config_selector.h b/src/core/client_channel/config_selector.h index cee71b86c06..e6560318f9a 100644 --- a/src/core/client_channel/config_selector.h +++ b/src/core/client_channel/config_selector.h @@ -90,7 +90,7 @@ class ConfigSelector : public RefCounted { }; // Default ConfigSelector that gets the MethodConfig from the service config. -class DefaultConfigSelector : public ConfigSelector { +class DefaultConfigSelector final : public ConfigSelector { public: explicit DefaultConfigSelector(RefCountedPtr service_config) : service_config_(std::move(service_config)) { diff --git a/src/core/client_channel/dynamic_filters.h b/src/core/client_channel/dynamic_filters.h index 641be64fc41..5db94fa672f 100644 --- a/src/core/client_channel/dynamic_filters.h +++ b/src/core/client_channel/dynamic_filters.h @@ -42,7 +42,7 @@ namespace grpc_core { -class DynamicFilters : public RefCounted { +class DynamicFilters final : public RefCounted { public: // Implements the interface of RefCounted<>. class Call { diff --git a/src/core/client_channel/http_proxy_mapper.h b/src/core/client_channel/http_proxy_mapper.h index bed8ab650e0..4ff58d73728 100644 --- a/src/core/client_channel/http_proxy_mapper.h +++ b/src/core/client_channel/http_proxy_mapper.h @@ -33,7 +33,7 @@ namespace grpc_core { -class HttpProxyMapper : public ProxyMapperInterface { +class HttpProxyMapper final : public ProxyMapperInterface { public: static constexpr char const* kAddressProxyEnvVar = "GRPC_ADDRESS_HTTP_PROXY"; static constexpr char const* kAddressProxyEnabledAddressesEnvVar = diff --git a/src/core/client_channel/retry_filter.h b/src/core/client_channel/retry_filter.h index bb11badcc78..733130a30ce 100644 --- a/src/core/client_channel/retry_filter.h +++ b/src/core/client_channel/retry_filter.h @@ -48,7 +48,7 @@ extern grpc_core::TraceFlag grpc_retry_trace; namespace grpc_core { -class RetryFilter { +class RetryFilter final { public: static const grpc_channel_filter kVtable; diff --git a/src/core/client_channel/retry_filter_legacy_call_data.cc b/src/core/client_channel/retry_filter_legacy_call_data.cc index a4bb16ace9f..ef5996c4b1f 100644 --- a/src/core/client_channel/retry_filter_legacy_call_data.cc +++ b/src/core/client_channel/retry_filter_legacy_call_data.cc @@ -72,7 +72,7 @@ namespace grpc_core { // those refs are not released until the LB call stack is destroyed. // When this object is destroyed, it will invoke the // on_call_stack_destruction closure from the surface. -class RetryFilter::LegacyCallData::CallStackDestructionBarrier +class RetryFilter::LegacyCallData::CallStackDestructionBarrier final : public RefCounted { public: diff --git a/src/core/client_channel/retry_filter_legacy_call_data.h b/src/core/client_channel/retry_filter_legacy_call_data.h index 1ce4dc11b29..876bd872655 100644 --- a/src/core/client_channel/retry_filter_legacy_call_data.h +++ b/src/core/client_channel/retry_filter_legacy_call_data.h @@ -54,7 +54,7 @@ namespace grpc_core { -class RetryFilter::LegacyCallData { +class RetryFilter::LegacyCallData final { public: static grpc_error_handle Init(grpc_call_element* elem, const grpc_call_element_args* args); @@ -78,7 +78,7 @@ class RetryFilter::LegacyCallData { }; // State associated with each call attempt. - class CallAttempt : public RefCounted { + class CallAttempt final : public RefCounted { public: CallAttempt(LegacyCallData* calld, bool is_transparent_retry); ~CallAttempt() override; @@ -102,7 +102,7 @@ class RetryFilter::LegacyCallData { // structures needed to populate the ops in the batch. // We allocate one struct on the arena for each attempt at starting a // batch on a given LB call. - class BatchData + class BatchData final : public RefCounted { public: BatchData(RefCountedPtr call_attempt, int refcount, diff --git a/src/core/client_channel/retry_service_config.h b/src/core/client_channel/retry_service_config.h index 3039df511e1..7c47e3b8c5a 100644 --- a/src/core/client_channel/retry_service_config.h +++ b/src/core/client_channel/retry_service_config.h @@ -40,7 +40,7 @@ namespace grpc_core { namespace internal { -class RetryGlobalConfig : public ServiceConfigParser::ParsedConfig { +class RetryGlobalConfig final : public ServiceConfigParser::ParsedConfig { public: uintptr_t max_milli_tokens() const { return max_milli_tokens_; } uintptr_t milli_token_ratio() const { return milli_token_ratio_; } @@ -54,7 +54,7 @@ class RetryGlobalConfig : public ServiceConfigParser::ParsedConfig { uintptr_t milli_token_ratio_ = 0; }; -class RetryMethodConfig : public ServiceConfigParser::ParsedConfig { +class RetryMethodConfig final : public ServiceConfigParser::ParsedConfig { public: int max_attempts() const { return max_attempts_; } Duration initial_backoff() const { return initial_backoff_; } @@ -80,7 +80,7 @@ class RetryMethodConfig : public ServiceConfigParser::ParsedConfig { absl::optional per_attempt_recv_timeout_; }; -class RetryServiceConfigParser : public ServiceConfigParser::Parser { +class RetryServiceConfigParser final : public ServiceConfigParser::Parser { public: absl::string_view name() const override { return parser_name(); } diff --git a/src/core/client_channel/retry_throttle.h b/src/core/client_channel/retry_throttle.h index 2c7c9f78504..ec1899b0967 100644 --- a/src/core/client_channel/retry_throttle.h +++ b/src/core/client_channel/retry_throttle.h @@ -38,7 +38,8 @@ namespace grpc_core { namespace internal { /// Tracks retry throttling data for an individual server name. -class ServerRetryThrottleData : public RefCounted { +class ServerRetryThrottleData final + : public RefCounted { public: ServerRetryThrottleData(uintptr_t max_milli_tokens, uintptr_t milli_token_ratio, @@ -68,7 +69,7 @@ class ServerRetryThrottleData : public RefCounted { }; /// Global map of server name to retry throttle data. -class ServerRetryThrottleMap { +class ServerRetryThrottleMap final { public: static ServerRetryThrottleMap* Get(); diff --git a/src/core/client_channel/subchannel.cc b/src/core/client_channel/subchannel.cc index 3b5feb822d0..6e8d1c41507 100644 --- a/src/core/client_channel/subchannel.cc +++ b/src/core/client_channel/subchannel.cc @@ -328,7 +328,7 @@ void SubchannelCall::IncrementRefCount(const DebugLocation& /*location*/, // Subchannel::ConnectedSubchannelStateWatcher // -class Subchannel::ConnectedSubchannelStateWatcher +class Subchannel::ConnectedSubchannelStateWatcher final : public AsyncConnectivityStateWatcherInterface { public: // Must be instantiated while holding c->mu. diff --git a/src/core/client_channel/subchannel.h b/src/core/client_channel/subchannel.h index cc9402dea7b..174e48df403 100644 --- a/src/core/client_channel/subchannel.h +++ b/src/core/client_channel/subchannel.h @@ -65,7 +65,7 @@ namespace grpc_core { class SubchannelCall; -class ConnectedSubchannel : public RefCounted { +class ConnectedSubchannel final : public RefCounted { public: ConnectedSubchannel( grpc_channel_stack* channel_stack, const ChannelArgs& args, @@ -96,7 +96,7 @@ class ConnectedSubchannel : public RefCounted { }; // Implements the interface of RefCounted<>. -class SubchannelCall { +class SubchannelCall final { public: struct Args { RefCountedPtr connected_subchannel; @@ -166,7 +166,7 @@ class SubchannelCall { // different from the SubchannelInterface that is exposed to LB policy // implementations. The client channel provides an adaptor class // (SubchannelWrapper) that "converts" between the two. -class Subchannel : public DualRefCounted { +class Subchannel final : public DualRefCounted { public: // TODO(roth): Once we remove pollset_set, consider whether this can // just use the normal AsyncConnectivityStateWatcherInterface API. @@ -279,7 +279,7 @@ class Subchannel : public DualRefCounted { // A linked list of ConnectivityStateWatcherInterfaces that are monitoring // the subchannel's state. - class ConnectivityStateWatcherList { + class ConnectivityStateWatcherList final { public: explicit ConnectivityStateWatcherList(Subchannel* subchannel) : subchannel_(subchannel) {} diff --git a/src/core/client_channel/subchannel_pool_interface.h b/src/core/client_channel/subchannel_pool_interface.h index 235b23b1dbe..fa8e828c393 100644 --- a/src/core/client_channel/subchannel_pool_interface.h +++ b/src/core/client_channel/subchannel_pool_interface.h @@ -39,7 +39,7 @@ class Subchannel; extern TraceFlag grpc_subchannel_pool_trace; // A key that can uniquely identify a subchannel. -class SubchannelKey { +class SubchannelKey final { public: SubchannelKey(const grpc_resolved_address& address, const ChannelArgs& args); diff --git a/src/core/client_channel/subchannel_stream_client.h b/src/core/client_channel/subchannel_stream_client.h index 37230f9e33c..38d25c755d3 100644 --- a/src/core/client_channel/subchannel_stream_client.h +++ b/src/core/client_channel/subchannel_stream_client.h @@ -61,7 +61,7 @@ namespace grpc_core { // // Currently, this assumes server-side streaming, but it could be extended // to support full bidi streaming if there is a need in the future. -class SubchannelStreamClient +class SubchannelStreamClient final : public InternallyRefCounted { public: // Interface implemented by caller. Thread safety is provided for the @@ -112,7 +112,7 @@ class SubchannelStreamClient private: // Contains a call to the backend and all the data related to the call. - class CallState : public Orphanable { + class CallState final : public Orphanable { public: CallState(RefCountedPtr client, grpc_pollset_set* interested_parties); diff --git a/src/core/ext/xds/certificate_provider_store.h b/src/core/ext/xds/certificate_provider_store.h index aba287f9789..963bd490039 100644 --- a/src/core/ext/xds/certificate_provider_store.h +++ b/src/core/ext/xds/certificate_provider_store.h @@ -46,7 +46,7 @@ namespace grpc_core { // Map for xDS based grpc_tls_certificate_provider instances. -class CertificateProviderStore +class CertificateProviderStore final : public InternallyRefCounted { public: struct PluginDefinition { @@ -77,7 +77,8 @@ class CertificateProviderStore private: // A thin wrapper around `grpc_tls_certificate_provider` which allows removing // the entry from the CertificateProviderStore when the refcount reaches zero. - class CertificateProviderWrapper : public grpc_tls_certificate_provider { + class CertificateProviderWrapper final + : public grpc_tls_certificate_provider { public: CertificateProviderWrapper( RefCountedPtr certificate_provider, diff --git a/src/core/ext/xds/file_watcher_certificate_provider_factory.h b/src/core/ext/xds/file_watcher_certificate_provider_factory.h index 7dd552c7c64..8c12e3867f5 100644 --- a/src/core/ext/xds/file_watcher_certificate_provider_factory.h +++ b/src/core/ext/xds/file_watcher_certificate_provider_factory.h @@ -37,10 +37,10 @@ namespace grpc_core { -class FileWatcherCertificateProviderFactory +class FileWatcherCertificateProviderFactory final : public CertificateProviderFactory { public: - class Config : public CertificateProviderFactory::Config { + class Config final : public CertificateProviderFactory::Config { public: absl::string_view name() const override; diff --git a/src/core/ext/xds/xds_api.h b/src/core/ext/xds/xds_api.h index e8ab904eb14..ad3192389a9 100644 --- a/src/core/ext/xds/xds_api.h +++ b/src/core/ext/xds/xds_api.h @@ -48,7 +48,7 @@ class XdsClient; // - ADS request/response handling // - LRS request/response handling // - CSDS response generation -class XdsApi { +class XdsApi final { public: // Interface defined by caller and passed to ParseAdsResponse(). class AdsResponseParserInterface { diff --git a/src/core/ext/xds/xds_audit_logger_registry.cc b/src/core/ext/xds/xds_audit_logger_registry.cc index 168e56a6558..914365c6868 100644 --- a/src/core/ext/xds/xds_audit_logger_registry.cc +++ b/src/core/ext/xds/xds_audit_logger_registry.cc @@ -39,7 +39,8 @@ namespace { using experimental::AuditLoggerRegistry; -class StdoutLoggerConfigFactory : public XdsAuditLoggerRegistry::ConfigFactory { +class StdoutLoggerConfigFactory final + : public XdsAuditLoggerRegistry::ConfigFactory { public: Json::Object ConvertXdsAuditLoggerConfig( const XdsResourceType::DecodeContext& /*context*/, diff --git a/src/core/ext/xds/xds_audit_logger_registry.h b/src/core/ext/xds/xds_audit_logger_registry.h index c363cd40e78..c42452cfa51 100644 --- a/src/core/ext/xds/xds_audit_logger_registry.h +++ b/src/core/ext/xds/xds_audit_logger_registry.h @@ -33,7 +33,7 @@ namespace grpc_core { // A registry that maintains a set of converters that are able to map xDS // RBAC audit logger configuration to gRPC's JSON format. -class XdsAuditLoggerRegistry { +class XdsAuditLoggerRegistry final { public: class ConfigFactory { public: diff --git a/src/core/ext/xds/xds_bootstrap_grpc.cc b/src/core/ext/xds/xds_bootstrap_grpc.cc index dcd5c918091..3988423985d 100644 --- a/src/core/ext/xds/xds_bootstrap_grpc.cc +++ b/src/core/ext/xds/xds_bootstrap_grpc.cc @@ -254,7 +254,7 @@ absl::StatusOr> GrpcXdsBootstrap::Create( "Failed to parse bootstrap JSON string: ", json.status().ToString())); } // Validate JSON. - class XdsJsonArgs : public JsonArgs { + class XdsJsonArgs final : public JsonArgs { public: bool IsEnabled(absl::string_view key) const override { if (key == "federation") return XdsFederationEnabled(); diff --git a/src/core/ext/xds/xds_bootstrap_grpc.h b/src/core/ext/xds/xds_bootstrap_grpc.h index 89fb7fe15e4..1aa0652983c 100644 --- a/src/core/ext/xds/xds_bootstrap_grpc.h +++ b/src/core/ext/xds/xds_bootstrap_grpc.h @@ -44,9 +44,9 @@ namespace grpc_core { -class GrpcXdsBootstrap : public XdsBootstrap { +class GrpcXdsBootstrap final : public XdsBootstrap { public: - class GrpcNode : public Node { + class GrpcNode final : public Node { public: const std::string& id() const override { return id_; } const std::string& cluster() const override { return cluster_; } @@ -76,7 +76,7 @@ class GrpcXdsBootstrap : public XdsBootstrap { Json::Object metadata_; }; - class GrpcXdsServer : public XdsServer { + class GrpcXdsServer final : public XdsServer { public: const std::string& server_uri() const override { return server_uri_; } @@ -102,7 +102,7 @@ class GrpcXdsBootstrap : public XdsBootstrap { std::set server_features_; }; - class GrpcAuthority : public Authority { + class GrpcAuthority final : public Authority { public: std::vector servers() const override { std::vector servers; diff --git a/src/core/ext/xds/xds_certificate_provider.cc b/src/core/ext/xds/xds_certificate_provider.cc index b97f0acb05f..b2c5ce5d892 100644 --- a/src/core/ext/xds/xds_certificate_provider.cc +++ b/src/core/ext/xds/xds_certificate_provider.cc @@ -35,7 +35,7 @@ namespace grpc_core { namespace { -class RootCertificatesWatcher +class RootCertificatesWatcher final : public grpc_tls_certificate_distributor::TlsCertificatesWatcherInterface { public: // Takes a ref to \a parent instead of a raw pointer since the watcher is @@ -68,7 +68,7 @@ class RootCertificatesWatcher RefCountedPtr parent_; }; -class IdentityCertificatesWatcher +class IdentityCertificatesWatcher final : public grpc_tls_certificate_distributor::TlsCertificatesWatcherInterface { public: // Takes a ref to \a parent instead of a raw pointer since the watcher is diff --git a/src/core/ext/xds/xds_certificate_provider.h b/src/core/ext/xds/xds_certificate_provider.h index 3d6dca2f59b..0f8e00e8db6 100644 --- a/src/core/ext/xds/xds_certificate_provider.h +++ b/src/core/ext/xds/xds_certificate_provider.h @@ -42,7 +42,7 @@ namespace grpc_core { -class XdsCertificateProvider : public grpc_tls_certificate_provider { +class XdsCertificateProvider final : public grpc_tls_certificate_provider { public: // ctor for client side XdsCertificateProvider( diff --git a/src/core/ext/xds/xds_channel_stack_modifier.h b/src/core/ext/xds/xds_channel_stack_modifier.h index 2c0df207cd8..323f0083a63 100644 --- a/src/core/ext/xds/xds_channel_stack_modifier.h +++ b/src/core/ext/xds/xds_channel_stack_modifier.h @@ -39,7 +39,8 @@ namespace grpc_core { // XdsChannelStackModifier allows for inserting xDS HTTP filters into the // channel stack. It is registered to mutate the `ChannelStackBuilder` object // via ChannelInit::Builder::RegisterPostProcessor. -class XdsChannelStackModifier : public RefCounted { +class XdsChannelStackModifier final + : public RefCounted { public: explicit XdsChannelStackModifier( std::vector filters) diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc index ca6ba41de4b..40301a60d34 100644 --- a/src/core/ext/xds/xds_client.cc +++ b/src/core/ext/xds/xds_client.cc @@ -76,7 +76,7 @@ TraceFlag grpc_xds_client_refcount_trace(false, "xds_client_refcount"); // An xds call wrapper that can restart a call upon failure. Holds a ref to // the xds channel. The template parameter is the kind of wrapped xds call. template -class XdsClient::XdsChannel::RetryableCall +class XdsClient::XdsChannel::RetryableCall final : public InternallyRefCounted> { public: explicit RetryableCall(WeakRefCountedPtr xds_channel); @@ -114,7 +114,8 @@ class XdsClient::XdsChannel::RetryableCall }; // Contains an ADS call to the xds server. -class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted { +class XdsClient::XdsChannel::AdsCall final + : public InternallyRefCounted { public: // The ctor and dtor should not be used directly. explicit AdsCall(RefCountedPtr> retryable_call); @@ -140,7 +141,7 @@ class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted { private: class AdsReadDelayHandle; - class AdsResponseParser : public XdsApi::AdsResponseParserInterface { + class AdsResponseParser final : public XdsApi::AdsResponseParserInterface { public: struct Result { const XdsResourceType* type; @@ -178,7 +179,7 @@ class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted { Result result_; }; - class ResourceTimer : public InternallyRefCounted { + class ResourceTimer final : public InternallyRefCounted { public: ResourceTimer(const XdsResourceType* type, const XdsResourceName& name) : type_(type), name_(name) {} @@ -291,7 +292,7 @@ class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted { ABSL_GUARDED_BY(&XdsClient::mu_); }; - class StreamEventHandler + class StreamEventHandler final : public XdsTransportFactory::XdsTransport::StreamingCall::EventHandler { public: explicit StreamEventHandler(RefCountedPtr ads_call) @@ -354,7 +355,8 @@ class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted { }; // Contains an LRS call to the xds server. -class XdsClient::XdsChannel::LrsCall : public InternallyRefCounted { +class XdsClient::XdsChannel::LrsCall final + : public InternallyRefCounted { public: // The ctor and dtor should not be used directly. explicit LrsCall(RefCountedPtr> retryable_call); @@ -367,7 +369,7 @@ class XdsClient::XdsChannel::LrsCall : public InternallyRefCounted { bool seen_response() const { return seen_response_; } private: - class StreamEventHandler + class StreamEventHandler final : public XdsTransportFactory::XdsTransport::StreamingCall::EventHandler { public: explicit StreamEventHandler(RefCountedPtr lrs_call) @@ -386,7 +388,7 @@ class XdsClient::XdsChannel::LrsCall : public InternallyRefCounted { }; // A repeating timer for a particular duration. - class Timer : public InternallyRefCounted { + class Timer final : public InternallyRefCounted { public: explicit Timer(RefCountedPtr lrs_call) : lrs_call_(std::move(lrs_call)) {} @@ -700,7 +702,7 @@ void XdsClient::XdsChannel::RetryableCall::OnRetryTimer() { // XdsClient::XdsChannel::AdsCall::AdsReadDelayHandle // -class XdsClient::XdsChannel::AdsCall::AdsReadDelayHandle +class XdsClient::XdsChannel::AdsCall::AdsReadDelayHandle final : public XdsClient::ReadDelayHandle { public: explicit AdsReadDelayHandle(RefCountedPtr ads_call) diff --git a/src/core/ext/xds/xds_client.h b/src/core/ext/xds/xds_client.h index b8223ffccce..5d99255bd15 100644 --- a/src/core/ext/xds/xds_client.h +++ b/src/core/ext/xds/xds_client.h @@ -208,7 +208,7 @@ class XdsClient : public DualRefCounted { // Contains a channel to the xds server and all the data related to the // channel. Holds a ref to the xds client object. - class XdsChannel : public DualRefCounted { + class XdsChannel final : public DualRefCounted { public: template class RetryableCall; diff --git a/src/core/ext/xds/xds_client_grpc.cc b/src/core/ext/xds/xds_client_grpc.cc index 6fc026decd5..24458a225e2 100644 --- a/src/core/ext/xds/xds_client_grpc.cc +++ b/src/core/ext/xds/xds_client_grpc.cc @@ -140,7 +140,7 @@ const auto kMetricResources = // GrpcXdsClient::MetricsReporter // -class GrpcXdsClient::MetricsReporter : public XdsMetricsReporter { +class GrpcXdsClient::MetricsReporter final : public XdsMetricsReporter { public: explicit MetricsReporter(GrpcXdsClient& xds_client) : xds_client_(xds_client) {} diff --git a/src/core/ext/xds/xds_client_grpc.h b/src/core/ext/xds/xds_client_grpc.h index 9edb9baac02..26c0e1044a7 100644 --- a/src/core/ext/xds/xds_client_grpc.h +++ b/src/core/ext/xds/xds_client_grpc.h @@ -40,7 +40,7 @@ namespace grpc_core { -class GrpcXdsClient : public XdsClient { +class GrpcXdsClient final : public XdsClient { public: // The key to pass to GetOrCreate() for gRPC servers. static constexpr absl::string_view kServerKey = "#server"; diff --git a/src/core/ext/xds/xds_client_stats.h b/src/core/ext/xds/xds_client_stats.h index 5f78e156768..8f15e25d928 100644 --- a/src/core/ext/xds/xds_client_stats.h +++ b/src/core/ext/xds/xds_client_stats.h @@ -45,7 +45,7 @@ namespace grpc_core { class XdsClient; // Locality name. -class XdsLocalityName : public RefCounted { +class XdsLocalityName final : public RefCounted { public: struct Less { bool operator()(const XdsLocalityName* lhs, @@ -115,7 +115,7 @@ class XdsLocalityName : public RefCounted { }; // Drop stats for an xds cluster. -class XdsClusterDropStats : public RefCounted { +class XdsClusterDropStats final : public RefCounted { public: // The total number of requests dropped for any reason is the sum of // uncategorized_drops, and dropped_requests map. @@ -169,7 +169,8 @@ class XdsClusterDropStats : public RefCounted { }; // Locality stats for an xds cluster. -class XdsClusterLocalityStats : public RefCounted { +class XdsClusterLocalityStats final + : public RefCounted { public: struct BackendMetric { uint64_t num_requests_finished_with_metric = 0; diff --git a/src/core/ext/xds/xds_cluster_specifier_plugin.h b/src/core/ext/xds/xds_cluster_specifier_plugin.h index bc2939ce0ac..434f894281e 100644 --- a/src/core/ext/xds/xds_cluster_specifier_plugin.h +++ b/src/core/ext/xds/xds_cluster_specifier_plugin.h @@ -49,7 +49,7 @@ class XdsClusterSpecifierPluginImpl { ValidationErrors* errors) const = 0; }; -class XdsRouteLookupClusterSpecifierPlugin +class XdsRouteLookupClusterSpecifierPlugin final : public XdsClusterSpecifierPluginImpl { absl::string_view ConfigProtoName() const override; @@ -60,7 +60,7 @@ class XdsRouteLookupClusterSpecifierPlugin ValidationErrors* errors) const override; }; -class XdsClusterSpecifierPluginRegistry { +class XdsClusterSpecifierPluginRegistry final { public: XdsClusterSpecifierPluginRegistry(); diff --git a/src/core/ext/xds/xds_endpoint.h b/src/core/ext/xds/xds_endpoint.h index faa33192c33..3e26f669e2b 100644 --- a/src/core/ext/xds/xds_endpoint.h +++ b/src/core/ext/xds/xds_endpoint.h @@ -71,7 +71,7 @@ struct XdsEndpointResource : public XdsResourceType::ResourceData { // 1. to initialize in the control plane combiner; // 2. to use in the data plane combiner. // So no additional synchronization is needed. - class DropConfig : public RefCounted { + class DropConfig final : public RefCounted { public: struct DropCategory { bool operator==(const DropCategory& other) const { @@ -130,7 +130,7 @@ struct XdsEndpointResource : public XdsResourceType::ResourceData { std::string ToString() const; }; -class XdsEndpointResourceType +class XdsEndpointResourceType final : public XdsResourceTypeImpl { public: absl::string_view type_url() const override { diff --git a/src/core/ext/xds/xds_health_status.h b/src/core/ext/xds/xds_health_status.h index 2ad46f082f3..53e706c432e 100644 --- a/src/core/ext/xds/xds_health_status.h +++ b/src/core/ext/xds/xds_health_status.h @@ -34,7 +34,7 @@ namespace grpc_core { -class XdsHealthStatus { +class XdsHealthStatus final { public: enum HealthStatus { kUnknown, kHealthy, kDraining }; @@ -56,7 +56,7 @@ class XdsHealthStatus { HealthStatus status_; }; -class XdsHealthStatusSet { +class XdsHealthStatusSet final { public: XdsHealthStatusSet() = default; diff --git a/src/core/ext/xds/xds_http_fault_filter.h b/src/core/ext/xds/xds_http_fault_filter.h index 690d89eb684..3bd8b2d9c79 100644 --- a/src/core/ext/xds/xds_http_fault_filter.h +++ b/src/core/ext/xds/xds_http_fault_filter.h @@ -33,7 +33,7 @@ namespace grpc_core { -class XdsHttpFaultFilter : public XdsHttpFilterImpl { +class XdsHttpFaultFilter final : public XdsHttpFilterImpl { public: absl::string_view ConfigProtoName() const override; absl::string_view OverrideConfigProtoName() const override; diff --git a/src/core/ext/xds/xds_http_filters.h b/src/core/ext/xds/xds_http_filters.h index b99f12bd4f9..fd5148d2b3e 100644 --- a/src/core/ext/xds/xds_http_filters.h +++ b/src/core/ext/xds/xds_http_filters.h @@ -124,7 +124,7 @@ class XdsHttpFilterImpl { virtual bool IsTerminalFilter() const { return false; } }; -class XdsHttpRouterFilter : public XdsHttpFilterImpl { +class XdsHttpRouterFilter final : public XdsHttpFilterImpl { public: absl::string_view ConfigProtoName() const override; absl::string_view OverrideConfigProtoName() const override; @@ -147,7 +147,7 @@ class XdsHttpRouterFilter : public XdsHttpFilterImpl { bool IsTerminalFilter() const override { return true; } }; -class XdsHttpFilterRegistry { +class XdsHttpFilterRegistry final { public: explicit XdsHttpFilterRegistry(bool register_builtins = true); diff --git a/src/core/ext/xds/xds_http_rbac_filter.h b/src/core/ext/xds/xds_http_rbac_filter.h index c066521658a..20053342070 100644 --- a/src/core/ext/xds/xds_http_rbac_filter.h +++ b/src/core/ext/xds/xds_http_rbac_filter.h @@ -33,7 +33,7 @@ namespace grpc_core { -class XdsHttpRbacFilter : public XdsHttpFilterImpl { +class XdsHttpRbacFilter final : public XdsHttpFilterImpl { public: absl::string_view ConfigProtoName() const override; absl::string_view OverrideConfigProtoName() const override; diff --git a/src/core/ext/xds/xds_http_stateful_session_filter.h b/src/core/ext/xds/xds_http_stateful_session_filter.h index 4fe68e57bc8..660b3660f7e 100644 --- a/src/core/ext/xds/xds_http_stateful_session_filter.h +++ b/src/core/ext/xds/xds_http_stateful_session_filter.h @@ -33,7 +33,7 @@ namespace grpc_core { -class XdsHttpStatefulSessionFilter : public XdsHttpFilterImpl { +class XdsHttpStatefulSessionFilter final : public XdsHttpFilterImpl { public: absl::string_view ConfigProtoName() const override; absl::string_view OverrideConfigProtoName() const override; diff --git a/src/core/ext/xds/xds_lb_policy_registry.cc b/src/core/ext/xds/xds_lb_policy_registry.cc index e10b55d4b6f..d36a4f22eaf 100644 --- a/src/core/ext/xds/xds_lb_policy_registry.cc +++ b/src/core/ext/xds/xds_lb_policy_registry.cc @@ -46,7 +46,7 @@ namespace grpc_core { namespace { -class RoundRobinLbPolicyConfigFactory +class RoundRobinLbPolicyConfigFactory final : public XdsLbPolicyRegistry::ConfigFactory { public: Json::Object ConvertXdsLbPolicyConfig( @@ -64,7 +64,7 @@ class RoundRobinLbPolicyConfigFactory } }; -class ClientSideWeightedRoundRobinLbPolicyConfigFactory +class ClientSideWeightedRoundRobinLbPolicyConfigFactory final : public XdsLbPolicyRegistry::ConfigFactory { public: Json::Object ConvertXdsLbPolicyConfig( @@ -151,7 +151,7 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory } }; -class RingHashLbPolicyConfigFactory +class RingHashLbPolicyConfigFactory final : public XdsLbPolicyRegistry::ConfigFactory { public: Json::Object ConvertXdsLbPolicyConfig( @@ -216,7 +216,7 @@ class RingHashLbPolicyConfigFactory } }; -class WrrLocalityLbPolicyConfigFactory +class WrrLocalityLbPolicyConfigFactory final : public XdsLbPolicyRegistry::ConfigFactory { public: Json::Object ConvertXdsLbPolicyConfig( @@ -255,7 +255,7 @@ class WrrLocalityLbPolicyConfigFactory } }; -class PickFirstLbPolicyConfigFactory +class PickFirstLbPolicyConfigFactory final : public XdsLbPolicyRegistry::ConfigFactory { public: Json::Object ConvertXdsLbPolicyConfig( diff --git a/src/core/ext/xds/xds_lb_policy_registry.h b/src/core/ext/xds/xds_lb_policy_registry.h index d797c9fbc07..e1a5a01bdc7 100644 --- a/src/core/ext/xds/xds_lb_policy_registry.h +++ b/src/core/ext/xds/xds_lb_policy_registry.h @@ -33,7 +33,7 @@ namespace grpc_core { // A registry that maintans a set of converters that are able to map xDS // loadbalancing policy configurations to gRPC's JSON format. -class XdsLbPolicyRegistry { +class XdsLbPolicyRegistry final { public: class ConfigFactory { public: diff --git a/src/core/ext/xds/xds_listener.h b/src/core/ext/xds/xds_listener.h index cb6cb06f518..625ea7af110 100644 --- a/src/core/ext/xds/xds_listener.h +++ b/src/core/ext/xds/xds_listener.h @@ -207,7 +207,7 @@ struct XdsListenerResource : public XdsResourceType::ResourceData { std::string ToString() const; }; -class XdsListenerResourceType +class XdsListenerResourceType final : public XdsResourceTypeImpl { public: absl::string_view type_url() const override { diff --git a/src/core/ext/xds/xds_route_config.h b/src/core/ext/xds/xds_route_config.h index e9cc39efc57..eb7e0b1b70f 100644 --- a/src/core/ext/xds/xds_route_config.h +++ b/src/core/ext/xds/xds_route_config.h @@ -227,7 +227,7 @@ struct XdsRouteConfigResource : public XdsResourceType::ResourceData { ValidationErrors* errors); }; -class XdsRouteConfigResourceType +class XdsRouteConfigResourceType final : public XdsResourceTypeImpl { public: diff --git a/src/core/ext/xds/xds_routing.h b/src/core/ext/xds/xds_routing.h index 67f2e98c96a..a6f383fd0f8 100644 --- a/src/core/ext/xds/xds_routing.h +++ b/src/core/ext/xds/xds_routing.h @@ -39,7 +39,7 @@ namespace grpc_core { -class XdsRouting { +class XdsRouting final { public: class VirtualHostListIterator { public: diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/ext/xds/xds_server_config_fetcher.cc index bc6bf4c4d62..c861dc61a2c 100644 --- a/src/core/ext/xds/xds_server_config_fetcher.cc +++ b/src/core/ext/xds/xds_server_config_fetcher.cc @@ -99,7 +99,7 @@ TraceFlag grpc_xds_server_config_fetcher_trace(false, // A server config fetcher that fetches the information for configuring server // listeners from the xDS control plane. -class XdsServerConfigFetcher : public grpc_server_config_fetcher { +class XdsServerConfigFetcher final : public grpc_server_config_fetcher { public: XdsServerConfigFetcher(RefCountedPtr xds_client, grpc_server_xds_status_notifier notifier); @@ -140,7 +140,7 @@ class XdsServerConfigFetcher : public grpc_server_config_fetcher { // continues to be used. If there isn't any previous good update or if the // update received was a fatal error (resource does not exist), the server // listener is made to stop listening. -class XdsServerConfigFetcher::ListenerWatcher +class XdsServerConfigFetcher::ListenerWatcher final : public XdsListenerResourceType::WatcherInterface { public: ListenerWatcher(RefCountedPtr xds_client, @@ -200,7 +200,7 @@ class XdsServerConfigFetcher::ListenerWatcher // appropriate filter chain from the xDS Listener resource and injects channel // args that configure the right mTLS certs and cause the right set of HTTP // filters to be injected. -class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager +class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager final : public grpc_server_config_fetcher::ConnectionManager { public: FilterChainMatchManager(RefCountedPtr xds_client, @@ -280,7 +280,8 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager // with the latest updates and new connections do not need to wait for the RDS // resources to be fetched. class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: - RouteConfigWatcher : public XdsRouteConfigResourceType::WatcherInterface { + RouteConfigWatcher final + : public XdsRouteConfigResourceType::WatcherInterface { public: RouteConfigWatcher( std::string resource_name, @@ -316,7 +317,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: // DynamicXdsServerConfigSelectorProvider to parse the RDS update and get // per-call configuration based on incoming metadata. class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: - XdsServerConfigSelector : public ServerConfigSelector { + XdsServerConfigSelector final : public ServerConfigSelector { public: static absl::StatusOr> Create( const XdsHttpFilterRegistry& http_filter_registry, @@ -340,7 +341,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: RefCountedPtr method_config; }; - class RouteListIterator : public XdsRouting::RouteListIterator { + class RouteListIterator final : public XdsRouting::RouteListIterator { public: explicit RouteListIterator(const std::vector* routes) : routes_(routes) {} @@ -360,7 +361,8 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: std::vector routes; }; - class VirtualHostListIterator : public XdsRouting::VirtualHostListIterator { + class VirtualHostListIterator final + : public XdsRouting::VirtualHostListIterator { public: explicit VirtualHostListIterator( const std::vector* virtual_hosts) @@ -383,7 +385,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: // An XdsServerConfigSelectorProvider implementation for when the // RouteConfiguration is available inline. class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: - StaticXdsServerConfigSelectorProvider + StaticXdsServerConfigSelectorProvider final : public ServerConfigSelectorProvider { public: StaticXdsServerConfigSelectorProvider( @@ -434,7 +436,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: // An XdsServerConfigSelectorProvider implementation for when the // RouteConfiguration is to be fetched separately via RDS. class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: - DynamicXdsServerConfigSelectorProvider + DynamicXdsServerConfigSelectorProvider final : public ServerConfigSelectorProvider { public: DynamicXdsServerConfigSelectorProvider( @@ -480,7 +482,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: // A watcher implementation for updating the RDS resource used by // DynamicXdsServerConfigSelectorProvider class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: - DynamicXdsServerConfigSelectorProvider::RouteConfigWatcher + DynamicXdsServerConfigSelectorProvider::RouteConfigWatcher final : public XdsRouteConfigResourceType::WatcherInterface { public: explicit RouteConfigWatcher( diff --git a/src/core/ext/xds/xds_transport_grpc.cc b/src/core/ext/xds/xds_transport_grpc.cc index c3355c1fe6b..da65a663279 100644 --- a/src/core/ext/xds/xds_transport_grpc.cc +++ b/src/core/ext/xds/xds_transport_grpc.cc @@ -227,7 +227,7 @@ void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall:: // GrpcXdsTransportFactory::GrpcXdsTransport::StateWatcher // -class GrpcXdsTransportFactory::GrpcXdsTransport::StateWatcher +class GrpcXdsTransportFactory::GrpcXdsTransport::StateWatcher final : public AsyncConnectivityStateWatcherInterface { public: explicit StateWatcher( diff --git a/src/core/ext/xds/xds_transport_grpc.h b/src/core/ext/xds/xds_transport_grpc.h index 1e80a996cd8..55498442643 100644 --- a/src/core/ext/xds/xds_transport_grpc.h +++ b/src/core/ext/xds/xds_transport_grpc.h @@ -41,7 +41,7 @@ namespace grpc_core { -class GrpcXdsTransportFactory : public XdsTransportFactory { +class GrpcXdsTransportFactory final : public XdsTransportFactory { public: class GrpcXdsTransport; @@ -62,7 +62,7 @@ class GrpcXdsTransportFactory : public XdsTransportFactory { grpc_pollset_set* interested_parties_; }; -class GrpcXdsTransportFactory::GrpcXdsTransport +class GrpcXdsTransportFactory::GrpcXdsTransport final : public XdsTransportFactory::XdsTransport { public: class GrpcStreamingCall; @@ -88,7 +88,7 @@ class GrpcXdsTransportFactory::GrpcXdsTransport StateWatcher* watcher_; }; -class GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall +class GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall final : public XdsTransportFactory::XdsTransport::StreamingCall { public: GrpcStreamingCall(RefCountedPtr factory, diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 42eb29ef991..dd228a28479 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -120,7 +120,7 @@ class BaseNode : public RefCounted { // - track calls_{started,succeeded,failed} // - track last_call_started_timestamp // - perform rendering of the above items -class CallCountingHelper { +class CallCountingHelper final { public: void RecordCallStarted(); void RecordCallFailed(); @@ -139,7 +139,7 @@ class CallCountingHelper { std::atomic last_call_started_cycle_{0}; }; -class PerCpuCallCountingHelper { +class PerCpuCallCountingHelper final { public: void RecordCallStarted(); void RecordCallFailed(); @@ -183,7 +183,7 @@ class PerCpuCallCountingHelper { }; // Handles channelz bookkeeping for channels -class ChannelNode : public BaseNode { +class ChannelNode final : public BaseNode { public: ChannelNode(std::string target, size_t channel_tracer_max_nodes, bool is_internal_channel); @@ -247,7 +247,7 @@ class ChannelNode : public BaseNode { }; // Handles channelz bookkeeping for servers -class ServerNode : public BaseNode { +class ServerNode final : public BaseNode { public: explicit ServerNode(size_t channel_tracer_max_nodes); @@ -291,7 +291,7 @@ class ServerNode : public BaseNode { #define GRPC_ARG_CHANNELZ_SECURITY "grpc.internal.channelz_security" // Handles channelz bookkeeping for sockets -class SocketNode : public BaseNode { +class SocketNode final : public BaseNode { public: struct Security : public RefCounted { struct Tls { @@ -367,7 +367,7 @@ class SocketNode : public BaseNode { }; // Handles channelz bookkeeping for listen sockets -class ListenSocketNode : public BaseNode { +class ListenSocketNode final : public BaseNode { public: ListenSocketNode(std::string local_addr, std::string name); ~ListenSocketNode() override {} diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index 9b02ef1337a..2c42ced0d47 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -36,7 +36,7 @@ namespace channelz { // singleton registry object to track all objects that are needed to support // channelz bookkeeping. All objects share globally distributed uuids. -class ChannelzRegistry { +class ChannelzRegistry final { public: static void Register(BaseNode* node) { return Default()->InternalRegister(node); diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index 5461fca61a6..9fe6c0d0999 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -214,7 +214,7 @@ bool LegacyChannel::SupportsConnectivityWatcher() const { } // A fire-and-forget object to handle external connectivity state watches. -class LegacyChannel::StateWatcher : public DualRefCounted { +class LegacyChannel::StateWatcher final : public DualRefCounted { public: StateWatcher(RefCountedPtr channel, grpc_completion_queue* cq, void* tag, grpc_connectivity_state last_observed_state, @@ -254,7 +254,7 @@ class LegacyChannel::StateWatcher : public DualRefCounted { private: // A fire-and-forget object used to delay starting the timer until the // ClientChannelFilter actually starts the watch. - class WatcherTimerInitState { + class WatcherTimerInitState final { public: WatcherTimerInitState(StateWatcher* state_watcher, Timestamp deadline) : state_watcher_(state_watcher), deadline_(deadline) { diff --git a/src/core/lib/surface/legacy_channel.h b/src/core/lib/surface/legacy_channel.h index cda0dbc6060..a6c68572866 100644 --- a/src/core/lib/surface/legacy_channel.h +++ b/src/core/lib/surface/legacy_channel.h @@ -44,7 +44,7 @@ namespace grpc_core { -class LegacyChannel : public Channel { +class LegacyChannel final : public Channel { public: static absl::StatusOr> Create( std::string target, ChannelArgs args, diff --git a/src/core/load_balancing/address_filtering.cc b/src/core/load_balancing/address_filtering.cc index 2d0731156d9..a6eb3966f04 100644 --- a/src/core/load_balancing/address_filtering.cc +++ b/src/core/load_balancing/address_filtering.cc @@ -47,7 +47,7 @@ int HierarchicalPathArg::ChannelArgsCompare(const HierarchicalPathArg* a, namespace { -class HierarchicalAddressIterator : public EndpointAddressesIterator { +class HierarchicalAddressIterator final : public EndpointAddressesIterator { public: HierarchicalAddressIterator( std::shared_ptr parent_it, diff --git a/src/core/load_balancing/address_filtering.h b/src/core/load_balancing/address_filtering.h index d81d5cacbbb..bad19b16039 100644 --- a/src/core/load_balancing/address_filtering.h +++ b/src/core/load_balancing/address_filtering.h @@ -87,7 +87,7 @@ namespace grpc_core { // An address channel arg containing the hierarchical path // to be associated with the address. -class HierarchicalPathArg : public RefCounted { +class HierarchicalPathArg final : public RefCounted { public: explicit HierarchicalPathArg(std::vector path) : path_(std::move(path)) {} diff --git a/src/core/load_balancing/child_policy_handler.cc b/src/core/load_balancing/child_policy_handler.cc index cb511b8e910..e70d017eb04 100644 --- a/src/core/load_balancing/child_policy_handler.cc +++ b/src/core/load_balancing/child_policy_handler.cc @@ -44,7 +44,7 @@ namespace grpc_core { // ChildPolicyHandler::Helper // -class ChildPolicyHandler::Helper +class ChildPolicyHandler::Helper final : public LoadBalancingPolicy::ParentOwningDelegatingChannelControlHelper< ChildPolicyHandler> { public: diff --git a/src/core/load_balancing/endpoint_list.cc b/src/core/load_balancing/endpoint_list.cc index 73399d7e125..00b152b9908 100644 --- a/src/core/load_balancing/endpoint_list.cc +++ b/src/core/load_balancing/endpoint_list.cc @@ -51,7 +51,7 @@ namespace grpc_core { // EndpointList::Endpoint::Helper // -class EndpointList::Endpoint::Helper +class EndpointList::Endpoint::Helper final : public LoadBalancingPolicy::DelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr endpoint) diff --git a/src/core/load_balancing/grpclb/client_load_reporting_filter.h b/src/core/load_balancing/grpclb/client_load_reporting_filter.h index 474a4a5464f..57e89251d0b 100644 --- a/src/core/load_balancing/grpclb/client_load_reporting_filter.h +++ b/src/core/load_balancing/grpclb/client_load_reporting_filter.h @@ -30,7 +30,8 @@ #include "src/core/lib/transport/transport.h" namespace grpc_core { -class ClientLoadReportingFilter : public ChannelFilter { + +class ClientLoadReportingFilter final : public ChannelFilter { public: static const grpc_channel_filter kFilter; @@ -41,6 +42,7 @@ class ClientLoadReportingFilter : public ChannelFilter { ArenaPromise MakeCallPromise( CallArgs call_args, NextPromiseFactory next_promise_factory) override; }; + } // namespace grpc_core #endif // GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H diff --git a/src/core/load_balancing/grpclb/grpclb.cc b/src/core/load_balancing/grpclb/grpclb.cc index e58d0e05a05..b6b3eac4b81 100644 --- a/src/core/load_balancing/grpclb/grpclb.cc +++ b/src/core/load_balancing/grpclb/grpclb.cc @@ -165,7 +165,7 @@ using ::grpc_event_engine::experimental::EventEngine; constexpr absl::string_view kGrpclb = "grpclb"; -class GrpcLbConfig : public LoadBalancingPolicy::Config { +class GrpcLbConfig final : public LoadBalancingPolicy::Config { public: GrpcLbConfig() = default; @@ -222,7 +222,7 @@ class GrpcLbConfig : public LoadBalancingPolicy::Config { std::string service_name_; }; -class GrpcLb : public LoadBalancingPolicy { +class GrpcLb final : public LoadBalancingPolicy { public: explicit GrpcLb(Args args); @@ -233,7 +233,8 @@ class GrpcLb : public LoadBalancingPolicy { private: /// Contains a call to the LB server and all the data related to the call. - class BalancerCallState : public InternallyRefCounted { + class BalancerCallState final + : public InternallyRefCounted { public: explicit BalancerCallState( RefCountedPtr parent_grpclb_policy); @@ -307,7 +308,7 @@ class GrpcLb : public LoadBalancingPolicy { grpc_closure client_load_report_done_closure_; }; - class SubchannelWrapper : public DelegatingSubchannel { + class SubchannelWrapper final : public DelegatingSubchannel { public: SubchannelWrapper(RefCountedPtr subchannel, RefCountedPtr lb_policy, std::string lb_token, @@ -343,7 +344,8 @@ class GrpcLb : public LoadBalancingPolicy { RefCountedPtr client_stats_; }; - class TokenAndClientStatsArg : public RefCounted { + class TokenAndClientStatsArg final + : public RefCounted { public: TokenAndClientStatsArg(std::string lb_token, RefCountedPtr client_stats) @@ -371,7 +373,7 @@ class GrpcLb : public LoadBalancingPolicy { RefCountedPtr client_stats_; }; - class Serverlist : public RefCounted { + class Serverlist final : public RefCounted { public: // Takes ownership of serverlist. explicit Serverlist(std::vector serverlist) @@ -408,7 +410,7 @@ class GrpcLb : public LoadBalancingPolicy { std::atomic drop_index_{0}; }; - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(RefCountedPtr serverlist, RefCountedPtr child_picker, @@ -424,7 +426,7 @@ class GrpcLb : public LoadBalancingPolicy { // in the case where the subchannel call is never actually started, // since the client load reporting filter will not be able to do it // in that case. - class SubchannelCallTracker : public SubchannelCallTrackerInterface { + class SubchannelCallTracker final : public SubchannelCallTrackerInterface { public: SubchannelCallTracker( RefCountedPtr client_stats, @@ -460,7 +462,8 @@ class GrpcLb : public LoadBalancingPolicy { RefCountedPtr client_stats_; }; - class Helper : public ParentOwningDelegatingChannelControlHelper { + class Helper final + : public ParentOwningDelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr parent) : ParentOwningDelegatingChannelControlHelper(std::move(parent)) {} @@ -473,7 +476,7 @@ class GrpcLb : public LoadBalancingPolicy { void RequestReresolution() override; }; - class StateWatcher : public AsyncConnectivityStateWatcherInterface { + class StateWatcher final : public AsyncConnectivityStateWatcherInterface { public: explicit StateWatcher(RefCountedPtr parent) : AsyncConnectivityStateWatcherInterface(parent->work_serializer()), @@ -647,7 +650,8 @@ void ParseServer(const GrpcLbServer& server, grpc_resolved_address* addr) { } } -class GrpcLb::Serverlist::AddressIterator : public EndpointAddressesIterator { +class GrpcLb::Serverlist::AddressIterator final + : public EndpointAddressesIterator { public: AddressIterator(RefCountedPtr serverlist, RefCountedPtr client_stats) @@ -1526,7 +1530,8 @@ void GrpcLb::ResetBackoffLocked() { } // Endpoint iterator wrapper to add null LB token attribute. -class GrpcLb::NullLbTokenEndpointIterator : public EndpointAddressesIterator { +class GrpcLb::NullLbTokenEndpointIterator final + : public EndpointAddressesIterator { public: explicit NullLbTokenEndpointIterator( std::shared_ptr parent_it) @@ -1892,7 +1897,7 @@ void GrpcLb::OnSubchannelCacheTimerLocked() { // factory // -class GrpcLbFactory : public LoadBalancingPolicyFactory { +class GrpcLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/grpclb/grpclb_client_stats.h b/src/core/load_balancing/grpclb/grpclb_client_stats.h index 809163938d3..0a7229a85d3 100644 --- a/src/core/load_balancing/grpclb/grpclb_client_stats.h +++ b/src/core/load_balancing/grpclb/grpclb_client_stats.h @@ -37,7 +37,7 @@ namespace grpc_core { -class GrpcLbClientStats : public RefCounted { +class GrpcLbClientStats final : public RefCounted { public: struct DropTokenCount { UniquePtr token; diff --git a/src/core/load_balancing/health_check_client.cc b/src/core/load_balancing/health_check_client.cc index a6dc3d5cb6a..a97edecec43 100644 --- a/src/core/load_balancing/health_check_client.cc +++ b/src/core/load_balancing/health_check_client.cc @@ -71,7 +71,7 @@ TraceFlag grpc_health_check_client_trace(false, "health_check_client"); namespace { // A fire-and-forget class to asynchronously drain a WorkSerializer queue. -class AsyncWorkSerializerDrainer { +class AsyncWorkSerializerDrainer final { public: explicit AsyncWorkSerializerDrainer( std::shared_ptr work_serializer) @@ -212,7 +212,7 @@ void HealthProducer::HealthChecker::OnHealthWatchStatusChange( // HealthProducer::HealthChecker::HealthStreamEventHandler // -class HealthProducer::HealthChecker::HealthStreamEventHandler +class HealthProducer::HealthChecker::HealthStreamEventHandler final : public SubchannelStreamClient::CallEventHandler { public: explicit HealthStreamEventHandler(RefCountedPtr health_checker) @@ -321,7 +321,7 @@ class HealthProducer::HealthChecker::HealthStreamEventHandler // HealthProducer::ConnectivityWatcher // -class HealthProducer::ConnectivityWatcher +class HealthProducer::ConnectivityWatcher final : public Subchannel::ConnectivityStateWatcherInterface { public: explicit ConnectivityWatcher(WeakRefCountedPtr producer) diff --git a/src/core/load_balancing/health_check_client_internal.h b/src/core/load_balancing/health_check_client_internal.h index c403e851ef9..a083fa035ec 100644 --- a/src/core/load_balancing/health_check_client_internal.h +++ b/src/core/load_balancing/health_check_client_internal.h @@ -52,7 +52,7 @@ class HealthWatcher; // health watch call for each health check service name that is being // watched and reports the resulting connectivity state to all // registered watchers. -class HealthProducer : public Subchannel::DataProducerInterface { +class HealthProducer final : public Subchannel::DataProducerInterface { public: HealthProducer() : interested_parties_(grpc_pollset_set_create()) {} ~HealthProducer() override { grpc_pollset_set_destroy(interested_parties_); } @@ -77,7 +77,7 @@ class HealthProducer : public Subchannel::DataProducerInterface { // Health checker for a given health check service name. Contains the // health check client and the list of watchers. - class HealthChecker : public InternallyRefCounted { + class HealthChecker final : public InternallyRefCounted { public: HealthChecker(WeakRefCountedPtr producer, absl::string_view health_check_service_name); @@ -155,7 +155,7 @@ class HealthProducer : public Subchannel::DataProducerInterface { }; // A data watcher that handles health checking. -class HealthWatcher : public InternalSubchannelDataWatcherInterface { +class HealthWatcher final : public InternalSubchannelDataWatcherInterface { public: HealthWatcher( std::shared_ptr work_serializer, diff --git a/src/core/load_balancing/lb_policy.h b/src/core/load_balancing/lb_policy.h index b48cd8d1c47..aa6036182d9 100644 --- a/src/core/load_balancing/lb_policy.h +++ b/src/core/load_balancing/lb_policy.h @@ -430,7 +430,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { // A picker that returns PickResult::Queue for all picks. // Also calls the parent LB policy's ExitIdleLocked() method when the // first pick is seen. - class QueuePicker : public SubchannelPicker { + class QueuePicker final : public SubchannelPicker { public: explicit QueuePicker(RefCountedPtr parent) : parent_(std::move(parent)) {} @@ -445,7 +445,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { }; // A picker that returns PickResult::Fail for all picks. - class TransientFailurePicker : public SubchannelPicker { + class TransientFailurePicker final : public SubchannelPicker { public: explicit TransientFailurePicker(absl::Status status) : status_(status) {} diff --git a/src/core/load_balancing/lb_policy_registry.h b/src/core/load_balancing/lb_policy_registry.h index 7e50b6d1474..018595eff4a 100644 --- a/src/core/load_balancing/lb_policy_registry.h +++ b/src/core/load_balancing/lb_policy_registry.h @@ -33,12 +33,12 @@ namespace grpc_core { -class LoadBalancingPolicyRegistry { +class LoadBalancingPolicyRegistry final { public: /// Methods used to create and populate the LoadBalancingPolicyRegistry. /// NOT THREAD SAFE -- to be used only during global gRPC /// initialization and shutdown. - class Builder { + class Builder final { public: /// Registers an LB policy factory. The factory will be used to create an /// LB policy whose name matches that of the factory. diff --git a/src/core/load_balancing/oob_backend_metric.cc b/src/core/load_balancing/oob_backend_metric.cc index d5244395fe7..854a4dba3bf 100644 --- a/src/core/load_balancing/oob_backend_metric.cc +++ b/src/core/load_balancing/oob_backend_metric.cc @@ -66,7 +66,7 @@ TraceFlag grpc_orca_client_trace(false, "orca_client"); // OrcaProducer::ConnectivityWatcher // -class OrcaProducer::ConnectivityWatcher +class OrcaProducer::ConnectivityWatcher final : public Subchannel::ConnectivityStateWatcherInterface { public: explicit ConnectivityWatcher(WeakRefCountedPtr producer) @@ -97,7 +97,7 @@ class OrcaProducer::ConnectivityWatcher // OrcaProducer::OrcaStreamEventHandler // -class OrcaProducer::OrcaStreamEventHandler +class OrcaProducer::OrcaStreamEventHandler final : public SubchannelStreamClient::CallEventHandler { public: OrcaStreamEventHandler(WeakRefCountedPtr producer, @@ -168,7 +168,7 @@ class OrcaProducer::OrcaStreamEventHandler // notifications, which avoids lock inversion problems due to // acquiring producer_->mu_ while holding the lock from inside of // SubchannelStreamClient. - class BackendMetricAllocator : public BackendMetricAllocatorInterface { + class BackendMetricAllocator final : public BackendMetricAllocatorInterface { public: explicit BackendMetricAllocator(WeakRefCountedPtr producer) : producer_(std::move(producer)) {} diff --git a/src/core/load_balancing/oob_backend_metric_internal.h b/src/core/load_balancing/oob_backend_metric_internal.h index 0c8a0afacbc..ee088f97064 100644 --- a/src/core/load_balancing/oob_backend_metric_internal.h +++ b/src/core/load_balancing/oob_backend_metric_internal.h @@ -46,7 +46,7 @@ class OrcaWatcher; // This producer is registered with a subchannel. It creates a // streaming ORCA call and reports the resulting backend metrics to all // registered watchers. -class OrcaProducer : public Subchannel::DataProducerInterface { +class OrcaProducer final : public Subchannel::DataProducerInterface { public: void Start(RefCountedPtr subchannel); @@ -92,7 +92,7 @@ class OrcaProducer : public Subchannel::DataProducerInterface { // This watcher is returned to the LB policy and added to the // client channel SubchannelWrapper. -class OrcaWatcher : public InternalSubchannelDataWatcherInterface { +class OrcaWatcher final : public InternalSubchannelDataWatcherInterface { public: OrcaWatcher(Duration report_interval, std::unique_ptr watcher) diff --git a/src/core/load_balancing/outlier_detection/outlier_detection.cc b/src/core/load_balancing/outlier_detection/outlier_detection.cc index 208d2369806..e6e85a8bffa 100644 --- a/src/core/load_balancing/outlier_detection/outlier_detection.cc +++ b/src/core/load_balancing/outlier_detection/outlier_detection.cc @@ -85,7 +85,7 @@ constexpr absl::string_view kOutlierDetection = "outlier_detection_experimental"; // Config for xDS Cluster Impl LB policy. -class OutlierDetectionLbConfig : public LoadBalancingPolicy::Config { +class OutlierDetectionLbConfig final : public LoadBalancingPolicy::Config { public: OutlierDetectionLbConfig( OutlierDetectionConfig outlier_detection_config, @@ -114,7 +114,7 @@ class OutlierDetectionLbConfig : public LoadBalancingPolicy::Config { }; // xDS Cluster Impl LB policy. -class OutlierDetectionLb : public LoadBalancingPolicy { +class OutlierDetectionLb final : public LoadBalancingPolicy { public: explicit OutlierDetectionLb(Args args); @@ -128,7 +128,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { class SubchannelState; class EndpointState; - class SubchannelWrapper : public DelegatingSubchannel { + class SubchannelWrapper final : public DelegatingSubchannel { public: SubchannelWrapper(std::shared_ptr work_serializer, RefCountedPtr subchannel_state, @@ -158,7 +158,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { } private: - class WatcherWrapper + class WatcherWrapper final : public SubchannelInterface::ConnectivityStateWatcherInterface { public: WatcherWrapper(std::shared_ptr< @@ -234,7 +234,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { WatcherWrapper* watcher_wrapper_ = nullptr; }; - class SubchannelState : public RefCounted { + class SubchannelState final : public RefCounted { public: void AddSubchannel(SubchannelWrapper* wrapper) { subchannels_.insert(wrapper); @@ -277,7 +277,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { RefCountedPtr endpoint_state_ ABSL_GUARDED_BY(mu_); }; - class EndpointState : public RefCounted { + class EndpointState final : public RefCounted { public: explicit EndpointState(std::set subchannels) : subchannels_(std::move(subchannels)) { @@ -371,7 +371,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { }; // A picker that wraps the picker from the child to perform outlier detection. - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(OutlierDetectionLb* outlier_detection_lb, RefCountedPtr picker, bool counting_enabled); @@ -384,7 +384,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { bool counting_enabled_; }; - class Helper + class Helper final : public ParentOwningDelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr outlier_detection_policy) @@ -398,7 +398,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy { RefCountedPtr picker) override; }; - class EjectionTimer : public InternallyRefCounted { + class EjectionTimer final : public InternallyRefCounted { public: EjectionTimer(RefCountedPtr parent, Timestamp start_time); @@ -483,7 +483,7 @@ void OutlierDetectionLb::SubchannelWrapper::CancelDataWatcher( // OutlierDetectionLb::Picker::SubchannelCallTracker // -class OutlierDetectionLb::Picker::SubchannelCallTracker +class OutlierDetectionLb::Picker::SubchannelCallTracker final : public LoadBalancingPolicy::SubchannelCallTrackerInterface { public: SubchannelCallTracker( @@ -1068,7 +1068,7 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() { // factory // -class OutlierDetectionLbFactory : public LoadBalancingPolicyFactory { +class OutlierDetectionLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/pick_first/pick_first.cc b/src/core/load_balancing/pick_first/pick_first.cc index 27c4de11db8..0459619827a 100644 --- a/src/core/load_balancing/pick_first/pick_first.cc +++ b/src/core/load_balancing/pick_first/pick_first.cc @@ -97,7 +97,7 @@ const auto kMetricConnectionAttemptsFailed = "EXPERIMENTAL. Number of failed connection attempts.", "{attempt}", {kMetricLabelTarget}, {}, false); -class PickFirstConfig : public LoadBalancingPolicy::Config { +class PickFirstConfig final : public LoadBalancingPolicy::Config { public: absl::string_view name() const override { return kPickFirst; } bool shuffle_addresses() const { return shuffle_addresses_; } @@ -115,7 +115,7 @@ class PickFirstConfig : public LoadBalancingPolicy::Config { bool shuffle_addresses_ = false; }; -class PickFirst : public LoadBalancingPolicy { +class PickFirst final : public LoadBalancingPolicy { public: explicit PickFirst(Args args); @@ -128,9 +128,9 @@ class PickFirst : public LoadBalancingPolicy { private: ~PickFirst() override; - class SubchannelList : public InternallyRefCounted { + class SubchannelList final : public InternallyRefCounted { public: - class SubchannelData { + class SubchannelData final { public: SubchannelData(SubchannelList* subchannel_list, size_t index, RefCountedPtr subchannel); @@ -162,7 +162,7 @@ class PickFirst : public LoadBalancingPolicy { private: // Watcher for subchannel connectivity state. - class Watcher + class Watcher final : public SubchannelInterface::ConnectivityStateWatcherInterface { public: Watcher(RefCountedPtr subchannel_list, size_t index) @@ -287,7 +287,7 @@ class PickFirst : public LoadBalancingPolicy { absl::Status last_failure_; }; - class HealthWatcher + class HealthWatcher final : public SubchannelInterface::ConnectivityStateWatcherInterface { public: explicit HealthWatcher(RefCountedPtr policy) @@ -308,7 +308,7 @@ class PickFirst : public LoadBalancingPolicy { RefCountedPtr policy_; }; - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: explicit Picker(RefCountedPtr subchannel) : subchannel_(std::move(subchannel)) {} @@ -467,7 +467,7 @@ absl::string_view GetAddressFamily(const grpc_resolved_address& address) { // An endpoint list iterator that returns only entries for a specific // address family, as indicated by the URI scheme. -class AddressFamilyIterator { +class AddressFamilyIterator final { public: AddressFamilyIterator(absl::string_view scheme, size_t index) : scheme_(scheme), index_(index) {} @@ -1128,7 +1128,7 @@ void PickFirst::SubchannelList::MaybeFinishHappyEyeballsPass() { // factory // -class PickFirstFactory : public LoadBalancingPolicyFactory { +class PickFirstFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/priority/priority.cc b/src/core/load_balancing/priority/priority.cc index e6a77772ffc..5b1b0e743ca 100644 --- a/src/core/load_balancing/priority/priority.cc +++ b/src/core/load_balancing/priority/priority.cc @@ -83,7 +83,7 @@ constexpr Duration kChildRetentionInterval = Duration::Minutes(15); constexpr Duration kDefaultChildFailoverTimeout = Duration::Seconds(10); // Config for priority LB policy. -class PriorityLbConfig : public LoadBalancingPolicy::Config { +class PriorityLbConfig final : public LoadBalancingPolicy::Config { public: struct PriorityLbChild { RefCountedPtr config; @@ -119,7 +119,7 @@ class PriorityLbConfig : public LoadBalancingPolicy::Config { }; // priority LB policy. -class PriorityLb : public LoadBalancingPolicy { +class PriorityLb final : public LoadBalancingPolicy { public: explicit PriorityLb(Args args); @@ -131,7 +131,7 @@ class PriorityLb : public LoadBalancingPolicy { private: // Each ChildPriority holds a ref to the PriorityLb. - class ChildPriority : public InternallyRefCounted { + class ChildPriority final : public InternallyRefCounted { public: ChildPriority(RefCountedPtr priority_policy, std::string name); @@ -163,7 +163,7 @@ class PriorityLb : public LoadBalancingPolicy { bool FailoverTimerPending() const { return failover_timer_ != nullptr; } private: - class Helper : public DelegatingChannelControlHelper { + class Helper final : public DelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr priority) : priority_(std::move(priority)) {} @@ -183,7 +183,8 @@ class PriorityLb : public LoadBalancingPolicy { RefCountedPtr priority_; }; - class DeactivationTimer : public InternallyRefCounted { + class DeactivationTimer final + : public InternallyRefCounted { public: explicit DeactivationTimer(RefCountedPtr child_priority); @@ -196,7 +197,7 @@ class PriorityLb : public LoadBalancingPolicy { absl::optional timer_handle_; }; - class FailoverTimer : public InternallyRefCounted { + class FailoverTimer final : public InternallyRefCounted { public: explicit FailoverTimer(RefCountedPtr child_priority); @@ -874,7 +875,7 @@ void PriorityLbConfig::JsonPostLoad(const Json& /*json*/, const JsonArgs&, } } -class PriorityLbFactory : public LoadBalancingPolicyFactory { +class PriorityLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/ring_hash/ring_hash.cc b/src/core/load_balancing/ring_hash/ring_hash.cc index a5d607266b6..a4c0e40a0cd 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.cc +++ b/src/core/load_balancing/ring_hash/ring_hash.cc @@ -114,7 +114,7 @@ namespace { constexpr absl::string_view kRingHash = "ring_hash_experimental"; -class RingHashLbConfig : public LoadBalancingPolicy::Config { +class RingHashLbConfig final : public LoadBalancingPolicy::Config { public: RingHashLbConfig(size_t min_ring_size, size_t max_ring_size) : min_ring_size_(min_ring_size), max_ring_size_(max_ring_size) {} @@ -133,7 +133,7 @@ class RingHashLbConfig : public LoadBalancingPolicy::Config { constexpr size_t kRingSizeCapDefault = 4096; -class RingHash : public LoadBalancingPolicy { +class RingHash final : public LoadBalancingPolicy { public: explicit RingHash(Args args); @@ -144,7 +144,7 @@ class RingHash : public LoadBalancingPolicy { private: // A ring computed based on a config and address list. - class Ring : public RefCounted { + class Ring final : public RefCounted { public: struct RingEntry { uint64_t hash; @@ -160,7 +160,7 @@ class RingHash : public LoadBalancingPolicy { }; // State for a particular endpoint. Delegates to a pick_first child policy. - class RingHashEndpoint : public InternallyRefCounted { + class RingHashEndpoint final : public InternallyRefCounted { public: // index is the index into RingHash::endpoints_ of this endpoint. RingHashEndpoint(RefCountedPtr ring_hash, size_t index) @@ -216,7 +216,7 @@ class RingHash : public LoadBalancingPolicy { RefCountedPtr picker_; }; - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: explicit Picker(RefCountedPtr ring_hash) : ring_hash_(std::move(ring_hash)), @@ -232,7 +232,7 @@ class RingHash : public LoadBalancingPolicy { private: // A fire-and-forget class that schedules endpoint connection attempts // on the control plane WorkSerializer. - class EndpointConnectionAttempter { + class EndpointConnectionAttempter final { public: EndpointConnectionAttempter(RefCountedPtr ring_hash, RefCountedPtr endpoint) @@ -462,7 +462,7 @@ RingHash::Ring::Ring(RingHash* ring_hash, RingHashLbConfig* config) { // RingHash::RingHashEndpoint::Helper // -class RingHash::RingHashEndpoint::Helper +class RingHash::RingHashEndpoint::Helper final : public LoadBalancingPolicy::DelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr endpoint) @@ -849,7 +849,7 @@ void RingHash::UpdateAggregatedConnectivityStateLocked( // factory // -class RingHashFactory : public LoadBalancingPolicyFactory { +class RingHashFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/ring_hash/ring_hash.h b/src/core/load_balancing/ring_hash/ring_hash.h index d2b564e806f..78833f3361f 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.h +++ b/src/core/load_balancing/ring_hash/ring_hash.h @@ -30,7 +30,7 @@ namespace grpc_core { -class RequestHashAttribute +class RequestHashAttribute final : public ServiceConfigCallData::CallAttributeInterface { public: static UniqueTypeName TypeName(); diff --git a/src/core/load_balancing/rls/rls.cc b/src/core/load_balancing/rls/rls.cc index 2f84e664767..aa5a281c5f1 100644 --- a/src/core/load_balancing/rls/rls.cc +++ b/src/core/load_balancing/rls/rls.cc @@ -188,7 +188,7 @@ const Duration kCacheCleanupTimerInterval = Duration::Minutes(1); const int64_t kMaxCacheSizeBytes = 5 * 1024 * 1024; // Parsed RLS LB policy configuration. -class RlsLbConfig : public LoadBalancingPolicy::Config { +class RlsLbConfig final : public LoadBalancingPolicy::Config { public: struct KeyBuilder { std::map> @@ -267,7 +267,7 @@ class RlsLbConfig : public LoadBalancingPolicy::Config { }; // RLS LB policy. -class RlsLb : public LoadBalancingPolicy { +class RlsLb final : public LoadBalancingPolicy { public: explicit RlsLb(Args args); @@ -323,7 +323,7 @@ class RlsLb : public LoadBalancingPolicy { }; // Wraps a child policy for a given RLS target. - class ChildPolicyWrapper : public DualRefCounted { + class ChildPolicyWrapper final : public DualRefCounted { public: ChildPolicyWrapper(RefCountedPtr lb_policy, std::string target); @@ -374,7 +374,7 @@ class RlsLb : public LoadBalancingPolicy { private: // ChannelControlHelper object that allows the child policy to update state // with the wrapper. - class ChildPolicyHelper : public DelegatingChannelControlHelper { + class ChildPolicyHelper final : public DelegatingChannelControlHelper { public: explicit ChildPolicyHelper(WeakRefCountedPtr wrapper) : wrapper_(std::move(wrapper)) {} @@ -415,7 +415,7 @@ class RlsLb : public LoadBalancingPolicy { // A picker that uses the cache and the request map in the LB policy // (synchronized via a mutex) to determine how to route requests. - class Picker : public LoadBalancingPolicy::SubchannelPicker { + class Picker final : public LoadBalancingPolicy::SubchannelPicker { public: explicit Picker(RefCountedPtr lb_policy); @@ -432,11 +432,11 @@ class RlsLb : public LoadBalancingPolicy { }; // An LRU cache with adjustable size. - class Cache { + class Cache final { public: using Iterator = std::list::iterator; - class Entry : public InternallyRefCounted { + class Entry final : public InternallyRefCounted { public: Entry(RefCountedPtr lb_policy, const RequestKey& key); @@ -508,7 +508,7 @@ class RlsLb : public LoadBalancingPolicy { void MarkUsed() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); private: - class BackoffTimer : public InternallyRefCounted { + class BackoffTimer final : public InternallyRefCounted { public: BackoffTimer(RefCountedPtr entry, Timestamp backoff_time); @@ -607,7 +607,7 @@ class RlsLb : public LoadBalancingPolicy { // Channel for communicating with the RLS server. // Contains throttling logic for RLS requests. - class RlsChannel : public InternallyRefCounted { + class RlsChannel final : public InternallyRefCounted { public: explicit RlsChannel(RefCountedPtr lb_policy); @@ -637,7 +637,7 @@ class RlsLb : public LoadBalancingPolicy { private: // Watches the state of the RLS channel. Notifies the LB policy when // the channel was previously in TRANSIENT_FAILURE and then becomes READY. - class StateWatcher : public AsyncConnectivityStateWatcherInterface { + class StateWatcher final : public AsyncConnectivityStateWatcherInterface { public: explicit StateWatcher(RefCountedPtr rls_channel) : AsyncConnectivityStateWatcherInterface( @@ -653,7 +653,7 @@ class RlsLb : public LoadBalancingPolicy { }; // Throttle state for RLS requests. - class Throttle { + class Throttle final { public: explicit Throttle( Duration window_size = kDefaultThrottleWindowSize, @@ -691,7 +691,7 @@ class RlsLb : public LoadBalancingPolicy { }; // A pending RLS request. Instances will be tracked in request_map_. - class RlsRequest : public InternallyRefCounted { + class RlsRequest final : public InternallyRefCounted { public: // Asynchronously starts a call on rls_channel for key. // Stores backoff_state, which will be transferred to the data cache @@ -2574,7 +2574,7 @@ void RlsLbConfig::JsonPostLoad(const Json& json, const JsonArgs&, } } -class RlsLbFactory : public LoadBalancingPolicyFactory { +class RlsLbFactory final : public LoadBalancingPolicyFactory { public: absl::string_view name() const override { return kRls; } diff --git a/src/core/load_balancing/round_robin/round_robin.cc b/src/core/load_balancing/round_robin/round_robin.cc index 1bfa55ccbaa..95160d543b4 100644 --- a/src/core/load_balancing/round_robin/round_robin.cc +++ b/src/core/load_balancing/round_robin/round_robin.cc @@ -59,7 +59,7 @@ namespace { constexpr absl::string_view kRoundRobin = "round_robin"; -class RoundRobin : public LoadBalancingPolicy { +class RoundRobin final : public LoadBalancingPolicy { public: explicit RoundRobin(Args args); @@ -69,7 +69,7 @@ class RoundRobin : public LoadBalancingPolicy { void ResetBackoffLocked() override; private: - class RoundRobinEndpointList : public EndpointList { + class RoundRobinEndpointList final : public EndpointList { public: RoundRobinEndpointList(RefCountedPtr round_robin, EndpointAddressesIterator* endpoints, @@ -88,7 +88,7 @@ class RoundRobin : public LoadBalancingPolicy { } private: - class RoundRobinEndpoint : public Endpoint { + class RoundRobinEndpoint final : public Endpoint { public: RoundRobinEndpoint(RefCountedPtr endpoint_list, const EndpointAddresses& addresses, @@ -135,7 +135,7 @@ class RoundRobin : public LoadBalancingPolicy { absl::Status last_failure_; }; - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(RoundRobin* parent, std::vector> @@ -431,12 +431,12 @@ void RoundRobin::RoundRobinEndpointList:: // factory // -class RoundRobinConfig : public LoadBalancingPolicy::Config { +class RoundRobinConfig final : public LoadBalancingPolicy::Config { public: absl::string_view name() const override { return kRoundRobin; } }; -class RoundRobinFactory : public LoadBalancingPolicyFactory { +class RoundRobinFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h index 72c72a0ff79..3bd8ec147fd 100644 --- a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h +++ b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h @@ -39,7 +39,7 @@ namespace grpc_core { // Construction is O(|weights|). Picking is O(1) if weights are similar, or // O(|weights|) if the mean of the non-zero weights is a small fraction of the // max. Stores two bytes per weight. -class StaticStrideScheduler { +class StaticStrideScheduler final { public: // Constructs and returns a new StaticStrideScheduler, or nullopt if all // wieghts are zero or |weights| <= 1. All weights must be >=0. diff --git a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc index 2870b34bab3..66d5b03325b 100644 --- a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +++ b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc @@ -118,7 +118,7 @@ const auto kMetricEndpointWeights = "{weight}", {kMetricLabelTarget}, {kMetricLabelLocality}, false); // Config for WRR policy. -class WeightedRoundRobinConfig : public LoadBalancingPolicy::Config { +class WeightedRoundRobinConfig final : public LoadBalancingPolicy::Config { public: WeightedRoundRobinConfig() = default; @@ -179,7 +179,7 @@ class WeightedRoundRobinConfig : public LoadBalancingPolicy::Config { }; // WRR LB policy -class WeightedRoundRobin : public LoadBalancingPolicy { +class WeightedRoundRobin final : public LoadBalancingPolicy { public: explicit WeightedRoundRobin(Args args); @@ -190,7 +190,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy { private: // Represents the weight for a given address. - class EndpointWeight : public RefCounted { + class EndpointWeight final : public RefCounted { public: EndpointWeight(RefCountedPtr wrr, EndpointAddressSet key) @@ -216,9 +216,9 @@ class WeightedRoundRobin : public LoadBalancingPolicy { Timestamp last_update_time_ ABSL_GUARDED_BY(&mu_) = Timestamp::InfPast(); }; - class WrrEndpointList : public EndpointList { + class WrrEndpointList final : public EndpointList { public: - class WrrEndpoint : public Endpoint { + class WrrEndpoint final : public Endpoint { public: WrrEndpoint(RefCountedPtr endpoint_list, const EndpointAddresses& addresses, const ChannelArgs& args, @@ -232,7 +232,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy { RefCountedPtr weight() const { return weight_; } private: - class OobWatcher : public OobBackendMetricWatcher { + class OobWatcher final : public OobBackendMetricWatcher { public: OobWatcher(RefCountedPtr weight, float error_utilization_penalty) @@ -309,7 +309,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy { // A picker that performs WRR picks with weights based on // endpoint-reported utilization and QPS. - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(RefCountedPtr wrr, WrrEndpointList* endpoint_list); @@ -320,7 +320,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy { private: // A call tracker that collects per-call endpoint utilization reports. - class SubchannelCallTracker : public SubchannelCallTrackerInterface { + class SubchannelCallTracker final : public SubchannelCallTrackerInterface { public: SubchannelCallTracker( RefCountedPtr weight, float error_utilization_penalty, @@ -997,7 +997,7 @@ void WeightedRoundRobin::WrrEndpointList:: // factory // -class WeightedRoundRobinFactory : public LoadBalancingPolicyFactory { +class WeightedRoundRobinFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/weighted_target/weighted_target.cc b/src/core/load_balancing/weighted_target/weighted_target.cc index 6621436a44d..3f32142a76a 100644 --- a/src/core/load_balancing/weighted_target/weighted_target.cc +++ b/src/core/load_balancing/weighted_target/weighted_target.cc @@ -83,7 +83,7 @@ constexpr absl::string_view kWeightedTarget = "weighted_target_experimental"; constexpr Duration kChildRetentionInterval = Duration::Minutes(15); // Config for weighted_target LB policy. -class WeightedTargetLbConfig : public LoadBalancingPolicy::Config { +class WeightedTargetLbConfig final : public LoadBalancingPolicy::Config { public: struct ChildConfig { uint32_t weight; @@ -115,7 +115,7 @@ class WeightedTargetLbConfig : public LoadBalancingPolicy::Config { }; // weighted_target LB policy. -class WeightedTargetLb : public LoadBalancingPolicy { +class WeightedTargetLb final : public LoadBalancingPolicy { public: explicit WeightedTargetLb(Args args); @@ -127,7 +127,7 @@ class WeightedTargetLb : public LoadBalancingPolicy { private: // Picks a child using stateless WRR and then delegates to that // child's picker. - class WeightedPicker : public SubchannelPicker { + class WeightedPicker final : public SubchannelPicker { public: // Maintains a weighted list of pickers from each child that is in // ready state. The first element in the pair represents the end of a @@ -151,7 +151,7 @@ class WeightedTargetLb : public LoadBalancingPolicy { }; // Each WeightedChild holds a ref to its parent WeightedTargetLb. - class WeightedChild : public InternallyRefCounted { + class WeightedChild final : public InternallyRefCounted { public: WeightedChild(RefCountedPtr weighted_target_policy, const std::string& name); @@ -173,7 +173,7 @@ class WeightedTargetLb : public LoadBalancingPolicy { RefCountedPtr picker() const { return picker_; } private: - class Helper : public DelegatingChannelControlHelper { + class Helper final : public DelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr weighted_child) : weighted_child_(std::move(weighted_child)) {} @@ -193,7 +193,7 @@ class WeightedTargetLb : public LoadBalancingPolicy { RefCountedPtr weighted_child_; }; - class DelayedRemovalTimer + class DelayedRemovalTimer final : public InternallyRefCounted { public: explicit DelayedRemovalTimer(RefCountedPtr weighted_child); @@ -732,7 +732,7 @@ const JsonLoaderInterface* WeightedTargetLbConfig::JsonLoader(const JsonArgs&) { return loader; } -class WeightedTargetLbFactory : public LoadBalancingPolicyFactory { +class WeightedTargetLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/xds/cds.cc b/src/core/load_balancing/xds/cds.cc index 61883499a33..a46c1e8b488 100644 --- a/src/core/load_balancing/xds/cds.cc +++ b/src/core/load_balancing/xds/cds.cc @@ -85,7 +85,7 @@ using XdsConfig = XdsDependencyManager::XdsConfig; constexpr absl::string_view kCds = "cds_experimental"; // Config for this LB policy. -class CdsLbConfig : public LoadBalancingPolicy::Config { +class CdsLbConfig final : public LoadBalancingPolicy::Config { public: CdsLbConfig() = default; @@ -115,7 +115,7 @@ class CdsLbConfig : public LoadBalancingPolicy::Config { }; // CDS LB policy. -class CdsLb : public LoadBalancingPolicy { +class CdsLb final : public LoadBalancingPolicy { public: explicit CdsLb(Args args); @@ -232,7 +232,7 @@ std::string MakeChildPolicyName(absl::string_view cluster, "}"); } -class PriorityEndpointIterator : public EndpointAddressesIterator { +class PriorityEndpointIterator final : public EndpointAddressesIterator { public: PriorityEndpointIterator( std::string cluster_name, @@ -731,7 +731,7 @@ void CdsLb::ReportTransientFailure(absl::Status status) { // factory // -class CdsLbFactory : public LoadBalancingPolicyFactory { +class CdsLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/xds/xds_cluster_impl.cc b/src/core/load_balancing/xds/xds_cluster_impl.cc index fc5c5e32b7a..0f03857ce21 100644 --- a/src/core/load_balancing/xds/xds_cluster_impl.cc +++ b/src/core/load_balancing/xds/xds_cluster_impl.cc @@ -86,12 +86,12 @@ using XdsConfig = XdsDependencyManager::XdsConfig; // global circuit breaker atomic map // -class CircuitBreakerCallCounterMap { +class CircuitBreakerCallCounterMap final { public: using Key = std::pair; - class CallCounter : public RefCounted { + class CallCounter final : public RefCounted { public: explicit CallCounter(Key key) : key_(std::move(key)) {} ~CallCounter() override; @@ -152,7 +152,7 @@ CircuitBreakerCallCounterMap::CallCounter::~CallCounter() { constexpr absl::string_view kXdsClusterImpl = "xds_cluster_impl_experimental"; // Config for xDS Cluster Impl LB policy. -class XdsClusterImplLbConfig : public LoadBalancingPolicy::Config { +class XdsClusterImplLbConfig final : public LoadBalancingPolicy::Config { public: XdsClusterImplLbConfig() = default; @@ -179,7 +179,7 @@ class XdsClusterImplLbConfig : public LoadBalancingPolicy::Config { }; // xDS Cluster Impl LB policy. -class XdsClusterImplLb : public LoadBalancingPolicy { +class XdsClusterImplLb final : public LoadBalancingPolicy { public: XdsClusterImplLb(RefCountedPtr xds_client, Args args); @@ -190,7 +190,7 @@ class XdsClusterImplLb : public LoadBalancingPolicy { void ResetBackoffLocked() override; private: - class StatsSubchannelWrapper : public DelegatingSubchannel { + class StatsSubchannelWrapper final : public DelegatingSubchannel { public: // If load reporting is enabled and we have an XdsClusterLocalityStats // object, that object already contains the locality labels. We @@ -235,7 +235,7 @@ class XdsClusterImplLb : public LoadBalancingPolicy { }; // A picker that wraps the picker from the child to perform drops. - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(XdsClusterImplLb* xds_cluster_impl_lb, RefCountedPtr picker); @@ -253,7 +253,7 @@ class XdsClusterImplLb : public LoadBalancingPolicy { RefCountedPtr picker_; }; - class Helper + class Helper final : public ParentOwningDelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr xds_cluster_impl_policy) @@ -315,7 +315,7 @@ class XdsClusterImplLb : public LoadBalancingPolicy { // XdsClusterImplLb::Picker::SubchannelCallTracker // -class XdsClusterImplLb::Picker::SubchannelCallTracker +class XdsClusterImplLb::Picker::SubchannelCallTracker final : public LoadBalancingPolicy::SubchannelCallTrackerInterface { public: SubchannelCallTracker( @@ -866,7 +866,7 @@ void XdsClusterImplLbConfig::JsonPostLoad(const Json& json, const JsonArgs&, } } -class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory { +class XdsClusterImplLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/xds/xds_cluster_manager.cc b/src/core/load_balancing/xds/xds_cluster_manager.cc index 2dfc4498aae..4cad8116953 100644 --- a/src/core/load_balancing/xds/xds_cluster_manager.cc +++ b/src/core/load_balancing/xds/xds_cluster_manager.cc @@ -75,7 +75,7 @@ constexpr absl::string_view kXdsClusterManager = "xds_cluster_manager_experimental"; // Config for xds_cluster_manager LB policy. -class XdsClusterManagerLbConfig : public LoadBalancingPolicy::Config { +class XdsClusterManagerLbConfig final : public LoadBalancingPolicy::Config { public: struct Child { RefCountedPtr config; @@ -108,7 +108,7 @@ class XdsClusterManagerLbConfig : public LoadBalancingPolicy::Config { }; // xds_cluster_manager LB policy. -class XdsClusterManagerLb : public LoadBalancingPolicy { +class XdsClusterManagerLb final : public LoadBalancingPolicy { public: explicit XdsClusterManagerLb(Args args); @@ -121,7 +121,7 @@ class XdsClusterManagerLb : public LoadBalancingPolicy { private: // Picks a child using prefix or path matching and then delegates to that // child's picker. - class ClusterPicker : public SubchannelPicker { + class ClusterPicker final : public SubchannelPicker { public: // Maintains a map of cluster names to pickers. using ClusterMap = std::map { + class ClusterChild final : public InternallyRefCounted { public: ClusterChild(RefCountedPtr xds_cluster_manager_policy, const std::string& name); @@ -162,7 +162,7 @@ class XdsClusterManagerLb : public LoadBalancingPolicy { RefCountedPtr picker() const { return picker_; } private: - class Helper : public DelegatingChannelControlHelper { + class Helper final : public DelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr xds_cluster_manager_child) : xds_cluster_manager_child_(std::move(xds_cluster_manager_child)) {} @@ -625,7 +625,7 @@ const JsonLoaderInterface* XdsClusterManagerLbConfig::JsonLoader( return loader; } -class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory { +class XdsClusterManagerLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/xds/xds_override_host.cc b/src/core/load_balancing/xds/xds_override_host.cc index 93344e596cd..4fcc5a77b6d 100644 --- a/src/core/load_balancing/xds/xds_override_host.cc +++ b/src/core/load_balancing/xds/xds_override_host.cc @@ -111,7 +111,7 @@ struct PtrLessThan { // xds_override_host LB policy // -class XdsOverrideHostLb : public LoadBalancingPolicy { +class XdsOverrideHostLb final : public LoadBalancingPolicy { public: explicit XdsOverrideHostLb(Args args); @@ -126,7 +126,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { private: class SubchannelEntry; - class SubchannelWrapper : public DelegatingSubchannel { + class SubchannelWrapper final : public DelegatingSubchannel { public: SubchannelWrapper(RefCountedPtr subchannel, RefCountedPtr policy); @@ -163,7 +163,8 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { } private: - class ConnectivityStateWatcher : public ConnectivityStateWatcherInterface { + class ConnectivityStateWatcher final + : public ConnectivityStateWatcherInterface { public: explicit ConnectivityStateWatcher( WeakRefCountedPtr subchannel) @@ -210,7 +211,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { // avoid that, any method that may result in releasing a ref to the // SubchannelWrapper will instead return that ref to the caller, who is // responsible for releasing the ref after releasing the lock. - class SubchannelEntry : public RefCounted { + class SubchannelEntry final : public RefCounted { public: bool HasOwnedSubchannel() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsOverrideHostLb::mu_) { @@ -313,7 +314,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { // A picker that wraps the picker from the child for cases when cookie is // present. - class Picker : public SubchannelPicker { + class Picker final : public SubchannelPicker { public: Picker(RefCountedPtr xds_override_host_lb, RefCountedPtr picker, @@ -322,7 +323,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { PickResult Pick(PickArgs args) override; private: - class SubchannelConnectionRequester { + class SubchannelConnectionRequester final { public: explicit SubchannelConnectionRequester( RefCountedPtr subchannel) @@ -348,7 +349,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { grpc_closure closure_; }; - class SubchannelCreationRequester { + class SubchannelCreationRequester final { public: SubchannelCreationRequester(RefCountedPtr policy, absl::string_view address) @@ -383,7 +384,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { XdsHealthStatusSet override_host_health_status_set_; }; - class Helper + class Helper final : public ParentOwningDelegatingChannelControlHelper { public: explicit Helper(RefCountedPtr xds_override_host_policy) @@ -397,7 +398,7 @@ class XdsOverrideHostLb : public LoadBalancingPolicy { RefCountedPtr picker) override; }; - class IdleTimer : public InternallyRefCounted { + class IdleTimer final : public InternallyRefCounted { public: IdleTimer(RefCountedPtr policy, Duration duration); @@ -729,7 +730,7 @@ XdsHealthStatus GetEndpointHealthStatus(const EndpointAddresses& endpoint) { } // Wraps the endpoint iterator and filters out endpoints in state DRAINING. -class ChildEndpointIterator : public EndpointAddressesIterator { +class ChildEndpointIterator final : public EndpointAddressesIterator { public: explicit ChildEndpointIterator( std::shared_ptr parent_it) @@ -1251,7 +1252,7 @@ void XdsOverrideHostLb::SubchannelEntry::OnSubchannelWrapperOrphan( // factory // -class XdsOverrideHostLbFactory : public LoadBalancingPolicyFactory { +class XdsOverrideHostLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/load_balancing/xds/xds_override_host.h b/src/core/load_balancing/xds/xds_override_host.h index 6c4d18b96d0..a9adae2eaa8 100644 --- a/src/core/load_balancing/xds/xds_override_host.h +++ b/src/core/load_balancing/xds/xds_override_host.h @@ -31,7 +31,7 @@ namespace grpc_core { // Config for stateful session LB policy. -class XdsOverrideHostLbConfig : public LoadBalancingPolicy::Config { +class XdsOverrideHostLbConfig final : public LoadBalancingPolicy::Config { public: XdsOverrideHostLbConfig() = default; diff --git a/src/core/load_balancing/xds/xds_wrr_locality.cc b/src/core/load_balancing/xds/xds_wrr_locality.cc index b5bb19172f8..de2264a0389 100644 --- a/src/core/load_balancing/xds/xds_wrr_locality.cc +++ b/src/core/load_balancing/xds/xds_wrr_locality.cc @@ -61,7 +61,7 @@ namespace { constexpr absl::string_view kXdsWrrLocality = "xds_wrr_locality_experimental"; // Config for xds_wrr_locality LB policy. -class XdsWrrLocalityLbConfig : public LoadBalancingPolicy::Config { +class XdsWrrLocalityLbConfig final : public LoadBalancingPolicy::Config { public: XdsWrrLocalityLbConfig() = default; @@ -106,7 +106,7 @@ class XdsWrrLocalityLbConfig : public LoadBalancingPolicy::Config { }; // xds_wrr_locality LB policy. -class XdsWrrLocalityLb : public LoadBalancingPolicy { +class XdsWrrLocalityLb final : public LoadBalancingPolicy { public: explicit XdsWrrLocalityLb(Args args); @@ -273,7 +273,7 @@ OrphanablePtr XdsWrrLocalityLb::CreateChildPolicyLocked( // factory // -class XdsWrrLocalityLbFactory : public LoadBalancingPolicyFactory { +class XdsWrrLocalityLbFactory final : public LoadBalancingPolicyFactory { public: OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { diff --git a/src/core/resolver/binder/binder_resolver.cc b/src/core/resolver/binder/binder_resolver.cc index dfc8e15b2d8..b0187ca3c40 100644 --- a/src/core/resolver/binder/binder_resolver.cc +++ b/src/core/resolver/binder/binder_resolver.cc @@ -57,7 +57,7 @@ namespace grpc_core { namespace { -class BinderResolver : public Resolver { +class BinderResolver final : public Resolver { public: BinderResolver(EndpointAddressesList addresses, ResolverArgs args) : result_handler_(std::move(args.result_handler)), @@ -80,7 +80,7 @@ class BinderResolver : public Resolver { ChannelArgs channel_args_; }; -class BinderResolverFactory : public ResolverFactory { +class BinderResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "binder"; } diff --git a/src/core/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/resolver/dns/c_ares/dns_resolver_ares.cc index aa50e62005d..b394fd635d2 100644 --- a/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/resolver/dns/c_ares/dns_resolver_ares.cc @@ -82,7 +82,7 @@ namespace grpc_core { namespace { -class AresClientChannelDNSResolver : public PollingResolver { +class AresClientChannelDNSResolver final : public PollingResolver { public: AresClientChannelDNSResolver(ResolverArgs args, Duration min_time_between_resolutions); @@ -90,7 +90,8 @@ class AresClientChannelDNSResolver : public PollingResolver { OrphanablePtr StartRequest() override; private: - class AresRequestWrapper : public InternallyRefCounted { + class AresRequestWrapper final + : public InternallyRefCounted { public: explicit AresRequestWrapper( RefCountedPtr resolver) @@ -342,7 +343,7 @@ AresClientChannelDNSResolver::AresRequestWrapper::OnResolvedLocked( // Factory // -class AresClientChannelDNSResolverFactory : public ResolverFactory { +class AresClientChannelDNSResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "dns"; } @@ -365,7 +366,7 @@ class AresClientChannelDNSResolverFactory : public ResolverFactory { } }; -class AresDNSResolver : public DNSResolver { +class AresDNSResolver final : public DNSResolver { public: // Abstract class that centralizes common request handling logic via the // template method pattern. @@ -485,7 +486,7 @@ class AresDNSResolver : public DNSResolver { grpc_pollset_set* pollset_set_; }; - class AresHostnameRequest : public AresRequest { + class AresHostnameRequest final : public AresRequest { public: AresHostnameRequest( absl::string_view name, absl::string_view default_port, @@ -538,7 +539,7 @@ class AresDNSResolver : public DNSResolver { std::unique_ptr addresses_; }; - class AresSRVRequest : public AresRequest { + class AresSRVRequest final : public AresRequest { public: AresSRVRequest( absl::string_view name, absl::string_view name_server, Duration timeout, @@ -586,7 +587,7 @@ class AresDNSResolver : public DNSResolver { std::unique_ptr balancer_addresses_; }; - class AresTXTRequest : public AresRequest { + class AresTXTRequest final : public AresRequest { public: AresTXTRequest(absl::string_view name, absl::string_view name_server, Duration timeout, grpc_pollset_set* interested_parties, diff --git a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index 6e6c2bd62e6..bf56486ed93 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -51,7 +51,7 @@ namespace grpc_core { -class GrpcPolledFdPosix : public GrpcPolledFd { +class GrpcPolledFdPosix final : public GrpcPolledFd { public: GrpcPolledFdPosix(ares_socket_t as, grpc_pollset_set* driver_pollset_set) : name_(absl::StrCat("c-ares fd: ", static_cast(as))), as_(as) { @@ -105,7 +105,7 @@ class GrpcPolledFdPosix : public GrpcPolledFd { grpc_pollset_set* driver_pollset_set_ ABSL_GUARDED_BY(&grpc_ares_request::mu); }; -class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory { +class GrpcPolledFdFactoryPosix final : public GrpcPolledFdFactory { public: ~GrpcPolledFdFactoryPosix() override { for (auto& fd : owned_fds_) { diff --git a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 9969e95546f..a016cae956b 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -70,7 +70,7 @@ namespace { // c-ares should read, it must do so by calling SetWSAError() on the // WSAErrorContext instance passed to it. A WSAErrorContext must only be // instantiated at the top of the virtual socket function callstack. -class WSAErrorContext { +class WSAErrorContext final { public: explicit WSAErrorContext(){}; @@ -99,7 +99,7 @@ class WSAErrorContext { // from c-ares and are used with the grpc windows poller, and it, e.g., // manufactures virtual socket error codes when it e.g. needs to tell the c-ares // library to wait for an async read. -class GrpcPolledFdWindows : public GrpcPolledFd { +class GrpcPolledFdWindows final : public GrpcPolledFd { public: enum WriteState { WRITE_IDLE, @@ -694,7 +694,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { absl::AnyInvocable on_shutdown_locked_; }; -class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory { +class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory { public: explicit GrpcPolledFdFactoryWindows(Mutex* mu) : mu_(mu) {} diff --git a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc index e1abc64b95f..23b9c2adae7 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -166,7 +166,7 @@ static void grpc_ares_request_unref_locked(grpc_ares_request* r) // organize per-query and per-resolution information in such a way // that doesn't involve allocating a number of different data // structures. -class GrpcAresQuery { +class GrpcAresQuery final { public: explicit GrpcAresQuery(grpc_ares_request* r, const std::string& name) : r_(r), name_(name) { diff --git a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc index 1305580fe7c..432e948968c 100644 --- a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +++ b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc @@ -92,7 +92,7 @@ TraceFlag grpc_event_engine_client_channel_resolver_trace( // ---------------------------------------------------------------------------- // EventEngineClientChannelDNSResolver // ---------------------------------------------------------------------------- -class EventEngineClientChannelDNSResolver : public PollingResolver { +class EventEngineClientChannelDNSResolver final : public PollingResolver { public: EventEngineClientChannelDNSResolver(ResolverArgs args, Duration min_time_between_resolutions); @@ -102,7 +102,7 @@ class EventEngineClientChannelDNSResolver : public PollingResolver { // ---------------------------------------------------------------------------- // EventEngineDNSRequestWrapper declaration // ---------------------------------------------------------------------------- - class EventEngineDNSRequestWrapper + class EventEngineDNSRequestWrapper final : public InternallyRefCounted { public: EventEngineDNSRequestWrapper( diff --git a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h index 57492bf9677..10d8f10a4d3 100644 --- a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h +++ b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h @@ -23,7 +23,9 @@ #include "src/core/lib/uri/uri_parser.h" namespace grpc_core { -class EventEngineClientChannelDNSResolverFactory : public ResolverFactory { + +class EventEngineClientChannelDNSResolverFactory final + : public ResolverFactory { public: absl::string_view scheme() const override { return "dns"; } bool IsValidUri(const URI& uri) const override; diff --git a/src/core/resolver/dns/native/dns_resolver.cc b/src/core/resolver/dns/native/dns_resolver.cc index 9ee003c81b9..3634e00e85c 100644 --- a/src/core/resolver/dns/native/dns_resolver.cc +++ b/src/core/resolver/dns/native/dns_resolver.cc @@ -59,7 +59,7 @@ namespace { TraceFlag grpc_trace_dns_resolver(false, "dns_resolver"); -class NativeClientChannelDNSResolver : public PollingResolver { +class NativeClientChannelDNSResolver final : public PollingResolver { public: NativeClientChannelDNSResolver(ResolverArgs args, Duration min_time_between_resolutions); @@ -71,7 +71,7 @@ class NativeClientChannelDNSResolver : public PollingResolver { // No-op request class, used so that the PollingResolver code knows // when there is a request in flight, even if the request is not // actually cancellable. - class Request : public Orphanable { + class Request final : public Orphanable { public: Request() = default; @@ -145,7 +145,7 @@ void NativeClientChannelDNSResolver::OnResolved( // Factory // -class NativeClientChannelDNSResolverFactory : public ResolverFactory { +class NativeClientChannelDNSResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "dns"; } diff --git a/src/core/resolver/endpoint_addresses.h b/src/core/resolver/endpoint_addresses.h index 5c9fdf956dd..789f7ede86b 100644 --- a/src/core/resolver/endpoint_addresses.h +++ b/src/core/resolver/endpoint_addresses.h @@ -45,7 +45,7 @@ namespace grpc_core { // A list of addresses for a given endpoint with an associated set of channel // args. Any args present here will be merged into the channel args when a // subchannel is created for each address. -class EndpointAddresses { +class EndpointAddresses final { public: // For backward compatibility. // TODO(roth): Remove when callers have been updated. @@ -102,7 +102,7 @@ struct ResolvedAddressLessThan { const grpc_resolved_address& addr2) const; }; -class EndpointAddressSet { +class EndpointAddressSet final { public: explicit EndpointAddressSet( const std::vector& addresses) @@ -128,7 +128,7 @@ class EndpointAddressesIterator { }; // Iterator over a fixed list of endpoints. -class EndpointAddressesListIterator : public EndpointAddressesIterator { +class EndpointAddressesListIterator final : public EndpointAddressesIterator { public: explicit EndpointAddressesListIterator(EndpointAddressesList endpoints) : endpoints_(std::move(endpoints)) {} @@ -145,7 +145,7 @@ class EndpointAddressesListIterator : public EndpointAddressesIterator { }; // Iterator that returns only a single endpoint. -class SingleEndpointIterator : public EndpointAddressesIterator { +class SingleEndpointIterator final : public EndpointAddressesIterator { public: explicit SingleEndpointIterator(EndpointAddresses endpoint) : endpoint_(std::move(endpoint)) {} diff --git a/src/core/resolver/fake/fake_resolver.cc b/src/core/resolver/fake/fake_resolver.cc index 713df2ad595..b8385440ab8 100644 --- a/src/core/resolver/fake/fake_resolver.cc +++ b/src/core/resolver/fake/fake_resolver.cc @@ -42,7 +42,7 @@ namespace grpc_core { // This cannot be in an anonymous namespace, because it is a friend of // FakeResolverResponseGenerator. -class FakeResolver : public Resolver { +class FakeResolver final : public Resolver { public: explicit FakeResolver(ResolverArgs args); @@ -232,7 +232,7 @@ const grpc_arg_pointer_vtable namespace { -class FakeResolverFactory : public ResolverFactory { +class FakeResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "fake"; } diff --git a/src/core/resolver/fake/fake_resolver.h b/src/core/resolver/fake/fake_resolver.h index 3a878233f2a..a9d51962485 100644 --- a/src/core/resolver/fake/fake_resolver.h +++ b/src/core/resolver/fake/fake_resolver.h @@ -49,7 +49,7 @@ class FakeResolver; // instead of RefCounted, but external refs are currently needed to // encode this in channel args. Once channel_args are converted to C++, // see if we can find a way to fix this. -class FakeResolverResponseGenerator +class FakeResolverResponseGenerator final : public RefCounted { public: static const grpc_arg_pointer_vtable kChannelArgPointerVtable; diff --git a/src/core/resolver/google_c2p/google_c2p_resolver.cc b/src/core/resolver/google_c2p/google_c2p_resolver.cc index 78bc88bf25c..254c34a2537 100644 --- a/src/core/resolver/google_c2p/google_c2p_resolver.cc +++ b/src/core/resolver/google_c2p/google_c2p_resolver.cc @@ -59,7 +59,7 @@ namespace { const char* kC2PAuthority = "traffic-director-c2p.xds.googleapis.com"; -class GoogleCloud2ProdResolver : public Resolver { +class GoogleCloud2ProdResolver final : public Resolver { public: explicit GoogleCloud2ProdResolver(ResolverArgs args); @@ -276,7 +276,7 @@ void GoogleCloud2ProdResolver::StartXdsResolver() { // Factory // -class GoogleCloud2ProdResolverFactory : public ResolverFactory { +class GoogleCloud2ProdResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "google-c2p"; } @@ -296,7 +296,8 @@ class GoogleCloud2ProdResolverFactory : public ResolverFactory { // TODO(apolcyn): remove this class after user code has updated to the // stable "google-c2p" URI scheme. -class ExperimentalGoogleCloud2ProdResolverFactory : public ResolverFactory { +class ExperimentalGoogleCloud2ProdResolverFactory final + : public ResolverFactory { public: absl::string_view scheme() const override { return "google-c2p-experimental"; diff --git a/src/core/resolver/resolver_registry.h b/src/core/resolver/resolver_registry.h index 75d4b6f5789..4de325da7a5 100644 --- a/src/core/resolver/resolver_registry.h +++ b/src/core/resolver/resolver_registry.h @@ -35,7 +35,7 @@ namespace grpc_core { -class ResolverRegistry { +class ResolverRegistry final { private: // Forward declaration needed to use this in Builder. struct State { @@ -47,7 +47,7 @@ class ResolverRegistry { /// Methods used to create and populate the ResolverRegistry. /// NOT THREAD SAFE -- to be used only during global gRPC /// initialization and shutdown. - class Builder { + class Builder final { public: Builder(); diff --git a/src/core/resolver/sockaddr/sockaddr_resolver.cc b/src/core/resolver/sockaddr/sockaddr_resolver.cc index e95652c8b28..a980d1f1ccc 100644 --- a/src/core/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/resolver/sockaddr/sockaddr_resolver.cc @@ -42,7 +42,7 @@ namespace grpc_core { namespace { -class SockaddrResolver : public Resolver { +class SockaddrResolver final : public Resolver { public: SockaddrResolver(EndpointAddressesList addresses, ResolverArgs args); @@ -110,7 +110,7 @@ OrphanablePtr CreateSockaddrResolver( std::move(args)); } -class IPv4ResolverFactory : public ResolverFactory { +class IPv4ResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "ipv4"; } @@ -123,7 +123,7 @@ class IPv4ResolverFactory : public ResolverFactory { } }; -class IPv6ResolverFactory : public ResolverFactory { +class IPv6ResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "ipv6"; } @@ -137,7 +137,7 @@ class IPv6ResolverFactory : public ResolverFactory { }; #ifdef GRPC_HAVE_UNIX_SOCKET -class UnixResolverFactory : public ResolverFactory { +class UnixResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "unix"; } @@ -150,7 +150,7 @@ class UnixResolverFactory : public ResolverFactory { } }; -class UnixAbstractResolverFactory : public ResolverFactory { +class UnixAbstractResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "unix-abstract"; } @@ -165,7 +165,7 @@ class UnixAbstractResolverFactory : public ResolverFactory { #endif // GRPC_HAVE_UNIX_SOCKET #ifdef GRPC_HAVE_VSOCK -class VSockResolverFactory : public ResolverFactory { +class VSockResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "vsock"; } diff --git a/src/core/resolver/xds/xds_dependency_manager.cc b/src/core/resolver/xds/xds_dependency_manager.cc index 063405711d0..49a4ecb2a60 100644 --- a/src/core/resolver/xds/xds_dependency_manager.cc +++ b/src/core/resolver/xds/xds_dependency_manager.cc @@ -105,7 +105,7 @@ std::string XdsDependencyManager::XdsConfig::ToString() const { // XdsDependencyManager::ListenerWatcher // -class XdsDependencyManager::ListenerWatcher +class XdsDependencyManager::ListenerWatcher final : public XdsListenerResourceType::WatcherInterface { public: explicit ListenerWatcher(RefCountedPtr dependency_mgr) @@ -154,7 +154,7 @@ class XdsDependencyManager::ListenerWatcher // XdsDependencyManager::RouteConfigWatcher // -class XdsDependencyManager::RouteConfigWatcher +class XdsDependencyManager::RouteConfigWatcher final : public XdsRouteConfigResourceType::WatcherInterface { public: RouteConfigWatcher(RefCountedPtr dependency_mgr, @@ -206,7 +206,7 @@ class XdsDependencyManager::RouteConfigWatcher // XdsDependencyManager::ClusterWatcher // -class XdsDependencyManager::ClusterWatcher +class XdsDependencyManager::ClusterWatcher final : public XdsClusterResourceType::WatcherInterface { public: ClusterWatcher(RefCountedPtr dependency_mgr, @@ -255,7 +255,7 @@ class XdsDependencyManager::ClusterWatcher // XdsDependencyManager::EndpointWatcher // -class XdsDependencyManager::EndpointWatcher +class XdsDependencyManager::EndpointWatcher final : public XdsEndpointResourceType::WatcherInterface { public: EndpointWatcher(RefCountedPtr dependency_mgr, @@ -306,7 +306,8 @@ class XdsDependencyManager::EndpointWatcher // XdsDependencyManager::DnsResultHandler // -class XdsDependencyManager::DnsResultHandler : public Resolver::ResultHandler { +class XdsDependencyManager::DnsResultHandler final + : public Resolver::ResultHandler { public: DnsResultHandler(RefCountedPtr dependency_mgr, std::string name) @@ -468,7 +469,8 @@ void XdsDependencyManager::OnListenerUpdate( namespace { -class XdsVirtualHostListIterator : public XdsRouting::VirtualHostListIterator { +class XdsVirtualHostListIterator final + : public XdsRouting::VirtualHostListIterator { public: explicit XdsVirtualHostListIterator( const std::vector* virtual_hosts) diff --git a/src/core/resolver/xds/xds_dependency_manager.h b/src/core/resolver/xds/xds_dependency_manager.h index f80fa05ab7f..263471174cb 100644 --- a/src/core/resolver/xds/xds_dependency_manager.h +++ b/src/core/resolver/xds/xds_dependency_manager.h @@ -35,8 +35,8 @@ namespace grpc_core { // Watches all xDS resources and handles dependencies between them. // Reports updates only when all necessary resources have been obtained. -class XdsDependencyManager : public RefCounted, - public Orphanable { +class XdsDependencyManager final : public RefCounted, + public Orphanable { public: struct XdsConfig : public RefCounted { // Listener resource. Always non-null. @@ -117,7 +117,7 @@ class XdsDependencyManager : public RefCounted, virtual void OnResourceDoesNotExist(std::string context) = 0; }; - class ClusterSubscription : public DualRefCounted { + class ClusterSubscription final : public DualRefCounted { public: ClusterSubscription(absl::string_view cluster_name, RefCountedPtr dependency_mgr) diff --git a/src/core/resolver/xds/xds_resolver.cc b/src/core/resolver/xds/xds_resolver.cc index 1e1620f88ae..6fc59c59113 100644 --- a/src/core/resolver/xds/xds_resolver.cc +++ b/src/core/resolver/xds/xds_resolver.cc @@ -102,7 +102,7 @@ namespace { // XdsResolver // -class XdsResolver : public Resolver { +class XdsResolver final : public Resolver { public: XdsResolver(ResolverArgs args, std::string data_plane_authority) : work_serializer_(std::move(args.work_serializer)), @@ -135,7 +135,7 @@ class XdsResolver : public Resolver { } private: - class XdsWatcher : public XdsDependencyManager::Watcher { + class XdsWatcher final : public XdsDependencyManager::Watcher { public: explicit XdsWatcher(RefCountedPtr resolver) : resolver_(std::move(resolver)) {} @@ -163,7 +163,7 @@ class XdsResolver : public Resolver { // the cluster by the ConfigSelector. The ref for each call is held // until the call is committed. When the strong refs go away, we hop // back into the WorkSerializer to remove the entry from the map. - class ClusterRef : public DualRefCounted { + class ClusterRef final : public DualRefCounted { public: ClusterRef(RefCountedPtr resolver, RefCountedPtr @@ -196,7 +196,7 @@ class XdsResolver : public Resolver { // XdsConfigSelector. A ref to this map will be taken by each call processed // by the XdsConfigSelector, stored in a the call's call attributes, and later // unreffed by the ClusterSelection filter. - class RouteConfigData : public RefCounted { + class RouteConfigData final : public RefCounted { public: struct RouteEntry { struct ClusterWeightState { @@ -266,7 +266,7 @@ class XdsResolver : public Resolver { std::vector routes_; }; - class XdsConfigSelector : public ConfigSelector { + class XdsConfigSelector final : public ConfigSelector { public: XdsConfigSelector(RefCountedPtr resolver, RefCountedPtr route_config_data); @@ -293,7 +293,7 @@ class XdsResolver : public Resolver { std::vector filters_; }; - class XdsRouteStateAttributeImpl : public XdsRouteStateAttribute { + class XdsRouteStateAttributeImpl final : public XdsRouteStateAttribute { public: explicit XdsRouteStateAttributeImpl( RefCountedPtr route_config_data, @@ -312,7 +312,7 @@ class XdsResolver : public Resolver { RouteConfigData::RouteEntry* route_; }; - class ClusterSelectionFilter + class ClusterSelectionFilter final : public ImplementChannelFilter { public: const static grpc_channel_filter kFilter; @@ -398,7 +398,7 @@ const NoInterceptor XdsResolver::ClusterSelectionFilter::Call::OnFinalize; // Implementation of XdsRouting::RouteListIterator for getting the matching // route for a request. -class XdsResolver::RouteConfigData::RouteListIterator +class XdsResolver::RouteConfigData::RouteListIterator final : public XdsRouting::RouteListIterator { public: explicit RouteListIterator(const RouteConfigData* route_table) @@ -1097,7 +1097,7 @@ void XdsResolver::MaybeRemoveUnusedClusters() { // XdsResolverFactory // -class XdsResolverFactory : public ResolverFactory { +class XdsResolverFactory final : public ResolverFactory { public: absl::string_view scheme() const override { return "xds"; } diff --git a/src/core/resolver/xds/xds_resolver_attributes.h b/src/core/resolver/xds/xds_resolver_attributes.h index c7f585f1b38..27720d31113 100644 --- a/src/core/resolver/xds/xds_resolver_attributes.h +++ b/src/core/resolver/xds/xds_resolver_attributes.h @@ -26,7 +26,7 @@ namespace grpc_core { -class XdsClusterAttribute +class XdsClusterAttribute final : public ServiceConfigCallData::CallAttributeInterface { public: static UniqueTypeName TypeName() { diff --git a/src/core/service_config/service_config_channel_arg_filter.cc b/src/core/service_config/service_config_channel_arg_filter.cc index fda1006f97f..43069611022 100644 --- a/src/core/service_config/service_config_channel_arg_filter.cc +++ b/src/core/service_config/service_config_channel_arg_filter.cc @@ -54,7 +54,7 @@ namespace grpc_core { namespace { -class ServiceConfigChannelArgFilter +class ServiceConfigChannelArgFilter final : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; diff --git a/src/core/service_config/service_config_parser.h b/src/core/service_config/service_config_parser.h index b88255d12db..f0f91f896bc 100644 --- a/src/core/service_config/service_config_parser.h +++ b/src/core/service_config/service_config_parser.h @@ -68,7 +68,7 @@ class ServiceConfigParser { using ServiceConfigParserList = std::vector>; using ParsedConfigVector = std::vector>; - class Builder { + class Builder final { public: /// Globally register a service config parser. Each new service config /// update will go through all the registered parser. Each parser is