Add IceControllerInterface::GetConnections() and fix return type.
This is a replacement for `connections()`, which is const-qualified but returns a `rtc::ArrayView<const cricket::Connection*>`. Unfortunately, this is a view of mutable pointers to `const cricket::Connection` objects: this means that the pointers in `IceControllerInterface`'s backing store can be reassigned. Returning `rtc::ArrayView<const cricket::Connection* const>` is more consistent with how a view returned from a const-qualified method should behave. Unfortunately, there are downstream overrides of this method, so instead of just fixing this outright, add a new method with the correct return type. Once downstream is updated, the old method can then be removed. Bug: chromium:1409870, webrtc:15702 Change-Id: I3d8f0c2f0bcf4c393ee63959cb61761ac00a28ab Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329962 Reviewed-by: Jonas Oreland <jonaso@google.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#41318}
This commit is contained in:
parent
61c5e86dca
commit
e125a3371f
@ -32,6 +32,9 @@ class BasicIceController : public IceControllerInterface {
|
||||
void SetSelectedConnection(const Connection* selected_connection) override;
|
||||
void AddConnection(const Connection* connection) override;
|
||||
void OnConnectionDestroyed(const Connection* connection) override;
|
||||
rtc::ArrayView<const Connection* const> GetConnections() const override {
|
||||
return connections_;
|
||||
}
|
||||
rtc::ArrayView<const Connection*> connections() const override {
|
||||
return rtc::ArrayView<const Connection*>(
|
||||
const_cast<const Connection**>(connections_.data()),
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "p2p/base/connection.h"
|
||||
#include "p2p/base/ice_switch_reason.h"
|
||||
#include "p2p/base/ice_transport_internal.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace cricket {
|
||||
@ -53,7 +54,7 @@ struct RTC_EXPORT IceRecheckEvent {
|
||||
// Connection::ForgetLearnedState - return in SwitchResult
|
||||
//
|
||||
// The IceController shall keep track of all connections added
|
||||
// (and not destroyed) and give them back using the connections()-function-
|
||||
// (and not destroyed) and give them back using the GetConnections() function.
|
||||
//
|
||||
// When a Connection gets destroyed
|
||||
// - signals on Connection::SignalDestroyed
|
||||
@ -101,7 +102,17 @@ class IceControllerInterface {
|
||||
virtual void OnConnectionDestroyed(const Connection* connection) = 0;
|
||||
|
||||
// These are all connections that has been added and not destroyed.
|
||||
virtual rtc::ArrayView<const Connection*> connections() const = 0;
|
||||
virtual rtc::ArrayView<const Connection* const> GetConnections() const {
|
||||
// Stub implementation to simplify downstream roll.
|
||||
RTC_CHECK_NOTREACHED();
|
||||
return {};
|
||||
}
|
||||
// TODO(bugs.webrtc.org/15702): Remove this after downstream is cleaned up.
|
||||
virtual rtc::ArrayView<const Connection*> connections() const {
|
||||
// Stub implementation to simplify downstream removal.
|
||||
RTC_CHECK_NOTREACHED();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Is there a pingable connection ?
|
||||
// This function is used to boot-strap pinging, after this returns true
|
||||
|
||||
@ -35,6 +35,10 @@ class MockIceController : public cricket::IceControllerInterface {
|
||||
OnConnectionDestroyed,
|
||||
(const cricket::Connection*),
|
||||
(override));
|
||||
MOCK_METHOD(rtc::ArrayView<const cricket::Connection* const>,
|
||||
GetConnections,
|
||||
(),
|
||||
(const, override));
|
||||
MOCK_METHOD(rtc::ArrayView<const cricket::Connection*>,
|
||||
connections,
|
||||
(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user