Change RTCEventLogFactory to have a const Create function

Conformant with naming rule:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/g3doc/implementation_basics.md;l=48?q=factory%20file:md$%20file:webrtc&ss=chromium

Bug: webrtc:14226
Change-Id: Ibec148fada6303e2ebdc5e6405fd527065f69d41
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266360
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37364}
This commit is contained in:
Harald Alvestrand 2022-06-28 21:48:37 +00:00 committed by WebRTC LUCI CQ
parent cc7bd85748
commit 90af4c1b70
6 changed files with 26 additions and 9 deletions

View file

@ -27,8 +27,8 @@ RtcEventLogFactory::RtcEventLogFactory(TaskQueueFactory* task_queue_factory)
RTC_DCHECK(task_queue_factory_);
}
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) {
std::unique_ptr<RtcEventLog> RtcEventLogFactory::Create(
RtcEventLog::EncodingType encoding_type) const {
#ifdef WEBRTC_ENABLE_RTC_EVENT_LOG
if (field_trial::IsEnabled("WebRTC-RtcEventLogKillSwitch")) {
return std::make_unique<RtcEventLogNull>();
@ -39,4 +39,9 @@ std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
#endif
}
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) {
return Create(encoding_type);
}
} // namespace webrtc

View file

@ -25,6 +25,8 @@ class RTC_EXPORT RtcEventLogFactory : public RtcEventLogFactoryInterface {
explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory);
~RtcEventLogFactory() override {}
std::unique_ptr<RtcEventLog> Create(
RtcEventLog::EncodingType encoding_type) const override;
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) override;

View file

@ -24,7 +24,9 @@ class RtcEventLogFactoryInterface {
public:
virtual ~RtcEventLogFactoryInterface() = default;
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
virtual std::unique_ptr<RtcEventLog> Create(
RtcEventLog::EncodingType encoding_type) const = 0;
[[deprecated]] virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) = 0;
};

View file

@ -17,11 +17,17 @@
namespace webrtc {
std::unique_ptr<RtcEventLog> FakeRtcEventLogFactory::CreateRtcEventLog(
RtcEventLog::EncodingType /*encoding_type*/) {
std::unique_ptr<RtcEventLog> FakeRtcEventLogFactory::Create(
RtcEventLog::EncodingType /*encoding_type*/) const {
auto fake_event_log = std::make_unique<FakeRtcEventLog>();
last_log_created_ = fake_event_log.get();
const_cast<FakeRtcEventLogFactory*>(this)->last_log_created_ =
fake_event_log.get();
return fake_event_log;
}
std::unique_ptr<RtcEventLog> FakeRtcEventLogFactory::CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) {
return Create(encoding_type);
}
} // namespace webrtc

View file

@ -23,6 +23,9 @@ class FakeRtcEventLogFactory : public RtcEventLogFactoryInterface {
FakeRtcEventLogFactory() = default;
~FakeRtcEventLogFactory() override = default;
std::unique_ptr<RtcEventLog> Create(
RtcEventLog::EncodingType encoding_type) const override;
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) override;

View file

@ -296,9 +296,8 @@ std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
auto encoding_type = RtcEventLog::EncodingType::Legacy;
if (IsTrialEnabled("WebRTC-RtcEventLogNewFormat"))
encoding_type = RtcEventLog::EncodingType::NewFormat;
return event_log_factory_
? event_log_factory_->CreateRtcEventLog(encoding_type)
: std::make_unique<RtcEventLogNull>();
return event_log_factory_ ? event_log_factory_->Create(encoding_type)
: std::make_unique<RtcEventLogNull>();
}
std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(