Move weak_ptr.h to webrtc namespace
Bug: webrtc:42232595
Change-Id: I4bf95fcabcf4fbe4ff68772b68a1df2466f7b8d5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/378822
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43980}
diff --git a/modules/video_coding/utility/bandwidth_quality_scaler.h b/modules/video_coding/utility/bandwidth_quality_scaler.h
index 9454945..2543dd2 100644
--- a/modules/video_coding/utility/bandwidth_quality_scaler.h
+++ b/modules/video_coding/utility/bandwidth_quality_scaler.h
@@ -86,7 +86,7 @@
std::optional<int64_t> last_time_sent_in_ms_ RTC_GUARDED_BY(&task_checker_);
RateStatistics encoded_bitrate_ RTC_GUARDED_BY(&task_checker_);
std::optional<int> last_frame_size_pixels_ RTC_GUARDED_BY(&task_checker_);
- rtc::WeakPtrFactory<BandwidthQualityScaler> weak_ptr_factory_;
+ WeakPtrFactory<BandwidthQualityScaler> weak_ptr_factory_;
std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits_;
};
diff --git a/modules/video_coding/utility/quality_scaler.cc b/modules/video_coding/utility/quality_scaler.cc
index e8a8f90..a71b928 100644
--- a/modules/video_coding/utility/quality_scaler.cc
+++ b/modules/video_coding/utility/quality_scaler.cc
@@ -172,7 +172,7 @@
const Result previous_task_result_;
Result result_;
- rtc::WeakPtrFactory<CheckQpTask> weak_ptr_factory_;
+ WeakPtrFactory<CheckQpTask> weak_ptr_factory_;
};
QualityScaler::QualityScaler(QualityScalerQpUsageHandlerInterface* handler,
diff --git a/pc/data_channel_controller.h b/pc/data_channel_controller.h
index 916eb990..8dc9516 100644
--- a/pc/data_channel_controller.h
+++ b/pc/data_channel_controller.h
@@ -160,7 +160,7 @@
PeerConnectionInternal* const pc_;
// The weak pointers must be dereferenced and invalidated on the network
// thread only.
- rtc::WeakPtrFactory<DataChannelController> weak_factory_
+ WeakPtrFactory<DataChannelController> weak_factory_
RTC_GUARDED_BY(network_thread()){this};
ScopedTaskSafety signaling_safety_;
};
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
index 49732f0..61b10ba 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -721,7 +721,7 @@
PayloadTypePicker payload_type_picker_;
// This variable needs to be the last one in the class.
- rtc::WeakPtrFactory<PeerConnection> weak_factory_;
+ WeakPtrFactory<PeerConnection> weak_factory_;
bool CanAttemptDtlsStunPiggybacking(const RTCConfiguration& configuration);
};
diff --git a/pc/rtp_transmission_manager.h b/pc/rtp_transmission_manager.h
index 1b63ef3..4b87db4 100644
--- a/pc/rtp_transmission_manager.h
+++ b/pc/rtp_transmission_manager.h
@@ -272,7 +272,7 @@
PeerConnectionObserver* observer_;
LegacyStatsCollectorInterface* const legacy_stats_;
std::function<void()> on_negotiation_needed_;
- rtc::WeakPtrFactory<RtpTransmissionManager> weak_ptr_factory_
+ WeakPtrFactory<RtpTransmissionManager> weak_ptr_factory_
RTC_GUARDED_BY(signaling_thread());
};
diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc
index 278f730..98570c0 100644
--- a/pc/sctp_data_channel.cc
+++ b/pc/sctp_data_channel.cc
@@ -285,7 +285,7 @@
// static
rtc::scoped_refptr<SctpDataChannel> SctpDataChannel::Create(
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
+ WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
const InternalDataChannelInit& config,
@@ -312,7 +312,7 @@
SctpDataChannel::SctpDataChannel(
const InternalDataChannelInit& config,
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
+ WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
rtc::Thread* signaling_thread,
diff --git a/pc/sctp_data_channel.h b/pc/sctp_data_channel.h
index 108f640..0a71d3e 100644
--- a/pc/sctp_data_channel.h
+++ b/pc/sctp_data_channel.h
@@ -130,7 +130,7 @@
class SctpDataChannel : public DataChannelInterface {
public:
static rtc::scoped_refptr<SctpDataChannel> Create(
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
+ WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
const InternalDataChannelInit& config,
@@ -232,7 +232,7 @@
protected:
SctpDataChannel(const InternalDataChannelInit& config,
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
+ WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
rtc::Thread* signaling_thread,
@@ -290,7 +290,7 @@
uint64_t bytes_sent_ RTC_GUARDED_BY(network_thread_) = 0;
uint32_t messages_received_ RTC_GUARDED_BY(network_thread_) = 0;
uint64_t bytes_received_ RTC_GUARDED_BY(network_thread_) = 0;
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller_
+ WeakPtr<SctpDataChannelControllerInterface> controller_
RTC_GUARDED_BY(network_thread_);
HandshakeState handshake_state_ RTC_GUARDED_BY(network_thread_) =
kHandshakeInit;
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 34ae4e0..6206b25 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -1188,7 +1188,7 @@
: public CreateSessionDescriptionObserver {
public:
ImplicitCreateSessionDescriptionObserver(
- rtc::WeakPtr<SdpOfferAnswerHandler> sdp_handler,
+ WeakPtr<SdpOfferAnswerHandler> sdp_handler,
rtc::scoped_refptr<SetLocalDescriptionObserverInterface>
set_local_description_observer)
: sdp_handler_(std::move(sdp_handler)),
@@ -1234,7 +1234,7 @@
private:
bool was_called_ = false;
- rtc::WeakPtr<SdpOfferAnswerHandler> sdp_handler_;
+ WeakPtr<SdpOfferAnswerHandler> sdp_handler_;
rtc::scoped_refptr<SetLocalDescriptionObserverInterface>
set_local_description_observer_;
std::function<void()> operation_complete_callback_;
@@ -1325,7 +1325,7 @@
public SetRemoteDescriptionObserverInterface {
public:
SetSessionDescriptionObserverAdapter(
- rtc::WeakPtr<SdpOfferAnswerHandler> handler,
+ WeakPtr<SdpOfferAnswerHandler> handler,
rtc::scoped_refptr<SetSessionDescriptionObserver> inner_observer)
: handler_(std::move(handler)),
inner_observer_(std::move(inner_observer)) {}
@@ -1352,7 +1352,7 @@
}
}
- rtc::WeakPtr<SdpOfferAnswerHandler> handler_;
+ WeakPtr<SdpOfferAnswerHandler> handler_;
rtc::scoped_refptr<SetSessionDescriptionObserver> inner_observer_;
};
diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h
index 0c91443..ea5078e 100644
--- a/pc/sdp_offer_answer.h
+++ b/pc/sdp_offer_answer.h
@@ -690,7 +690,7 @@
// determines the SSL role.
std::optional<bool> initial_offerer_ RTC_GUARDED_BY(signaling_thread());
- rtc::WeakPtrFactory<SdpOfferAnswerHandler> weak_ptr_factory_
+ WeakPtrFactory<SdpOfferAnswerHandler> weak_ptr_factory_
RTC_GUARDED_BY(signaling_thread());
};
diff --git a/pc/test/fake_data_channel_controller.h b/pc/test/fake_data_channel_controller.h
index 6ef8a57..ca1f365 100644
--- a/pc/test/fake_data_channel_controller.h
+++ b/pc/test/fake_data_channel_controller.h
@@ -38,7 +38,7 @@
});
}
- rtc::WeakPtr<FakeDataChannelController> weak_ptr() {
+ webrtc::WeakPtr<FakeDataChannelController> weak_ptr() {
RTC_DCHECK_RUN_ON(network_thread_);
return weak_factory_.GetWeakPtr();
}
@@ -49,7 +49,7 @@
rtc::scoped_refptr<webrtc::SctpDataChannel> channel =
network_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(network_thread_);
- rtc::WeakPtr<FakeDataChannelController> my_weak_ptr = weak_ptr();
+ webrtc::WeakPtr<FakeDataChannelController> my_weak_ptr = weak_ptr();
// Explicitly associate the weak ptr instance with the current thread
// to catch early any inappropriate referencing of it on the network
// thread.
@@ -239,7 +239,7 @@
std::set<webrtc::SctpDataChannel*> connected_channels_
RTC_GUARDED_BY(network_thread_);
std::set<webrtc::StreamId> known_stream_ids_ RTC_GUARDED_BY(network_thread_);
- rtc::WeakPtrFactory<FakeDataChannelController> weak_factory_
+ webrtc::WeakPtrFactory<FakeDataChannelController> weak_factory_
RTC_GUARDED_BY(network_thread_){this};
};
#endif // PC_TEST_FAKE_DATA_CHANNEL_CONTROLLER_H_
diff --git a/pc/test/mock_data_channel.h b/pc/test/mock_data_channel.h
index ef781fe..a32bed6 100644
--- a/pc/test/mock_data_channel.h
+++ b/pc/test/mock_data_channel.h
@@ -21,10 +21,9 @@
class MockSctpDataChannel : public SctpDataChannel {
public:
- MockSctpDataChannel(
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
- int id,
- DataState state)
+ MockSctpDataChannel(WeakPtr<SctpDataChannelControllerInterface> controller,
+ int id,
+ DataState state)
: MockSctpDataChannel(std::move(controller),
id,
"MockSctpDataChannel",
@@ -35,7 +34,7 @@
0,
0) {}
MockSctpDataChannel(
- rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
+ WeakPtr<SctpDataChannelControllerInterface> controller,
int id,
const std::string& label,
DataState state,
diff --git a/pc/webrtc_session_description_factory.h b/pc/webrtc_session_description_factory.h
index 6c468ac..de7fd42 100644
--- a/pc/webrtc_session_description_factory.h
+++ b/pc/webrtc_session_description_factory.h
@@ -147,7 +147,7 @@
std::function<void(const rtc::scoped_refptr<rtc::RTCCertificate>&)>
on_certificate_ready_;
- rtc::WeakPtrFactory<WebRtcSessionDescriptionFactory> weak_factory_{this};
+ WeakPtrFactory<WebRtcSessionDescriptionFactory> weak_factory_{this};
};
} // namespace webrtc
diff --git a/rtc_base/weak_ptr.cc b/rtc_base/weak_ptr.cc
index cec0808..d67472d 100644
--- a/rtc_base/weak_ptr.cc
+++ b/rtc_base/weak_ptr.cc
@@ -13,7 +13,7 @@
// The implementation is borrowed from chromium except that it does not
// implement SupportsWeakPtr.
-namespace rtc {
+namespace webrtc {
namespace internal {
void WeakReference::Flag::Invalidate() {
@@ -68,4 +68,4 @@
WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) {}
} // namespace internal
-} // namespace rtc
+} // namespace webrtc
diff --git a/rtc_base/weak_ptr.h b/rtc_base/weak_ptr.h
index bc317e8..ecc9621 100644
--- a/rtc_base/weak_ptr.h
+++ b/rtc_base/weak_ptr.h
@@ -21,6 +21,7 @@
#include "rtc_base/ref_counted_object.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/weak_ptr.h"
// The implementation is borrowed from chromium except that it does not
// implement SupportsWeakPtr.
@@ -86,7 +87,7 @@
// the correct thread to enforce that other WeakPtr objects will enforce they
// are used on the desired thread.
-namespace rtc {
+namespace webrtc {
namespace internal {
@@ -102,11 +103,11 @@
bool IsValid() const;
private:
- friend class webrtc::FinalRefCountedObject<Flag>;
+ friend class FinalRefCountedObject<Flag>;
~Flag() = default;
- RTC_NO_UNIQUE_ADDRESS ::webrtc::SequenceChecker checker_{
+ RTC_NO_UNIQUE_ADDRESS SequenceChecker checker_{
webrtc::SequenceChecker::kDetached};
bool is_valid_ RTC_GUARDED_BY(checker_) = true;
};
@@ -276,6 +277,13 @@
T* ptr_;
};
+} // namespace webrtc
+
+// Re-export symbols from the webrtc namespace for backwards compatibility.
+// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
+namespace rtc {
+using ::webrtc::WeakPtr;
+using ::webrtc::WeakPtrFactory;
} // namespace rtc
#endif // RTC_BASE_WEAK_PTR_H_
diff --git a/rtc_base/weak_ptr_unittest.cc b/rtc_base/weak_ptr_unittest.cc
index 9e22312..3bff8ad 100644
--- a/rtc_base/weak_ptr_unittest.cc
+++ b/rtc_base/weak_ptr_unittest.cc
@@ -17,7 +17,7 @@
#include "rtc_base/task_queue_for_test.h"
#include "test/gtest.h"
-namespace rtc {
+namespace webrtc {
namespace {
@@ -203,7 +203,7 @@
template <class T>
std::unique_ptr<T> NewObjectCreatedOnTaskQueue() {
std::unique_ptr<T> obj;
- webrtc::TaskQueueForTest queue("NewObjectCreatedOnTaskQueue");
+ TaskQueueForTest queue("NewObjectCreatedOnTaskQueue");
queue.SendTask([&] { obj = std::make_unique<T>(); });
return obj;
}
@@ -225,7 +225,7 @@
auto target = std::make_unique<TargetWithFactory>();
// Create weak ptr on main thread
WeakPtr<Target> weak_ptr = target->factory.GetWeakPtr();
- webrtc::TaskQueueForTest queue("queue");
+ TaskQueueForTest queue("queue");
queue.SendTask([&] {
// Dereference and invalide weak_ptr on another thread.
EXPECT_EQ(weak_ptr.get(), target.get());
@@ -233,4 +233,4 @@
});
}
-} // namespace rtc
+} // namespace webrtc