diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /third_party/libwebrtc/logging/rtc_event_log | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/logging/rtc_event_log')
-rw-r--r-- | third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc | 44 | ||||
-rw-r--r-- | third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h | 13 |
2 files changed, 27 insertions, 30 deletions
diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc index f2b3f22d6a..419afd330a 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc @@ -17,6 +17,8 @@ #include <vector> #include "absl/strings/string_view.h" +#include "api/environment/environment.h" +#include "api/field_trials_view.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h" @@ -29,24 +31,23 @@ #include "rtc_base/time_utils.h" namespace webrtc { +namespace { -std::unique_ptr<RtcEventLogEncoder> RtcEventLogImpl::CreateEncoder( - RtcEventLog::EncodingType type) { - switch (type) { - case RtcEventLog::EncodingType::Legacy: - RTC_DLOG(LS_INFO) << "Creating legacy encoder for RTC event log."; - return std::make_unique<RtcEventLogEncoderLegacy>(); - case RtcEventLog::EncodingType::NewFormat: - RTC_DLOG(LS_INFO) << "Creating new format encoder for RTC event log."; - return std::make_unique<RtcEventLogEncoderNewFormat>(); - default: - RTC_LOG(LS_ERROR) << "Unknown RtcEventLog encoder type (" << int(type) - << ")"; - RTC_DCHECK_NOTREACHED(); - return std::unique_ptr<RtcEventLogEncoder>(nullptr); +std::unique_ptr<RtcEventLogEncoder> CreateEncoder(const Environment& env) { + if (env.field_trials().IsDisabled("WebRTC-RtcEventLogNewFormat")) { + RTC_DLOG(LS_INFO) << "Creating legacy encoder for RTC event log."; + return std::make_unique<RtcEventLogEncoderLegacy>(); + } else { + RTC_DLOG(LS_INFO) << "Creating new format encoder for RTC event log."; + return std::make_unique<RtcEventLogEncoderNewFormat>(); } } +} // namespace + +RtcEventLogImpl::RtcEventLogImpl(const Environment& env) + : RtcEventLogImpl(CreateEncoder(env), &env.task_queue_factory()) {} + RtcEventLogImpl::RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> encoder, TaskQueueFactory* task_queue_factory, size_t max_events_in_history, @@ -55,10 +56,9 @@ RtcEventLogImpl::RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> encoder, max_config_events_in_history_(max_config_events_in_history), event_encoder_(std::move(encoder)), last_output_ms_(rtc::TimeMillis()), - task_queue_( - std::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue( - "rtc_event_log", - TaskQueueFactory::Priority::NORMAL))) {} + task_queue_(task_queue_factory->CreateTaskQueue( + "rtc_event_log", + TaskQueueFactory::Priority::NORMAL)) {} RtcEventLogImpl::~RtcEventLogImpl() { // If we're logging to the output, this will stop that. Blocking function. @@ -71,10 +71,12 @@ RtcEventLogImpl::~RtcEventLogImpl() { StopLogging(); } - // We want to block on any executing task by invoking ~TaskQueue() before + // Since we are posting tasks bound to `this`, it is critical that the event + // log and its members outlive `task_queue_`. Destruct `task_queue_` first + // to ensure tasks living on the queue can access other members. + // We want to block on any executing task by deleting TaskQueue before // we set unique_ptr's internal pointer to null. - rtc::TaskQueue* tq = task_queue_.get(); - delete tq; + task_queue_.get_deleter()(task_queue_.get()); task_queue_.release(); } diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h index 3187a7fe87..2c4ef8d7ed 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h @@ -18,14 +18,15 @@ #include <string> #include "absl/strings/string_view.h" +#include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log_output.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" #include "rtc_base/system/no_unique_address.h" -#include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" namespace webrtc { @@ -39,6 +40,7 @@ class RtcEventLogImpl final : public RtcEventLog { // bound to prevent an attack via unreasonable memory use. static constexpr size_t kMaxEventsInConfigHistory = 1000; + explicit RtcEventLogImpl(const Environment& env); RtcEventLogImpl( std::unique_ptr<RtcEventLogEncoder> encoder, TaskQueueFactory* task_queue_factory, @@ -49,9 +51,6 @@ class RtcEventLogImpl final : public RtcEventLog { ~RtcEventLogImpl() override; - static std::unique_ptr<RtcEventLogEncoder> CreateEncoder( - EncodingType encoding_type); - // TODO(eladalon): We should change these name to reflect that what we're // actually starting/stopping is the output of the log, not the log itself. bool StartLogging(std::unique_ptr<RtcEventLogOutput> output, @@ -114,11 +113,7 @@ class RtcEventLogImpl final : public RtcEventLog { bool immediately_output_mode_ RTC_GUARDED_BY(mutex_) = false; bool need_schedule_output_ RTC_GUARDED_BY(mutex_) = false; - // Since we are posting tasks bound to `this`, it is critical that the event - // log and its members outlive `task_queue_`. Keep the `task_queue_` - // last to ensure it destructs first, or else tasks living on the queue might - // access other members after they've been torn down. - std::unique_ptr<rtc::TaskQueue> task_queue_; + std::unique_ptr<TaskQueueBase, TaskQueueDeleter> task_queue_; Mutex mutex_; }; |