| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT; | 31 event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT; |
| 32 } | 32 } |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 // RtcEventLogImpl member functions. | 35 // RtcEventLogImpl member functions. |
| 36 RtcEventLogHelperThread::RtcEventLogHelperThread( | 36 RtcEventLogHelperThread::RtcEventLogHelperThread( |
| 37 SwapQueue<ControlMessage>* message_queue, | 37 SwapQueue<ControlMessage>* message_queue, |
| 38 SwapQueue<std::unique_ptr<rtclog::Event>>* event_queue) | 38 SwapQueue<std::unique_ptr<rtclog::Event>>* event_queue) |
| 39 : message_queue_(message_queue), | 39 : message_queue_(message_queue), |
| 40 event_queue_(event_queue), | 40 event_queue_(event_queue), |
| 41 history_(kEventsInHistory), | |
| 42 config_history_(), | |
| 43 file_(FileWrapper::Create()), | 41 file_(FileWrapper::Create()), |
| 44 thread_(&ThreadOutputFunction, this, "RtcEventLog thread"), | 42 thread_(&ThreadOutputFunction, this, "RtcEventLog thread"), |
| 45 max_size_bytes_(std::numeric_limits<int64_t>::max()), | 43 max_size_bytes_(std::numeric_limits<int64_t>::max()), |
| 46 written_bytes_(0), | 44 written_bytes_(0), |
| 47 start_time_(0), | 45 start_time_(0), |
| 48 stop_time_(std::numeric_limits<int64_t>::max()), | 46 stop_time_(std::numeric_limits<int64_t>::max()), |
| 49 has_recent_event_(false), | 47 has_recent_event_(false), |
| 50 most_recent_event_(), | |
| 51 output_string_(), | |
| 52 wake_periodically_(false, false), | 48 wake_periodically_(false, false), |
| 53 wake_from_hibernation_(false, false), | 49 wake_from_hibernation_(false, false), |
| 54 file_finished_(false, false) { | 50 file_finished_(false, false) { |
| 55 RTC_DCHECK(message_queue_); | 51 RTC_DCHECK(message_queue_); |
| 56 RTC_DCHECK(event_queue_); | 52 RTC_DCHECK(event_queue_); |
| 57 thread_.Start(); | 53 thread_.Start(); |
| 58 } | 54 } |
| 59 | 55 |
| 60 RtcEventLogHelperThread::~RtcEventLogHelperThread() { | 56 RtcEventLogHelperThread::~RtcEventLogHelperThread() { |
| 61 ControlMessage message; | 57 ControlMessage message; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 int64_t current_time = rtc::TimeMicros(); | 109 int64_t current_time = rtc::TimeMicros(); |
| 114 if (!has_recent_event_) { | 110 if (!has_recent_event_) { |
| 115 has_recent_event_ = event_queue_->Remove(&most_recent_event_); | 111 has_recent_event_ = event_queue_->Remove(&most_recent_event_); |
| 116 } | 112 } |
| 117 while (has_recent_event_ && | 113 while (has_recent_event_ && |
| 118 most_recent_event_->timestamp_us() <= current_time) { | 114 most_recent_event_->timestamp_us() <= current_time) { |
| 119 if (IsConfigEvent(*most_recent_event_)) { | 115 if (IsConfigEvent(*most_recent_event_)) { |
| 120 config_history_.push_back(std::move(most_recent_event_)); | 116 config_history_.push_back(std::move(most_recent_event_)); |
| 121 } else { | 117 } else { |
| 122 history_.push_back(std::move(most_recent_event_)); | 118 history_.push_back(std::move(most_recent_event_)); |
| 119 if (history_.size() > kEventsInHistory) |
| 120 history_.pop_front(); |
| 123 } | 121 } |
| 124 has_recent_event_ = event_queue_->Remove(&most_recent_event_); | 122 has_recent_event_ = event_queue_->Remove(&most_recent_event_); |
| 125 message_received = true; | 123 message_received = true; |
| 126 } | 124 } |
| 127 return message_received; | 125 return message_received; |
| 128 } | 126 } |
| 129 | 127 |
| 130 void RtcEventLogHelperThread::StartLogFile() { | 128 void RtcEventLogHelperThread::StartLogFile() { |
| 131 RTC_DCHECK(file_->is_open()); | 129 RTC_DCHECK(file_->is_open()); |
| 132 bool stop = false; | 130 bool stop = false; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 306 } |
| 309 | 307 |
| 310 void RtcEventLogHelperThread::ThreadOutputFunction(void* obj) { | 308 void RtcEventLogHelperThread::ThreadOutputFunction(void* obj) { |
| 311 RtcEventLogHelperThread* helper = static_cast<RtcEventLogHelperThread*>(obj); | 309 RtcEventLogHelperThread* helper = static_cast<RtcEventLogHelperThread*>(obj); |
| 312 helper->ProcessEvents(); | 310 helper->ProcessEvents(); |
| 313 } | 311 } |
| 314 | 312 |
| 315 } // namespace webrtc | 313 } // namespace webrtc |
| 316 | 314 |
| 317 #endif // ENABLE_RTC_EVENT_LOG | 315 #endif // ENABLE_RTC_EVENT_LOG |
| OLD | NEW |