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_
|
#ifndef P2P_BASE_ICE_AGENT_INTERFACE_H_
|
||||||
#define 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/connection.h"
|
||||||
#include "p2p/base/ice_switch_reason.h"
|
#include "p2p/base/ice_switch_reason.h"
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ class IceAgentInterface {
|
|||||||
//
|
//
|
||||||
// SignalStateChange will not be triggered.
|
// SignalStateChange will not be triggered.
|
||||||
virtual void ForgetLearnedStateForConnections(
|
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.
|
// Send a STUN ping request for the given connection.
|
||||||
virtual void SendPingRequest(const Connection* connection) = 0;
|
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
|
// Prune away the given connections. Returns true if pruning is permitted and
|
||||||
// successfully performed.
|
// successfully performed.
|
||||||
virtual bool PruneConnections(std::vector<const Connection*> connections) = 0;
|
virtual bool PruneConnections(
|
||||||
|
rtc::ArrayView<const Connection* const> connections) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cricket
|
} // namespace cricket
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class MockIceAgent : public IceAgentInterface {
|
|||||||
MOCK_METHOD(void, UpdateState, (), (override));
|
MOCK_METHOD(void, UpdateState, (), (override));
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
ForgetLearnedStateForConnections,
|
ForgetLearnedStateForConnections,
|
||||||
(std::vector<const Connection*>),
|
(rtc::ArrayView<const Connection* const>),
|
||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(void, SendPingRequest, (const Connection*), (override));
|
MOCK_METHOD(void, SendPingRequest, (const Connection*), (override));
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
@ -41,7 +41,7 @@ class MockIceAgent : public IceAgentInterface {
|
|||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(bool,
|
MOCK_METHOD(bool,
|
||||||
PruneConnections,
|
PruneConnections,
|
||||||
(std::vector<const Connection*>),
|
(rtc::ArrayView<const Connection* const>),
|
||||||
(override));
|
(override));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -339,7 +339,7 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void P2PTransportChannel::ForgetLearnedStateForConnections(
|
void P2PTransportChannel::ForgetLearnedStateForConnections(
|
||||||
std::vector<const Connection*> connections) {
|
rtc::ArrayView<const Connection* const> connections) {
|
||||||
for (const Connection* con : connections) {
|
for (const Connection* con : connections) {
|
||||||
FromIceController(con)->ForgetLearnedState();
|
FromIceController(con)->ForgetLearnedState();
|
||||||
}
|
}
|
||||||
@ -1885,7 +1885,7 @@ void P2PTransportChannel::PruneConnections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool P2PTransportChannel::PruneConnections(
|
bool P2PTransportChannel::PruneConnections(
|
||||||
std::vector<const Connection*> connections) {
|
rtc::ArrayView<const Connection* const> connections) {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (!AllowedToPruneConnections()) {
|
if (!AllowedToPruneConnections()) {
|
||||||
RTC_LOG(LS_WARNING) << "Not allowed to prune connections";
|
RTC_LOG(LS_WARNING) << "Not allowed to prune connections";
|
||||||
|
|||||||
@ -180,8 +180,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal,
|
|||||||
void SwitchSelectedConnection(const Connection* connection,
|
void SwitchSelectedConnection(const Connection* connection,
|
||||||
IceSwitchReason reason) override;
|
IceSwitchReason reason) override;
|
||||||
void ForgetLearnedStateForConnections(
|
void ForgetLearnedStateForConnections(
|
||||||
std::vector<const Connection*> connections) override;
|
rtc::ArrayView<const Connection* const> connections) override;
|
||||||
bool PruneConnections(std::vector<const Connection*> connections) override;
|
bool PruneConnections(
|
||||||
|
rtc::ArrayView<const Connection* const> connections) override;
|
||||||
|
|
||||||
// TODO(honghaiz): Remove this method once the reference of it in
|
// TODO(honghaiz): Remove this method once the reference of it in
|
||||||
// Chromoting is removed.
|
// Chromoting is removed.
|
||||||
|
|||||||
@ -37,6 +37,8 @@ using ::cricket::NominationMode;
|
|||||||
using ::cricket::WrappingActiveIceController;
|
using ::cricket::WrappingActiveIceController;
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
|
using ::testing::ElementsAreArray;
|
||||||
|
using ::testing::IsEmpty;
|
||||||
using ::testing::NiceMock;
|
using ::testing::NiceMock;
|
||||||
using ::testing::Ref;
|
using ::testing::Ref;
|
||||||
using ::testing::Return;
|
using ::testing::Return;
|
||||||
@ -132,7 +134,8 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSwitchRequest) {
|
|||||||
.WillOnce(Return(switch_result));
|
.WillOnce(Return(switch_result));
|
||||||
EXPECT_CALL(agent, SwitchSelectedConnection(kConnection, reason))
|
EXPECT_CALL(agent, SwitchSelectedConnection(kConnection, reason))
|
||||||
.InSequence(check_then_switch);
|
.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));
|
EXPECT_TRUE(controller.OnImmediateSwitchRequest(reason, kConnection));
|
||||||
|
|
||||||
@ -146,7 +149,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSwitchRequest) {
|
|||||||
SortAndSwitchConnection(IceSwitchReason::ICE_CONTROLLER_RECHECK))
|
SortAndSwitchConnection(IceSwitchReason::ICE_CONTROLLER_RECHECK))
|
||||||
.InSequence(recheck_sort)
|
.InSequence(recheck_sort)
|
||||||
.WillOnce(Return(IceControllerInterface::SwitchResult{}));
|
.WillOnce(Return(IceControllerInterface::SwitchResult{}));
|
||||||
EXPECT_CALL(agent, ForgetLearnedStateForConnections(kEmptyConnsList));
|
EXPECT_CALL(agent, ForgetLearnedStateForConnections(IsEmpty()));
|
||||||
|
|
||||||
clock.AdvanceTime(kTick);
|
clock.AdvanceTime(kTick);
|
||||||
}
|
}
|
||||||
@ -180,7 +183,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSortAndSwitchRequest) {
|
|||||||
EXPECT_CALL(*wrapped, PruneConnections())
|
EXPECT_CALL(*wrapped, PruneConnections())
|
||||||
.InSequence(sort_and_switch)
|
.InSequence(sort_and_switch)
|
||||||
.WillOnce(Return(conns_to_prune));
|
.WillOnce(Return(conns_to_prune));
|
||||||
EXPECT_CALL(agent, PruneConnections(conns_to_prune))
|
EXPECT_CALL(agent, PruneConnections(ElementsAreArray(conns_to_prune)))
|
||||||
.InSequence(sort_and_switch);
|
.InSequence(sort_and_switch);
|
||||||
|
|
||||||
controller.OnImmediateSortAndSwitchRequest(reason);
|
controller.OnImmediateSortAndSwitchRequest(reason);
|
||||||
@ -198,8 +201,7 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSortAndSwitchRequest) {
|
|||||||
EXPECT_CALL(*wrapped, PruneConnections())
|
EXPECT_CALL(*wrapped, PruneConnections())
|
||||||
.InSequence(recheck_sort)
|
.InSequence(recheck_sort)
|
||||||
.WillOnce(Return(kEmptyConnsList));
|
.WillOnce(Return(kEmptyConnsList));
|
||||||
EXPECT_CALL(agent, PruneConnections(kEmptyConnsList))
|
EXPECT_CALL(agent, PruneConnections(IsEmpty())).InSequence(recheck_sort);
|
||||||
.InSequence(recheck_sort);
|
|
||||||
|
|
||||||
clock.AdvanceTime(kTick);
|
clock.AdvanceTime(kTick);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user