diff --git a/api/test/network_emulation/network_emulation_interfaces.h b/api/test/network_emulation/network_emulation_interfaces.h index db1f9ada67..7c1a61f2f6 100644 --- a/api/test/network_emulation/network_emulation_interfaces.h +++ b/api/test/network_emulation/network_emulation_interfaces.h @@ -159,7 +159,8 @@ class EmulatedNetworkStats { }; // EmulatedEndpoint is an abstraction for network interface on device. Instances -// of this are created by NetworkEmulationManager::CreateEndpoint. +// of this are created by NetworkEmulationManager::CreateEndpoint and +// thread safe. class EmulatedEndpoint : public EmulatedNetworkReceiverInterface { public: // Send packet into network. diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index 90441e4f27..d2e6417a9d 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -79,7 +79,8 @@ class EmulatedNetworkManagerInterface { virtual std::vector endpoints() const = 0; // Passes summarized network stats for endpoints for this manager into - // specified |stats_callback|. + // specified |stats_callback|. Callback will be executed on network emulation + // internal task queue. virtual void GetStats( std::function)> stats_callback) const = 0; @@ -194,8 +195,9 @@ class NetworkEmulationManager { CreateEmulatedNetworkManagerInterface( const std::vector& endpoints) = 0; - // Passes summarized network stats for specified |endpoints| into specifield - // |stats_callback|. + // Passes summarized network stats for specified |endpoints| into specified + // |stats_callback|. Callback will be executed on network emulation + // internal task queue. virtual void GetStats( rtc::ArrayView endpoints, std::function)> diff --git a/test/network/emulated_network_manager.h b/test/network/emulated_network_manager.h index 98927d7911..2321af0e04 100644 --- a/test/network/emulated_network_manager.h +++ b/test/network/emulated_network_manager.h @@ -51,7 +51,7 @@ class EmulatedNetworkManager : public rtc::NetworkManagerBase, rtc::Thread* network_thread() override { return network_thread_.get(); } rtc::NetworkManager* network_manager() override { return this; } std::vector endpoints() const override { - return endpoints_container_->endpoints(); + return endpoints_container_->GetEndpoints(); } void GetStats(std::function)> stats_callback) const override; @@ -61,7 +61,7 @@ class EmulatedNetworkManager : public rtc::NetworkManagerBase, void MaybeSignalNetworksChanged(); TaskQueueForTest* const task_queue_; - EndpointsContainer* const endpoints_container_; + const EndpointsContainer* const endpoints_container_; std::unique_ptr network_thread_; bool sent_first_update_ RTC_GUARDED_BY(network_thread_); diff --git a/test/network/network_emulation.cc b/test/network/network_emulation.cc index 8de4cba78b..13d3d87349 100644 --- a/test/network/network_emulation.cc +++ b/test/network/network_emulation.cc @@ -571,7 +571,7 @@ EndpointsContainer::GetEnabledNetworks() const { return networks; } -std::vector EndpointsContainer::endpoints() const { +std::vector EndpointsContainer::GetEndpoints() const { return std::vector(endpoints_.begin(), endpoints_.end()); } diff --git a/test/network/network_emulation.h b/test/network/network_emulation.h index c60f85d0b9..d29253320d 100644 --- a/test/network/network_emulation.h +++ b/test/network/network_emulation.h @@ -486,6 +486,7 @@ class EmulatedRoute { bool active; }; +// This object is immutable and so thread safe. class EndpointsContainer { public: explicit EndpointsContainer( @@ -497,7 +498,7 @@ class EndpointsContainer { // Returns list of networks for enabled endpoints. Caller takes ownership of // returned rtc::Network objects. std::vector> GetEnabledNetworks() const; - std::vector endpoints() const; + std::vector GetEndpoints() const; std::unique_ptr GetStats() const; private: