Adopt absl::string_view in function parameters under rtc_base/
This is part of a large-scale effort to increase adoption of absl::string_view across the WebRTC code base. This CL converts the majority of "const std::string&"s in function parameters under rtc_base/ to absl::string_view. Bug: webrtc:13579 Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081 Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Xavier Lepaul <xalep@webrtc.org> Reviewed-by: Anders Lilienthal <andersc@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Commit-Queue: Ali Tofigh <alito@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36239}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
1a08096998
commit
7fa9057a05
@ -15,6 +15,7 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
@ -44,15 +45,15 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test {
|
||||
static const char* kFilePrefix;
|
||||
static const size_t kMaxFileSize;
|
||||
|
||||
void Init(const std::string& dir_name,
|
||||
const std::string& file_prefix,
|
||||
void Init(absl::string_view dir_name,
|
||||
absl::string_view file_prefix,
|
||||
size_t max_file_size,
|
||||
size_t num_log_files,
|
||||
bool ensure_trailing_delimiter = true) {
|
||||
dir_path_ = webrtc::test::OutputPath();
|
||||
|
||||
// Append per-test output path in order to run within gtest parallel.
|
||||
dir_path_.append(dir_name);
|
||||
dir_path_.append(dir_name.begin(), dir_name.end());
|
||||
if (ensure_trailing_delimiter) {
|
||||
dir_path_.append(webrtc::test::kPathDelimiter);
|
||||
}
|
||||
@ -80,7 +81,7 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test {
|
||||
// end of stream result.
|
||||
void VerifyStreamRead(const char* expected_contents,
|
||||
const size_t expected_length,
|
||||
const std::string& dir_path,
|
||||
absl::string_view dir_path,
|
||||
const char* file_prefix) {
|
||||
FileRotatingStreamReader reader(dir_path, file_prefix);
|
||||
EXPECT_EQ(reader.GetSize(), expected_length);
|
||||
@ -92,9 +93,10 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test {
|
||||
|
||||
void VerifyFileContents(const char* expected_contents,
|
||||
const size_t expected_length,
|
||||
const std::string& file_path) {
|
||||
absl::string_view file_path) {
|
||||
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length + 1]);
|
||||
webrtc::FileWrapper f = webrtc::FileWrapper::OpenReadOnly(file_path);
|
||||
webrtc::FileWrapper f =
|
||||
webrtc::FileWrapper::OpenReadOnly(std::string(file_path));
|
||||
ASSERT_TRUE(f.is_open());
|
||||
size_t size_read = f.Read(buffer.get(), expected_length + 1);
|
||||
EXPECT_EQ(size_read, expected_length);
|
||||
@ -255,11 +257,11 @@ TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) {
|
||||
|
||||
class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test {
|
||||
protected:
|
||||
void Init(const std::string& dir_name, size_t max_total_log_size) {
|
||||
void Init(absl::string_view dir_name, size_t max_total_log_size) {
|
||||
dir_path_ = webrtc::test::OutputPath();
|
||||
|
||||
// Append per-test output path in order to run within gtest parallel.
|
||||
dir_path_.append(dir_name);
|
||||
dir_path_.append(dir_name.begin(), dir_name.end());
|
||||
dir_path_.append(webrtc::test::kPathDelimiter);
|
||||
ASSERT_TRUE(webrtc::test::CreateDir(dir_path_));
|
||||
stream_.reset(
|
||||
@ -285,7 +287,7 @@ class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test {
|
||||
// end of stream result.
|
||||
void VerifyStreamRead(const char* expected_contents,
|
||||
const size_t expected_length,
|
||||
const std::string& dir_path) {
|
||||
absl::string_view dir_path) {
|
||||
CallSessionFileRotatingStreamReader reader(dir_path);
|
||||
EXPECT_EQ(reader.GetSize(), expected_length);
|
||||
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
|
||||
|
||||
Reference in New Issue
Block a user