From c925f50c1caf392fa11128dbc89a5b1104e45954 Mon Sep 17 00:00:00 2001 From: Manashi Sarkar Date: Mon, 4 Dec 2023 12:10:15 +0000 Subject: [PATCH] Revert "Correctly const-qualify return value of IceControllerInterface::connections()." This reverts commit ad631f0d353011b8d4282577310abb48bf60ff67. Reason for revert: error: virtual function 'connections' has a different return type ('ArrayView') than the function it overrides (which has return type 'ArrayView') Original change's description: > Correctly const-qualify return value of IceControllerInterface::connections(). > > This is intended to be a read-only view across a container of const > Connection*, but due to the missing const, elements of the container > could actually be re-assigned through the ArrayView. > > This was discovered when trying to roll Googletest, since Googletest was > fixed to const-qualify converting actions: > https://github.com/google/googletest/commit/cbca6bc3957b28b8062f20b65f9349d94a4bf0b3 > > Bug: chromium:1409870 > Change-Id: Iadd3abe6807111987e422b8510a23f2a4f7026ed > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329481 > Auto-Submit: Daniel Cheng > Reviewed-by: Harald Alvestrand > Commit-Queue: Harald Alvestrand > Commit-Queue: Daniel Cheng > Cr-Commit-Position: refs/heads/main@{#41300} Bug: chromium:1409870 Change-Id: Id0026eb7727a3d1408045d0040b3b080cca07832 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329762 Reviewed-by: Harald Alvestrand Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Manashi Sarkar Cr-Commit-Position: refs/heads/main@{#41307} --- p2p/base/basic_ice_controller.h | 6 ++++-- p2p/base/ice_controller_interface.h | 2 +- p2p/base/mock_ice_controller.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index ba14d80474..b941a0dd7e 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -32,8 +32,10 @@ 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 connections() const override { - return connections_; + rtc::ArrayView connections() const override { + return rtc::ArrayView( + const_cast(connections_.data()), + connections_.size()); } bool HasPingableConnection() const override; diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index adedf4c604..8b63ed3fc3 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -101,7 +101,7 @@ class IceControllerInterface { virtual void OnConnectionDestroyed(const Connection* connection) = 0; // These are all connections that has been added and not destroyed. - virtual rtc::ArrayView connections() const = 0; + virtual rtc::ArrayView connections() const = 0; // Is there a pingable connection ? // This function is used to boot-strap pinging, after this returns true diff --git a/p2p/base/mock_ice_controller.h b/p2p/base/mock_ice_controller.h index 02468402ac..bde9254e7d 100644 --- a/p2p/base/mock_ice_controller.h +++ b/p2p/base/mock_ice_controller.h @@ -35,7 +35,7 @@ class MockIceController : public cricket::IceControllerInterface { OnConnectionDestroyed, (const cricket::Connection*), (override)); - MOCK_METHOD(rtc::ArrayView, + MOCK_METHOD(rtc::ArrayView, connections, (), (const, override));