From 1c187dcd80c30e7c677dcfb26ee4d9d4d35c67b2 Mon Sep 17 00:00:00 2001 From: terelius Date: Mon, 5 Jun 2017 08:55:40 -0700 Subject: [PATCH] Replace RingBuffer by std::deque in RtcEventLog. BUG=webrtc:7732 Review-Url: https://codereview.webrtc.org/2875823003 Cr-Commit-Position: refs/heads/master@{#18447} --- webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc | 6 ++---- webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc b/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc index 04186a7c58..cdc30f9c36 100644 --- a/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc +++ b/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc @@ -38,8 +38,6 @@ RtcEventLogHelperThread::RtcEventLogHelperThread( SwapQueue>* event_queue) : message_queue_(message_queue), event_queue_(event_queue), - history_(kEventsInHistory), - config_history_(), file_(FileWrapper::Create()), thread_(&ThreadOutputFunction, this, "RtcEventLog thread"), max_size_bytes_(std::numeric_limits::max()), @@ -47,8 +45,6 @@ RtcEventLogHelperThread::RtcEventLogHelperThread( start_time_(0), stop_time_(std::numeric_limits::max()), has_recent_event_(false), - most_recent_event_(), - output_string_(), wake_periodically_(false, false), wake_from_hibernation_(false, false), file_finished_(false, false) { @@ -120,6 +116,8 @@ bool RtcEventLogHelperThread::LogToMemory() { config_history_.push_back(std::move(most_recent_event_)); } else { history_.push_back(std::move(most_recent_event_)); + if (history_.size() > kEventsInHistory) + history_.pop_front(); } has_recent_event_ = event_queue_->Remove(&most_recent_event_); message_received = true; diff --git a/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h b/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h index 16faad3a14..93233d8268 100644 --- a/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h +++ b/webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_HELPER_THREAD_H_ #define WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_HELPER_THREAD_H_ +#include #include #include #include @@ -95,7 +96,7 @@ class RtcEventLogHelperThread final { SwapQueue>* event_queue_; // History containing the most recent events (~ 10 s). - RingBuffer> history_; + std::deque> history_; // History containing all past configuration events. std::vector> config_history_;