mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Remove unnecessary std::string overloads
Makes std::string version of rtc::RtcEventLogOutput::Write() no longer pure virtual while making the absl::string_view version pure virtual. Also removes unnecessary overloads in subclasses. BUG=webrtc:13579 Change-Id: I8fb449560b795a1ef76fab27533d9042d0c34cd1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268062 Commit-Queue: Ali Tofigh <alito@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37484}
This commit is contained in:
parent
26910ffe22
commit
eb91fe48fe
7 changed files with 5 additions and 20 deletions
|
@ -33,12 +33,12 @@ class RtcEventLogOutput {
|
|||
// 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
|
||||
// an inactive output sink.
|
||||
virtual bool Write(const std::string& output) = 0;
|
||||
// TODO(bugs.webrtc.org/13579): Make pure virtual and remove the string ref
|
||||
// once all classes implement the string_view version.
|
||||
virtual bool Write(absl::string_view output) {
|
||||
return Write(std::string(output));
|
||||
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;
|
||||
|
||||
// Indicates that buffers should be written to disk if applicable.
|
||||
virtual void Flush() {}
|
||||
|
|
|
@ -54,10 +54,6 @@ bool RtcEventLogOutputFile::IsActive() const {
|
|||
return IsActiveInternal();
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -37,7 +37,6 @@ class RtcEventLogOutputFile final : public RtcEventLogOutput {
|
|||
|
||||
bool IsActive() const override;
|
||||
|
||||
bool Write(const std::string& output) override;
|
||||
bool Write(absl::string_view output) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -437,7 +437,6 @@ static const char kDtlsSdesFallbackSdp[] =
|
|||
class RtcEventLogOutputNull final : public RtcEventLogOutput {
|
||||
public:
|
||||
bool IsActive() const override { return true; }
|
||||
bool Write(const std::string& /*output*/) override { return true; }
|
||||
bool Write(const absl::string_view /*output*/) override { return true; }
|
||||
};
|
||||
|
||||
|
|
|
@ -32,10 +32,6 @@ bool FileLogWriter::IsActive() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FileLogWriter::Write(const std::string& value) {
|
||||
return Write(absl::string_view(value));
|
||||
}
|
||||
|
||||
bool FileLogWriter::Write(absl::string_view value) {
|
||||
// We don't expect the write to fail. If it does, we don't want to risk
|
||||
// silently ignoring it.
|
||||
|
|
|
@ -24,7 +24,6 @@ class FileLogWriter final : public RtcEventLogOutput {
|
|||
explicit FileLogWriter(std::string file_path);
|
||||
~FileLogWriter() final;
|
||||
bool IsActive() const override;
|
||||
bool Write(const std::string& value) override;
|
||||
bool Write(absl::string_view value) override;
|
||||
void Flush() override;
|
||||
|
||||
|
|
|
@ -23,10 +23,6 @@ class MemoryLogWriter final : public RtcEventLogOutput {
|
|||
: target_(target), filename_(filename) {}
|
||||
~MemoryLogWriter() final { target_->insert({filename_, std::move(buffer_)}); }
|
||||
bool IsActive() const override { return true; }
|
||||
bool Write(const std::string& value) override {
|
||||
buffer_.append(value);
|
||||
return true;
|
||||
}
|
||||
bool Write(absl::string_view value) override {
|
||||
buffer_.append(value.data(), value.size());
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue