Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: webrtc/logging/rtc_event_log/rtc_event_log.cc

Issue 3012263002: Move log_count_ out of RtcEventLogImpl (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/logging/rtc_event_log/rtc_event_log.cc
diff --git a/webrtc/logging/rtc_event_log/rtc_event_log.cc b/webrtc/logging/rtc_event_log/rtc_event_log.cc
index 8f0c0682c5529495c4fcdfd97677c81e1ae5236e..08464d1be7684dee0e16175f94798e54045fac29 100644
--- a/webrtc/logging/rtc_event_log/rtc_event_log.cc
+++ b/webrtc/logging/rtc_event_log/rtc_event_log.cc
@@ -72,6 +72,11 @@ bool IsConfigEvent(const rtclog::Event& event) {
event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT;
}
+// Observe a limit on the number of concurrent logs, so as not to run into
+// OS-imposed limits on open files and/or threads/task-queues.
+// TODO(eladalon): Known issue - there's a race over |rtc_event_log_count|.
+std::atomic<int> rtc_event_log_count(0);
+
// TODO(eladalon): This class exists because C++11 doesn't allow transferring a
// unique_ptr to a lambda (a copy constructor is required). We should get
// rid of this when we move to C++14.
@@ -157,11 +162,6 @@ class RtcEventLogImpl final : public RtcEventLog {
void LogToFile(std::unique_ptr<rtclog::Event> event);
void StopLogFile(int64_t stop_time);
- // Observe a limit on the number of concurrent logs, so as not to run into
- // OS-imposed limits on open files and/or threads/task-queues.
- // TODO(eladalon): Known issue - there's a race over |log_count_|.
- static std::atomic<int> log_count_;
-
// Make sure that the event log is "managed" - created/destroyed, as well
// as started/stopped - from the same thread/task-queue.
rtc::SequencedTaskChecker owner_sequence_checker_;
@@ -235,8 +235,6 @@ rtclog::BweProbeResult::ResultType ConvertProbeResultType(
} // namespace
-std::atomic<int> RtcEventLogImpl::log_count_(0);
-
RtcEventLogImpl::RtcEventLogImpl()
: file_(FileWrapper::Create()),
max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()),
@@ -249,7 +247,7 @@ RtcEventLogImpl::~RtcEventLogImpl() {
// If we're logging to the file, this will stop that. Blocking function.
StopLogging();
- int count = std::atomic_fetch_sub(&RtcEventLogImpl::log_count_, 1) - 1;
+ int count = std::atomic_fetch_sub(&rtc_event_log_count, 1) - 1;
RTC_DCHECK_GE(count, 0);
}
@@ -811,13 +809,13 @@ void RtcEventLogImpl::StopLogFile(int64_t stop_time) {
// RtcEventLog member functions.
std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
#ifdef ENABLE_RTC_EVENT_LOG
- // TODO(eladalon): Known issue - there's a race over |log_count_| here.
+ // TODO(eladalon): Known issue - there's a race over |rtc_event_log_count|.
constexpr int kMaxLogCount = 5;
- int count = 1 + std::atomic_fetch_add(&RtcEventLogImpl::log_count_, 1);
+ int count = 1 + std::atomic_fetch_add(&rtc_event_log_count, 1);
if (count > kMaxLogCount) {
LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. "
<< count - 1 << " logs open already.";
- std::atomic_fetch_sub(&RtcEventLogImpl::log_count_, 1);
+ std::atomic_fetch_sub(&rtc_event_log_count, 1);
return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
}
return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698