Bug: webrtc:11756
Change-Id: I2f65713181598a5af831bb6ce71c32cf7c0f4b90
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180882
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32056}
This commit is contained in:
Artem Titov 2020-08-04 11:49:19 +02:00 committed by Commit Bot
parent 869e9fb4f3
commit 5501cef0a7
5 changed files with 12 additions and 8 deletions

View File

@ -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.

View File

@ -79,7 +79,8 @@ class EmulatedNetworkManagerInterface {
virtual std::vector<EmulatedEndpoint*> 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<void(std::unique_ptr<EmulatedNetworkStats>)> stats_callback)
const = 0;
@ -194,8 +195,9 @@ class NetworkEmulationManager {
CreateEmulatedNetworkManagerInterface(
const std::vector<EmulatedEndpoint*>& 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<EmulatedEndpoint*> endpoints,
std::function<void(std::unique_ptr<EmulatedNetworkStats>)>

View File

@ -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<EmulatedEndpoint*> endpoints() const override {
return endpoints_container_->endpoints();
return endpoints_container_->GetEndpoints();
}
void GetStats(std::function<void(std::unique_ptr<EmulatedNetworkStats>)>
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<rtc::Thread> network_thread_;
bool sent_first_update_ RTC_GUARDED_BY(network_thread_);

View File

@ -571,7 +571,7 @@ EndpointsContainer::GetEnabledNetworks() const {
return networks;
}
std::vector<EmulatedEndpoint*> EndpointsContainer::endpoints() const {
std::vector<EmulatedEndpoint*> EndpointsContainer::GetEndpoints() const {
return std::vector<EmulatedEndpoint*>(endpoints_.begin(), endpoints_.end());
}

View File

@ -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<std::unique_ptr<rtc::Network>> GetEnabledNetworks() const;
std::vector<EmulatedEndpoint*> endpoints() const;
std::vector<EmulatedEndpoint*> GetEndpoints() const;
std::unique_ptr<EmulatedNetworkStats> GetStats() const;
private: