Add absl::string_view overload for RtcEventLogOutput::Write

Bug: webrtc:13579
Change-Id: I13f63fb6be6aa62c2e011c18327499fa16b5824e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267641
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37440}
This commit is contained in:
Björn Terelius
2022-07-05 10:58:52 +02:00
committed by WebRTC LUCI CQ
parent 8feb6fd1e9
commit 63299a3124
14 changed files with 52 additions and 26 deletions

View File

@ -55,14 +55,18 @@ bool RtcEventLogOutputFile::IsActive() const {
}
bool RtcEventLogOutputFile::Write(const std::string& output) {
return Write(absl::string_view(output));
}
bool RtcEventLogOutputFile::Write(absl::string_view output) {
RTC_DCHECK(IsActiveInternal());
// No single write may be so big, that it would risk overflowing the
// calculation of (written_bytes_ + output.length()).
RTC_DCHECK_LT(output.length(), kMaxReasonableFileSize);
RTC_DCHECK_LT(output.size(), kMaxReasonableFileSize);
if (max_size_bytes_ == RtcEventLog::kUnlimitedOutput ||
written_bytes_ + output.length() <= max_size_bytes_) {
if (file_.Write(output.c_str(), output.size())) {
written_bytes_ + output.size() <= max_size_bytes_) {
if (file_.Write(output.data(), output.size())) {
written_bytes_ += output.size();
return true;
} else {