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

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc

Issue 2787263003: Delete all log messages depending on system_wrappers. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
11 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" 11 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/timeutils.h" 16 #include "webrtc/base/timeutils.h"
17 #include "webrtc/system_wrappers/include/logging.h"
18 17
19 #ifdef ENABLE_RTC_EVENT_LOG 18 #ifdef ENABLE_RTC_EVENT_LOG
20 19
21 namespace webrtc { 20 namespace webrtc {
22 21
23 namespace { 22 namespace {
24 const int kEventsInHistory = 10000; 23 const int kEventsInHistory = 10000;
25 24
26 bool IsConfigEvent(const rtclog::Event& event) { 25 bool IsConfigEvent(const rtclog::Event& event) {
27 rtclog::Event_EventType event_type = event.type(); 26 rtclog::Event_EventType event_type = event.type();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 RtcEventLogHelperThread::~RtcEventLogHelperThread() { 59 RtcEventLogHelperThread::~RtcEventLogHelperThread() {
61 ControlMessage message; 60 ControlMessage message;
62 message.message_type = ControlMessage::TERMINATE_THREAD; 61 message.message_type = ControlMessage::TERMINATE_THREAD;
63 message.stop_time = rtc::TimeMicros(); 62 message.stop_time = rtc::TimeMicros();
64 while (!message_queue_->Insert(&message)) { 63 while (!message_queue_->Insert(&message)) {
65 // We can't destroy the event log until we have stopped the thread, 64 // We can't destroy the event log until we have stopped the thread,
66 // so clear the message queue and try again. Note that if we clear 65 // so clear the message queue and try again. Note that if we clear
67 // any STOP_FILE events, then the threads calling StopLogging would likely 66 // any STOP_FILE events, then the threads calling StopLogging would likely
68 // wait indefinitely. However, there should not be any such calls as we 67 // wait indefinitely. However, there should not be any such calls as we
69 // are executing the destructor. 68 // are executing the destructor.
70 LOG(LS_WARNING) << "Clearing message queue to terminate thread.";
71 message_queue_->Clear(); 69 message_queue_->Clear();
72 } 70 }
73 wake_from_hibernation_.Set(); 71 wake_from_hibernation_.Set();
74 wake_periodically_.Set(); // Wake up the output thread. 72 wake_periodically_.Set(); // Wake up the output thread.
75 thread_.Stop(); // Wait for the thread to terminate. 73 thread_.Stop(); // Wait for the thread to terminate.
76 } 74 }
77 75
78 void RtcEventLogHelperThread::WaitForFileFinished() { 76 void RtcEventLogHelperThread::WaitForFileFinished() {
79 wake_from_hibernation_.Set(); 77 wake_from_hibernation_.Set();
80 wake_periodically_.Set(); 78 wake_periodically_.Set();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Serialize the events in the event queue. 144 // Serialize the events in the event queue.
147 while (!history_.empty() && !stop) { 145 while (!history_.empty() && !stop) {
148 stop = AppendEventToString(history_.front().get()); 146 stop = AppendEventToString(history_.front().get());
149 if (!stop) { 147 if (!stop) {
150 history_.pop_front(); 148 history_.pop_front();
151 } 149 }
152 } 150 }
153 151
154 // Write to file. 152 // Write to file.
155 if (!file_->Write(output_string_.data(), output_string_.size())) { 153 if (!file_->Write(output_string_.data(), output_string_.size())) {
156 LOG(LS_ERROR) << "FileWrapper failed to write WebRtcEventLog file.";
157 // The current FileWrapper implementation closes the file on error. 154 // The current FileWrapper implementation closes the file on error.
158 RTC_DCHECK(!file_->is_open()); 155 RTC_DCHECK(!file_->is_open());
159 return; 156 return;
160 } 157 }
161 written_bytes_ += output_string_.size(); 158 written_bytes_ += output_string_.size();
162 159
163 // Free the allocated memory since we probably won't need this amount of 160 // Free the allocated memory since we probably won't need this amount of
164 // space again. 161 // space again.
165 output_string_.clear(); 162 output_string_.clear();
166 output_string_.shrink_to_fit(); 163 output_string_.shrink_to_fit();
(...skipping 24 matching lines...) Expand all
191 if (IsConfigEvent(*most_recent_event_)) { 188 if (IsConfigEvent(*most_recent_event_)) {
192 config_history_.push_back(std::move(most_recent_event_)); 189 config_history_.push_back(std::move(most_recent_event_));
193 } 190 }
194 has_recent_event_ = event_queue_->Remove(&most_recent_event_); 191 has_recent_event_ = event_queue_->Remove(&most_recent_event_);
195 } 192 }
196 message_received = true; 193 message_received = true;
197 } 194 }
198 195
199 // Write string to file. 196 // Write string to file.
200 if (!file_->Write(output_string_.data(), output_string_.size())) { 197 if (!file_->Write(output_string_.data(), output_string_.size())) {
201 LOG(LS_ERROR) << "FileWrapper failed to write WebRtcEventLog file.";
202 // The current FileWrapper implementation closes the file on error. 198 // The current FileWrapper implementation closes the file on error.
203 RTC_DCHECK(!file_->is_open()); 199 RTC_DCHECK(!file_->is_open());
204 return message_received; 200 return message_received;
205 } 201 }
206 written_bytes_ += output_string_.size(); 202 written_bytes_ += output_string_.size();
207 203
208 // We want to stop logging if we have reached the file size limit. We also 204 // We want to stop logging if we have reached the file size limit. We also
209 // want to stop logging if the remaining events are more recent than the 205 // want to stop logging if the remaining events are more recent than the
210 // time limit, or in other words if we have terminated the loop despite 206 // time limit, or in other words if we have terminated the loop despite
211 // having more events in the queue. 207 // having more events in the queue.
(...skipping 14 matching lines...) Expand all
226 // or because we have reached the log file size limit. Therefore, use the 222 // or because we have reached the log file size limit. Therefore, use the
227 // current time if we have not reached the time limit. 223 // current time if we have not reached the time limit.
228 end_event.set_timestamp_us( 224 end_event.set_timestamp_us(
229 std::min(stop_time_, rtc::TimeMicros())); 225 std::min(stop_time_, rtc::TimeMicros()));
230 end_event.set_type(rtclog::Event::LOG_END); 226 end_event.set_type(rtclog::Event::LOG_END);
231 AppendEventToString(&end_event); 227 AppendEventToString(&end_event);
232 228
233 if (written_bytes_ + static_cast<int64_t>(output_string_.size()) <= 229 if (written_bytes_ + static_cast<int64_t>(output_string_.size()) <=
234 max_size_bytes_) { 230 max_size_bytes_) {
235 if (!file_->Write(output_string_.data(), output_string_.size())) { 231 if (!file_->Write(output_string_.data(), output_string_.size())) {
236 LOG(LS_ERROR) << "FileWrapper failed to write WebRtcEventLog file.";
237 // The current FileWrapper implementation closes the file on error. 232 // The current FileWrapper implementation closes the file on error.
238 RTC_DCHECK(!file_->is_open()); 233 RTC_DCHECK(!file_->is_open());
239 } 234 }
240 written_bytes_ += output_string_.size(); 235 written_bytes_ += output_string_.size();
241 } 236 }
242 237
243 max_size_bytes_ = std::numeric_limits<int64_t>::max(); 238 max_size_bytes_ = std::numeric_limits<int64_t>::max();
244 written_bytes_ = 0; 239 written_bytes_ = 0;
245 start_time_ = 0; 240 start_time_ = 0;
246 stop_time_ = std::numeric_limits<int64_t>::max(); 241 stop_time_ = std::numeric_limits<int64_t>::max();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 303 }
309 304
310 void RtcEventLogHelperThread::ThreadOutputFunction(void* obj) { 305 void RtcEventLogHelperThread::ThreadOutputFunction(void* obj) {
311 RtcEventLogHelperThread* helper = static_cast<RtcEventLogHelperThread*>(obj); 306 RtcEventLogHelperThread* helper = static_cast<RtcEventLogHelperThread*>(obj);
312 helper->ProcessEvents(); 307 helper->ProcessEvents();
313 } 308 }
314 309
315 } // namespace webrtc 310 } // namespace webrtc
316 311
317 #endif // ENABLE_RTC_EVENT_LOG 312 #endif // ENABLE_RTC_EVENT_LOG
OLDNEW
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log.cc ('k') | webrtc/modules/audio_coding/acm2/acm_resampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698