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

Unified Diff: webrtc/call/rtc_event_log_helper_thread.cc

Issue 1997393002: Improved error checking for file errors in RtcEventLog. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/call/rtc_event_log_helper_thread.cc
diff --git a/webrtc/call/rtc_event_log_helper_thread.cc b/webrtc/call/rtc_event_log_helper_thread.cc
index a9aa85144f03da4b825308f618f50e6d0d08e612..502391c64543e50ffe02840142ffaf92606b7cf2 100644
--- a/webrtc/call/rtc_event_log_helper_thread.cc
+++ b/webrtc/call/rtc_event_log_helper_thread.cc
@@ -143,7 +143,13 @@ void RtcEventLogHelperThread::StartLogFile() {
}
// Write to file.
- file_->Write(output_string_.data(), output_string_.size());
+ bool success = file_->Write(output_string_.data(), output_string_.size());
+ if (!success) {
+ LOG(LS_WARNING) << "FileWrapper failed to write WebRtcEventLog file.";
pbos-webrtc 2016/05/23 11:59:11 LS_ERROR
+ // The current FileWrapper implementation closes the file on error.
+ RTC_DCHECK(!file_->Open());
+ return;
+ }
written_bytes_ += output_string_.size();
// Free the allocated memory since we probably won't need this amount of
@@ -181,12 +187,14 @@ void RtcEventLogHelperThread::LogToFile() {
}
// Write string to file.
- file_->Write(output_string_.data(), output_string_.size());
- written_bytes_ += output_string_.size();
-
- if (!file_->Open()) {
- LOG(LS_WARNING) << "WebRTC event log file closed by FileWrapper.";
+ bool success = file_->Write(output_string_.data(), output_string_.size());
pbos-webrtc 2016/05/23 11:59:11 remove temporary bool
+ if (!success) {
+ LOG(LS_WARNING) << "FileWrapper failed to write WebRtcEventLog file.";
pbos-webrtc 2016/05/23 11:59:11 LS_ERROR
+ // The current FileWrapper implementation closes the file on error.
+ RTC_DCHECK(!file_->Open());
+ return;
}
+ written_bytes_ += output_string_.size();
// We want to stop logging if we have reached the file size limit. We also
// want to stop logging if the remaining events are more recent than the
@@ -210,7 +218,12 @@ void RtcEventLogHelperThread::StopLogFile() {
if (written_bytes_ + static_cast<int64_t>(output_string_.size()) <=
max_size_bytes_) {
- file_->Write(output_string_.data(), output_string_.size());
+ bool success = file_->Write(output_string_.data(), output_string_.size());
pbos-webrtc 2016/05/23 11:59:11 remove bool here and everywhere it's not used afte
+ if (!success) {
+ LOG(LS_WARNING) << "FileWrapper failed to write WebRtcEventLog file.";
pbos-webrtc 2016/05/23 11:59:11 LS_ERROR
+ // The current FileWrapper implementation closes the file on error.
+ RTC_DCHECK(!file_->Open());
+ }
written_bytes_ += output_string_.size();
}
« 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