Skip to content

Commit

Permalink
Remove stat API from EmulatedEndpoint.
Browse files Browse the repository at this point in the history
stats() method on EmulatedEndpoint has to be called from network
emulation internal task queue and user has no access to that task queue,
so user can't call this method. Because of that remove it from public
API and keep it only on implementation.

Bug: webrtc:11756
Change-Id: I2fb7256abe94d6900965512f90c6a53a0708a7b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180880
Reviewed-by: Tommi <[email protected]>
Commit-Queue: Artem Titov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#31867}
  • Loading branch information
titov-artem authored and Commit Bot committed Aug 6, 2020
1 parent 2b068ce commit 9dcab80
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions api/test/network_emulation/network_emulation_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmulatedNetworkStats> 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
Expand Down
2 changes: 1 addition & 1 deletion test/network/network_emulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint {

const rtc::Network& network() const { return *network_.get(); }

std::unique_ptr<EmulatedNetworkStats> stats() const override;
std::unique_ptr<EmulatedNetworkStats> stats() const;

private:
static constexpr uint16_t kFirstEphemeralPort = 49152;
Expand Down
6 changes: 5 additions & 1 deletion test/network/network_emulation_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmulatedEndpointImpl*>(endpoint);
stats_builder.AddEmulatedNetworkStats(*endpoint_impl->stats());
}
stats_callback(stats_builder.Build());
});
Expand Down

0 comments on commit 9dcab80

Please sign in to comment.