Accept ArrayView in ICE agent interface where feasible.
Ownership does not need to cross the interface boundary, so ArrayView can be safely accepted in ForgetStateForConnections and PruneConnections. Bug: webrtc:14131 Change-Id: I18a739aea1dc47976d17925e9bca3461225bf803 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278629 Commit-Queue: Sameer Vijaykar <samvi@google.com> Reviewed-by: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38418}
This commit is contained in:
parent
8b715657fb
commit
f0e65bab0e
@ -11,8 +11,7 @@
|
||||
#ifndef P2P_BASE_ICE_AGENT_INTERFACE_H_
|
||||
#define P2P_BASE_ICE_AGENT_INTERFACE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "p2p/base/connection.h"
|
||||
#include "p2p/base/ice_switch_reason.h"
|
||||
|
||||
@ -61,7 +60,7 @@ class IceAgentInterface {
|
||||
//
|
||||
// SignalStateChange will not be triggered.
|
||||
virtual void ForgetLearnedStateForConnections(
|
||||
std::vector<const Connection*> connections) = 0;
|
||||
rtc::ArrayView<const Connection* const> connections) = 0;
|
||||
|
||||
// Send a STUN ping request for the given connection.
|
||||
virtual void SendPingRequest(const Connection* connection) = 0;
|
||||
@ -72,7 +71,8 @@ class IceAgentInterface {
|
||||
|
||||
// Prune away the given connections. Returns true if pruning is permitted and
|
||||
// successfully performed.
|
||||
virtual bool PruneConnections(std::vector<const Connection*> connections) = 0;
|
||||
virtual bool PruneConnections(
|
||||
rtc::ArrayView<const Connection* const> connections) = 0;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -32,7 +32,7 @@ class MockIceAgent : public IceAgentInterface {
|
||||
MOCK_METHOD(void, UpdateState, (), (override));
|
||||
MOCK_METHOD(void,
|
||||
ForgetLearnedStateForConnections,
|
||||
(std::vector<const Connection*>),
|
||||
(rtc::ArrayView<const Connection* const>),
|
||||
(override));
|
||||
MOCK_METHOD(void, SendPingRequest, (const Connection*), (override));
|
||||
MOCK_METHOD(void,
|
||||
@ -41,7 +41,7 @@ class MockIceAgent : public IceAgentInterface {
|
||||
(override));
|
||||
MOCK_METHOD(bool,
|
||||
PruneConnections,
|
||||
(std::vector<const Connection*>),
|
||||
(rtc::ArrayView<const Connection* const>),
|
||||
(override));
|
||||
};
|
||||
|
||||
|
||||
@ -339,7 +339,7 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection(
|
||||
}
|
||||
|
||||
void P2PTransportChannel::ForgetLearnedStateForConnections(
|
||||
std::vector<const Connection*> connections) {
|
||||
rtc::ArrayView<const Connection* const> connections) {
|
||||
for (const Connection* con : connections) {
|
||||
FromIceController(con)->ForgetLearnedState();
|
||||
}
|
||||
@ -1885,7 +1885,7 @@ void P2PTransportChannel::PruneConnections() {
|
||||
}
|
||||
|
||||
bool P2PTransportChannel::PruneConnections(
|
||||
std::vector<const Connection*> connections) {
|
||||
rtc::ArrayView<const Connection* const> connections) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
if (!AllowedToPruneConnections()) {
|
||||
RTC_LOG(LS_WARNING) << "Not allowed to prune connections";
|
||||
|
||||
@ -180,8 +180,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal,
|
||||
void SwitchSelectedConnection(const Connection* connection,
|
||||
IceSwitchReason reason) override;
|
||||
void ForgetLearnedStateForConnections(
|
||||
std::vector<const Connection*> connections) override;
|
||||
bool PruneConnections(std::vector<const Connection*> connections) override;
|
||||
rtc::ArrayView<const Connection* const> connections) override;
|
||||
bool PruneConnections(
|
||||
rtc::ArrayView<const Connection* const> connections) override;
|
||||
|
||||
// TODO(honghaiz): Remove this method once the reference of it in
|
||||
// Chromoting is removed.
|
||||
|
||||
@ -37,6 +37,8 @@ using ::cricket::NominationMode;
|
||||
using ::cricket::WrappingActiveIceController;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::ElementsAreArray;
|
||||
using ::testing::IsEmpty;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Ref;
|
||||
using ::testing::Return;
|
||||
@ -132,7 +134,8 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSwitchRequest) {
|
||||
.WillOnce(Return(switch_result));
|
||||
EXPECT_CALL(agent, SwitchSelectedConnection(kConnection, reason))
|
||||
.InSequence(check_then_switch);
|
||||
EXPECT_CALL(agent, ForgetLearnedStateForConnections(conns_to_forget));
|
||||
EXPECT_CALL(agent, ForgetLearnedStateForConnections(
|
||||
ElementsAreArray(conns_to_forget)));
|
||||
|
||||
EXPECT_TRUE(controller.OnImmediateSwitchRequest(reason, kConnection));
|
||||
|
||||
@ -146,7 +149,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSwitchRequest) {
|
||||
SortAndSwitchConnection(IceSwitchReason::ICE_CONTROLLER_RECHECK))
|
||||
.InSequence(recheck_sort)
|
||||
.WillOnce(Return(IceControllerInterface::SwitchResult{}));
|
||||
EXPECT_CALL(agent, ForgetLearnedStateForConnections(kEmptyConnsList));
|
||||
EXPECT_CALL(agent, ForgetLearnedStateForConnections(IsEmpty()));
|
||||
|
||||
clock.AdvanceTime(kTick);
|
||||
}
|
||||
@ -180,7 +183,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSortAndSwitchRequest) {
|
||||
EXPECT_CALL(*wrapped, PruneConnections())
|
||||
.InSequence(sort_and_switch)
|
||||
.WillOnce(Return(conns_to_prune));
|
||||
EXPECT_CALL(agent, PruneConnections(conns_to_prune))
|
||||
EXPECT_CALL(agent, PruneConnections(ElementsAreArray(conns_to_prune)))
|
||||
.InSequence(sort_and_switch);
|
||||
|
||||
controller.OnImmediateSortAndSwitchRequest(reason);
|
||||
@ -198,8 +201,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSortAndSwitchRequest) {
|
||||
EXPECT_CALL(*wrapped, PruneConnections())
|
||||
.InSequence(recheck_sort)
|
||||
.WillOnce(Return(kEmptyConnsList));
|
||||
EXPECT_CALL(agent, PruneConnections(kEmptyConnsList))
|
||||
.InSequence(recheck_sort);
|
||||
EXPECT_CALL(agent, PruneConnections(IsEmpty())).InSequence(recheck_sort);
|
||||
|
||||
clock.AdvanceTime(kTick);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user