mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Remove unnecessary overload in RtcEventLogOutput
Bug: webrtc:13579 Change-Id: I3ea4b8ce8d111ae6b9ce7e92f75bd4196bc9656b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268420 Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37508}
This commit is contained in:
parent
c8f9c56bc8
commit
b7821cea6b
7 changed files with 22 additions and 27 deletions
|
@ -33,11 +33,6 @@ class RtcEventLogOutput {
|
||||||
// about how much data was written, if any. The output sink becomes inactive
|
// about how much data was written, if any. The output sink becomes inactive
|
||||||
// after the first time `false` is returned. Write() may not be called on
|
// after the first time `false` is returned. Write() may not be called on
|
||||||
// an inactive output sink.
|
// an inactive output sink.
|
||||||
virtual bool Write(const std::string& output) {
|
|
||||||
return Write(absl::string_view(output));
|
|
||||||
}
|
|
||||||
// TODO(bugs.webrtc.org/13579): Remove the string ref once all classes
|
|
||||||
// implement the string_view version.
|
|
||||||
virtual bool Write(absl::string_view output) = 0;
|
virtual bool Write(absl::string_view output) = 0;
|
||||||
|
|
||||||
// Indicates that buffers should be written to disk if applicable.
|
// Indicates that buffers should be written to disk if applicable.
|
||||||
|
|
|
@ -78,9 +78,9 @@ TEST_F(RtcEventLogOutputFileTest, LimitedOutputFileCappedToCapacity) {
|
||||||
auto output_file =
|
auto output_file =
|
||||||
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
||||||
|
|
||||||
output_file->Write(absl::string_view("1"));
|
output_file->Write("1");
|
||||||
output_file->Write(absl::string_view("2"));
|
output_file->Write("2");
|
||||||
output_file->Write(absl::string_view("3"));
|
output_file->Write("3");
|
||||||
// Unsuccessful writes close the file; no need to delete the output to flush.
|
// Unsuccessful writes close the file; no need to delete the output to flush.
|
||||||
|
|
||||||
EXPECT_EQ(GetOutputFileContents(), "12");
|
EXPECT_EQ(GetOutputFileContents(), "12");
|
||||||
|
@ -108,20 +108,20 @@ TEST_F(RtcEventLogOutputFileTest, DoNotWritePartialLines) {
|
||||||
TEST_F(RtcEventLogOutputFileTest, UnsuccessfulWriteReturnsFalse) {
|
TEST_F(RtcEventLogOutputFileTest, UnsuccessfulWriteReturnsFalse) {
|
||||||
auto output_file =
|
auto output_file =
|
||||||
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
||||||
EXPECT_FALSE(output_file->Write(absl::string_view("abc")));
|
EXPECT_FALSE(output_file->Write("abc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtcEventLogOutputFileTest, SuccessfulWriteReturnsTrue) {
|
TEST_F(RtcEventLogOutputFileTest, SuccessfulWriteReturnsTrue) {
|
||||||
auto output_file =
|
auto output_file =
|
||||||
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
|
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
|
||||||
EXPECT_TRUE(output_file->Write(absl::string_view("abc")));
|
EXPECT_TRUE(output_file->Write("abc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Even if capacity is reached, a successful write leaves the output active.
|
// Even if capacity is reached, a successful write leaves the output active.
|
||||||
TEST_F(RtcEventLogOutputFileTest, FileStillActiveAfterSuccessfulWrite) {
|
TEST_F(RtcEventLogOutputFileTest, FileStillActiveAfterSuccessfulWrite) {
|
||||||
auto output_file =
|
auto output_file =
|
||||||
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
|
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
|
||||||
ASSERT_TRUE(output_file->Write(absl::string_view("abc")));
|
ASSERT_TRUE(output_file->Write("abc"));
|
||||||
EXPECT_TRUE(output_file->IsActive());
|
EXPECT_TRUE(output_file->IsActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ TEST_F(RtcEventLogOutputFileTest, FileStillActiveAfterSuccessfulWrite) {
|
||||||
TEST_F(RtcEventLogOutputFileTest, FileInactiveAfterUnsuccessfulWrite) {
|
TEST_F(RtcEventLogOutputFileTest, FileInactiveAfterUnsuccessfulWrite) {
|
||||||
auto output_file =
|
auto output_file =
|
||||||
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
|
||||||
ASSERT_FALSE(output_file->Write(absl::string_view("abc")));
|
ASSERT_FALSE(output_file->Write("abc"));
|
||||||
EXPECT_FALSE(output_file->IsActive());
|
EXPECT_FALSE(output_file->IsActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +145,9 @@ class RtcEventLogOutputFileDeathTest : public RtcEventLogOutputFileTest {};
|
||||||
|
|
||||||
TEST_F(RtcEventLogOutputFileDeathTest, WritingToInactiveFileForbidden) {
|
TEST_F(RtcEventLogOutputFileDeathTest, WritingToInactiveFileForbidden) {
|
||||||
RtcEventLogOutputFile output_file(output_file_name_, 2);
|
RtcEventLogOutputFile output_file(output_file_name_, 2);
|
||||||
ASSERT_FALSE(output_file.Write(absl::string_view("abc")));
|
ASSERT_FALSE(output_file.Write("abc"));
|
||||||
ASSERT_FALSE(output_file.IsActive());
|
ASSERT_FALSE(output_file.IsActive());
|
||||||
EXPECT_DEATH(output_file.Write(absl::string_view("abc")), "");
|
EXPECT_DEATH(output_file.Write("abc"), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtcEventLogOutputFileDeathTest, DisallowUnreasonableFileSizeLimits) {
|
TEST_F(RtcEventLogOutputFileDeathTest, DisallowUnreasonableFileSizeLimits) {
|
||||||
|
|
|
@ -136,10 +136,10 @@ void GoogCcStatePrinter::PrintHeaders(RtcEventLogOutput* log) {
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
for (const auto& logger : loggers_) {
|
for (const auto& logger : loggers_) {
|
||||||
if (ix++)
|
if (ix++)
|
||||||
log->Write(absl::string_view(" "));
|
log->Write(" ");
|
||||||
log->Write(logger->name());
|
log->Write(logger->name());
|
||||||
}
|
}
|
||||||
log->Write(absl::string_view("\n"));
|
log->Write("\n");
|
||||||
log->Flush();
|
log->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,11 +160,11 @@ void GoogCcStatePrinter::PrintState(RtcEventLogOutput* log,
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
for (const auto& logger : loggers_) {
|
for (const auto& logger : loggers_) {
|
||||||
if (ix++)
|
if (ix++)
|
||||||
log->Write(absl::string_view(" "));
|
log->Write(" ");
|
||||||
logger->WriteValue(log);
|
logger->WriteValue(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
log->Write(absl::string_view("\n"));
|
log->Write("\n");
|
||||||
log->Flush();
|
log->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2810,9 +2810,9 @@ TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalled) {
|
||||||
|
|
||||||
auto output = std::make_unique<testing::NiceMock<MockRtcEventLogOutput>>();
|
auto output = std::make_unique<testing::NiceMock<MockRtcEventLogOutput>>();
|
||||||
ON_CALL(*output, IsActive()).WillByDefault(::testing::Return(true));
|
ON_CALL(*output, IsActive()).WillByDefault(::testing::Return(true));
|
||||||
ON_CALL(*output, Write(::testing::A<const std::string&>()))
|
ON_CALL(*output, Write(::testing::A<absl::string_view>()))
|
||||||
.WillByDefault(::testing::Return(true));
|
.WillByDefault(::testing::Return(true));
|
||||||
EXPECT_CALL(*output, Write(::testing::A<const std::string&>()))
|
EXPECT_CALL(*output, Write(::testing::A<absl::string_view>()))
|
||||||
.Times(::testing::AtLeast(1));
|
.Times(::testing::AtLeast(1));
|
||||||
EXPECT_TRUE(caller()->pc()->StartRtcEventLog(
|
EXPECT_TRUE(caller()->pc()->StartRtcEventLog(
|
||||||
std::move(output), webrtc::RtcEventLog::kImmediateOutput));
|
std::move(output), webrtc::RtcEventLog::kImmediateOutput));
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/audio_options.h"
|
#include "api/audio_options.h"
|
||||||
#include "api/call/call_factory_interface.h"
|
#include "api/call/call_factory_interface.h"
|
||||||
|
@ -1250,7 +1251,6 @@ class MockRtcEventLogOutput : public webrtc::RtcEventLogOutput {
|
||||||
public:
|
public:
|
||||||
virtual ~MockRtcEventLogOutput() = default;
|
virtual ~MockRtcEventLogOutput() = default;
|
||||||
MOCK_METHOD(bool, IsActive, (), (const, override));
|
MOCK_METHOD(bool, IsActive, (), (const, override));
|
||||||
MOCK_METHOD(bool, Write, (const std::string&), (override));
|
|
||||||
MOCK_METHOD(bool, Write, (absl::string_view), (override));
|
MOCK_METHOD(bool, Write, (absl::string_view), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ StatesPrinter::~StatesPrinter() = default;
|
||||||
void StatesPrinter::PrintHeaders() {
|
void StatesPrinter::PrintHeaders() {
|
||||||
if (!writer_)
|
if (!writer_)
|
||||||
return;
|
return;
|
||||||
writer_->Write(absl::string_view(printers_[0].headers_));
|
writer_->Write(printers_[0].headers_);
|
||||||
for (size_t i = 1; i < printers_.size(); ++i) {
|
for (size_t i = 1; i < printers_.size(); ++i) {
|
||||||
writer_->Write(absl::string_view(" "));
|
writer_->Write(" ");
|
||||||
writer_->Write(absl::string_view(printers_[i].headers_));
|
writer_->Write(printers_[i].headers_);
|
||||||
}
|
}
|
||||||
writer_->Write(absl::string_view("\n"));
|
writer_->Write("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesPrinter::PrintRow() {
|
void StatesPrinter::PrintRow() {
|
||||||
|
|
|
@ -29,9 +29,9 @@ VideoQualityAnalyzer::VideoQualityAnalyzer(
|
||||||
VideoQualityAnalyzer::~VideoQualityAnalyzer() = default;
|
VideoQualityAnalyzer::~VideoQualityAnalyzer() = default;
|
||||||
|
|
||||||
void VideoQualityAnalyzer::PrintHeaders() {
|
void VideoQualityAnalyzer::PrintHeaders() {
|
||||||
writer_->Write(absl::string_view(
|
writer_->Write(
|
||||||
"capture_time render_time capture_width capture_height render_width "
|
"capture_time render_time capture_width capture_height render_width "
|
||||||
"render_height psnr\n"));
|
"render_height psnr\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<void(const VideoFramePair&)> VideoQualityAnalyzer::Handler() {
|
std::function<void(const VideoFramePair&)> VideoQualityAnalyzer::Handler() {
|
||||||
|
|
Loading…
Reference in a new issue