diff --git a/api/test/network_emulation/network_emulation_interfaces.h b/api/test/network_emulation/network_emulation_interfaces.h index ebb1eedc78..db1f9ada67 100644 --- a/api/test/network_emulation/network_emulation_interfaces.h +++ b/api/test/network_emulation/network_emulation_interfaces.h @@ -187,8 +187,6 @@ class EmulatedEndpoint : public EmulatedNetworkReceiverInterface { virtual void UnbindReceiver(uint16_t port) = 0; virtual rtc::IPAddress GetPeerLocalAddress() const = 0; - virtual std::unique_ptr stats() const = 0; - private: // Ensure that there can be no other subclass than EmulatedEndpointImpl. This // means that it's always safe to downcast EmulatedEndpoint instances to diff --git a/test/network/network_emulation.h b/test/network/network_emulation.h index 5531efd041..c60f85d0b9 100644 --- a/test/network/network_emulation.h +++ b/test/network/network_emulation.h @@ -447,7 +447,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { const rtc::Network& network() const { return *network_.get(); } - std::unique_ptr stats() const override; + std::unique_ptr stats() const; private: static constexpr uint16_t kFirstEphemeralPort = 49152; diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc index b5ba4545ba..1e8e5ef9ff 100644 --- a/test/network/network_emulation_manager.cc +++ b/test/network/network_emulation_manager.cc @@ -301,7 +301,11 @@ void NetworkEmulationManagerImpl::GetStats( task_queue_.PostTask([endpoints, stats_callback]() { EmulatedNetworkStatsBuilder stats_builder; for (auto* endpoint : endpoints) { - stats_builder.AddEmulatedNetworkStats(*endpoint->stats()); + // It's safe to cast here because EmulatedEndpointImpl can be the only + // implementation of EmulatedEndpoint, because only it has access to + // EmulatedEndpoint constructor. + auto endpoint_impl = static_cast(endpoint); + stats_builder.AddEmulatedNetworkStats(*endpoint_impl->stats()); } stats_callback(stats_builder.Build()); });