Use std::make_unique instead of absl::make_unique.
WebRTC is now using C++14 so there is no need to use the Abseil version
of std::make_unique.
This CL has been created with the following steps:
git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt
git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt
git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt
diff --new-line-format="" --unchanged-line-format="" \
/tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \
uniq > /tmp/only_make_unique.txt
diff --new-line-format="" --unchanged-line-format="" \
/tmp/only_make_unique.txt /tmp/memory.txt | \
xargs grep -l "absl/memory" > /tmp/add-memory.txt
git grep -l "\babsl::make_unique\b" | \
xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g"
git checkout PRESUBMIT.py abseil-in-webrtc.md
cat /tmp/add-memory.txt | \
xargs sed -i \
's/#include "absl\/memory\/memory.h"/#include <memory>/g'
git cl format
# Manual fix order of the new inserted #include <memory>
cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \
xargs sed -i '/#include "absl\/memory\/memory.h"/d'
git ls-files | grep BUILD.gn | \
xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d'
python tools_webrtc/gn_check_autofix.py \
-m tryserver.webrtc -b linux_rel
# Repead the gn_check_autofix step for other platforms
git ls-files | grep BUILD.gn | \
xargs sed -i 's/absl\/memory:memory/absl\/memory/g'
git cl format
Bug: webrtc:10945
Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29209}
diff --git a/api/rtc_event_log_output_file_unittest.cc b/api/rtc_event_log_output_file_unittest.cc
index bffda0c..071909b 100644
--- a/api/rtc_event_log_output_file_unittest.cc
+++ b/api/rtc_event_log_output_file_unittest.cc
@@ -15,7 +15,6 @@
#include <memory>
#include <string>
-#include "absl/memory/memory.h"
#include "rtc_base/checks.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
@@ -52,14 +51,13 @@
};
TEST_F(RtcEventLogOutputFileTest, NonDefectiveOutputsStartOutActive) {
- auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_);
+ auto output_file = std::make_unique<RtcEventLogOutputFile>(output_file_name_);
EXPECT_TRUE(output_file->IsActive());
}
TEST_F(RtcEventLogOutputFileTest, DefectiveOutputsStartOutInactive) {
const std::string illegal_filename = "/////////";
- auto output_file = absl::make_unique<RtcEventLogOutputFile>(illegal_filename);
+ auto output_file = std::make_unique<RtcEventLogOutputFile>(illegal_filename);
EXPECT_FALSE(output_file->IsActive());
}
@@ -67,8 +65,7 @@
TEST_F(RtcEventLogOutputFileTest, UnlimitedOutputFile) {
const std::string output_str = "one two three";
- auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_);
+ auto output_file = std::make_unique<RtcEventLogOutputFile>(output_file_name_);
output_file->Write(output_str);
output_file.reset(); // Closing the file flushes the buffer to disk.
@@ -79,7 +76,7 @@
TEST_F(RtcEventLogOutputFileTest, LimitedOutputFileCappedToCapacity) {
// Fit two bytes, then the third should be rejected.
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
output_file->Write("1");
output_file->Write("2");
@@ -99,7 +96,7 @@
// Set a file size limit just shy of fitting the entire second line.
const size_t size_limit = output_str_1.length() + output_str_2.length() - 1;
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, size_limit);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, size_limit);
output_file->Write(output_str_1);
output_file->Write(output_str_2);
@@ -110,20 +107,20 @@
TEST_F(RtcEventLogOutputFileTest, UnsuccessfulWriteReturnsFalse) {
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
EXPECT_FALSE(output_file->Write("abc"));
}
TEST_F(RtcEventLogOutputFileTest, SuccessfulWriteReturnsTrue) {
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
EXPECT_TRUE(output_file->Write("abc"));
}
// Even if capacity is reached, a successful write leaves the output active.
TEST_F(RtcEventLogOutputFileTest, FileStillActiveAfterSuccessfulWrite) {
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, 3);
ASSERT_TRUE(output_file->Write("abc"));
EXPECT_TRUE(output_file->IsActive());
}
@@ -132,13 +129,13 @@
// not yet been reached.
TEST_F(RtcEventLogOutputFileTest, FileInactiveAfterUnsuccessfulWrite) {
auto output_file =
- absl::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
+ std::make_unique<RtcEventLogOutputFile>(output_file_name_, 2);
ASSERT_FALSE(output_file->Write("abc"));
EXPECT_FALSE(output_file->IsActive());
}
TEST_F(RtcEventLogOutputFileTest, AllowReasonableFileSizeLimits) {
- auto output_file = absl::make_unique<RtcEventLogOutputFile>(
+ auto output_file = std::make_unique<RtcEventLogOutputFile>(
output_file_name_, RtcEventLogOutputFile::kMaxReasonableFileSize);
EXPECT_TRUE(output_file->IsActive());
}
@@ -158,8 +155,8 @@
auto create_output_file = [&] {
const size_t unreasonable_size =
RtcEventLogOutputFile::kMaxReasonableFileSize + 1;
- output_file = absl::make_unique<RtcEventLogOutputFile>(output_file_name_,
- unreasonable_size);
+ output_file = std::make_unique<RtcEventLogOutputFile>(output_file_name_,
+ unreasonable_size);
};
EXPECT_DEATH(create_output_file(), "");
}