Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index bbe9980..5c90a0c 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -214,6 +214,7 @@
"../../common_audio:common_audio",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
+ "//third_party/abseil-cpp/absl/memory",
]
}
@@ -522,6 +523,7 @@
"test/conversational_speech:unittest",
"vad:vad_unittests",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
@@ -642,6 +644,7 @@
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:safe_minmax",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
}
@@ -680,6 +683,7 @@
"aec_dump",
"aec_dump:aec_dump_impl",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
} # audioproc_f_impl
@@ -692,6 +696,7 @@
":audio_processing",
"../../api:audioproc_f_api",
"../../rtc_base:rtc_base_approved",
+ "//third_party/abseil-cpp/absl/memory",
]
} # audioproc_f
}
diff --git a/modules/audio_processing/aec_dump/BUILD.gn b/modules/audio_processing/aec_dump/BUILD.gn
index 52a8f09..e5fee3e 100644
--- a/modules/audio_processing/aec_dump/BUILD.gn
+++ b/modules/audio_processing/aec_dump/BUILD.gn
@@ -45,6 +45,7 @@
"../",
"../../../rtc_base:rtc_base_approved",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/memory",
]
}
@@ -69,6 +70,7 @@
"../../../rtc_base:rtc_task_queue",
"../../../rtc_base/system:file_wrapper",
"../../../system_wrappers",
+ "//third_party/abseil-cpp/absl/memory",
]
deps += [ "../:audioproc_debug_proto" ]
diff --git a/modules/audio_processing/aec_dump/aec_dump_impl.cc b/modules/audio_processing/aec_dump/aec_dump_impl.cc
index 9158f9b..1b8df40 100644
--- a/modules/audio_processing/aec_dump/aec_dump_impl.cc
+++ b/modules/audio_processing/aec_dump/aec_dump_impl.cc
@@ -12,10 +12,10 @@
#include "modules/audio_processing/aec_dump/aec_dump_impl.h"
+#include "absl/memory/memory.h"
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
@@ -168,8 +168,8 @@
}
std::unique_ptr<WriteToFileTask> AecDumpImpl::CreateWriteToFileTask() {
- return rtc::MakeUnique<WriteToFileTask>(debug_file_.get(),
- &num_bytes_left_for_log_);
+ return absl::make_unique<WriteToFileTask>(debug_file_.get(),
+ &num_bytes_left_for_log_);
}
std::unique_ptr<AecDump> AecDumpFactory::Create(rtc::PlatformFile file,
@@ -184,8 +184,8 @@
if (!debug_file->OpenFromFileHandle(handle)) {
return nullptr;
}
- return rtc::MakeUnique<AecDumpImpl>(std::move(debug_file), max_log_size_bytes,
- worker_queue);
+ return absl::make_unique<AecDumpImpl>(std::move(debug_file),
+ max_log_size_bytes, worker_queue);
}
std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
@@ -196,8 +196,8 @@
if (!debug_file->OpenFile(file_name.c_str(), false)) {
return nullptr;
}
- return rtc::MakeUnique<AecDumpImpl>(std::move(debug_file), max_log_size_bytes,
- worker_queue);
+ return absl::make_unique<AecDumpImpl>(std::move(debug_file),
+ max_log_size_bytes, worker_queue);
}
std::unique_ptr<AecDump> AecDumpFactory::Create(FILE* handle,
@@ -209,7 +209,7 @@
if (!debug_file->OpenFromFileHandle(handle)) {
return nullptr;
}
- return rtc::MakeUnique<AecDumpImpl>(std::move(debug_file), max_log_size_bytes,
- worker_queue);
+ return absl::make_unique<AecDumpImpl>(std::move(debug_file),
+ max_log_size_bytes, worker_queue);
}
} // namespace webrtc
diff --git a/modules/audio_processing/aec_dump/aec_dump_integration_test.cc b/modules/audio_processing/aec_dump/aec_dump_integration_test.cc
index a7d53b5..53e731a 100644
--- a/modules/audio_processing/aec_dump/aec_dump_integration_test.cc
+++ b/modules/audio_processing/aec_dump/aec_dump_integration_test.cc
@@ -10,9 +10,9 @@
#include <utility>
+#include "absl/memory/memory.h"
#include "modules/audio_processing/aec_dump/mock_aec_dump.h"
#include "modules/audio_processing/include/audio_processing.h"
-#include "rtc_base/ptr_util.h"
using testing::_;
using testing::AtLeast;
@@ -31,14 +31,14 @@
std::unique_ptr<webrtc::test::MockAecDump> CreateMockAecDump() {
auto mock_aec_dump =
- rtc::MakeUnique<testing::StrictMock<webrtc::test::MockAecDump>>();
+ absl::make_unique<testing::StrictMock<webrtc::test::MockAecDump>>();
EXPECT_CALL(*mock_aec_dump.get(), WriteConfig(_)).Times(AtLeast(1));
EXPECT_CALL(*mock_aec_dump.get(), WriteInitMessage(_)).Times(AtLeast(1));
return std::unique_ptr<webrtc::test::MockAecDump>(std::move(mock_aec_dump));
}
std::unique_ptr<webrtc::AudioFrame> CreateFakeFrame() {
- auto fake_frame = rtc::MakeUnique<webrtc::AudioFrame>();
+ auto fake_frame = absl::make_unique<webrtc::AudioFrame>();
fake_frame->num_channels_ = 1;
fake_frame->sample_rate_hz_ = 48000;
fake_frame->samples_per_channel_ = 480;
diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn
index 8501dd9..1eb8e61 100644
--- a/modules/audio_processing/agc2/BUILD.gn
+++ b/modules/audio_processing/agc2/BUILD.gn
@@ -208,6 +208,7 @@
"../../../rtc_base:checks",
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:rtc_base_tests_utils",
+ "//third_party/abseil-cpp/absl/memory",
]
}
diff --git a/modules/audio_processing/agc2/fixed_gain_controller_unittest.cc b/modules/audio_processing/agc2/fixed_gain_controller_unittest.cc
index d688f6a..72bb409 100644
--- a/modules/audio_processing/agc2/fixed_gain_controller_unittest.cc
+++ b/modules/audio_processing/agc2/fixed_gain_controller_unittest.cc
@@ -10,12 +10,12 @@
#include "modules/audio_processing/agc2/fixed_gain_controller.h"
+#include "absl/memory/memory.h"
#include "api/array_view.h"
#include "modules/audio_processing/agc2/agc2_testing_common.h"
#include "modules/audio_processing/agc2/vector_float_frame.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
namespace {
@@ -51,7 +51,7 @@
float gain_to_apply,
size_t rate) {
std::unique_ptr<FixedGainController> fgc =
- rtc::MakeUnique<FixedGainController>(&test_data_dumper);
+ absl::make_unique<FixedGainController>(&test_data_dumper);
fgc->SetGain(gain_to_apply);
fgc->SetSampleRate(rate);
return fgc;
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 7269b9d..6bfec6d 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -62,6 +62,7 @@
"../../../../rtc_base:ptr_util",
"../../../../test:fileutils",
"../../../../test:test_support",
+ "//third_party/abseil-cpp/absl/memory",
]
}
diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.cc b/modules/audio_processing/agc2/rnn_vad/test_utils.cc
index e6dd865..db38cab 100644
--- a/modules/audio_processing/agc2/rnn_vad/test_utils.cc
+++ b/modules/audio_processing/agc2/rnn_vad/test_utils.cc
@@ -10,8 +10,8 @@
#include "modules/audio_processing/agc2/rnn_vad/test_utils.h"
+#include "absl/memory/memory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/ptr_util.h"
#include "test/gtest.h"
#include "test/testsupport/fileutils.h"
@@ -48,14 +48,14 @@
std::unique_ptr<BinaryFileReader<float>> CreatePitchSearchTestDataReader() {
constexpr size_t cols = 1396;
- return rtc::MakeUnique<BinaryFileReader<float>>(
+ return absl::make_unique<BinaryFileReader<float>>(
ResourcePath("audio_processing/agc2/rnn_vad/pitch_search_int", "dat"),
cols);
}
std::pair<std::unique_ptr<BinaryFileReader<int16_t, float>>, const size_t>
CreatePcmSamplesReader(const size_t frame_length) {
- auto ptr = rtc::MakeUnique<BinaryFileReader<int16_t, float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<int16_t, float>>(
test::ResourcePath("audio_processing/agc2/rnn_vad/samples", "pcm"),
frame_length);
// The last incomplete frame is ignored.
@@ -64,14 +64,14 @@
ReaderPairType CreatePitchBuffer24kHzReader() {
constexpr size_t cols = 864;
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
ResourcePath("audio_processing/agc2/rnn_vad/pitch_buf_24k", "dat"), cols);
return {std::move(ptr), rtc::CheckedDivExact(ptr->data_length(), cols)};
}
ReaderPairType CreateLpResidualAndPitchPeriodGainReader() {
constexpr size_t num_lp_residual_coeffs = 864;
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
ResourcePath("audio_processing/agc2/rnn_vad/pitch_lp_res", "dat"),
num_lp_residual_coeffs);
return {std::move(ptr),
@@ -81,7 +81,7 @@
ReaderPairType CreateFftCoeffsReader() {
constexpr size_t num_fft_points = 481;
constexpr size_t row_size = 2 * num_fft_points; // Real and imaginary values.
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
test::ResourcePath("audio_processing/agc2/rnn_vad/fft", "dat"),
num_fft_points);
return {std::move(ptr), rtc::CheckedDivExact(ptr->data_length(), row_size)};
@@ -89,7 +89,7 @@
ReaderPairType CreateBandEnergyCoeffsReader() {
constexpr size_t num_bands = 22;
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
test::ResourcePath("audio_processing/agc2/rnn_vad/band_energies", "dat"),
num_bands);
return {std::move(ptr), rtc::CheckedDivExact(ptr->data_length(), num_bands)};
@@ -97,7 +97,7 @@
ReaderPairType CreateSilenceFlagsFeatureMatrixReader() {
constexpr size_t feature_vector_size = 42;
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
test::ResourcePath("audio_processing/agc2/rnn_vad/sil_features", "dat"),
feature_vector_size);
// Features and silence flag.
@@ -106,7 +106,7 @@
}
ReaderPairType CreateVadProbsReader() {
- auto ptr = rtc::MakeUnique<BinaryFileReader<float>>(
+ auto ptr = absl::make_unique<BinaryFileReader<float>>(
test::ResourcePath("audio_processing/agc2/rnn_vad/vad_prob", "dat"));
return {std::move(ptr), ptr->data_length()};
}
diff --git a/modules/audio_processing/include/audio_generator_factory.cc b/modules/audio_processing/include/audio_generator_factory.cc
index 9084a1e..69a5401 100644
--- a/modules/audio_processing/include/audio_generator_factory.cc
+++ b/modules/audio_processing/include/audio_generator_factory.cc
@@ -10,16 +10,16 @@
#include "modules/audio_processing/include/audio_generator_factory.h"
+#include "absl/memory/memory.h"
#include "common_audio/wav_file.h"
#include "modules/audio_processing/audio_generator/file_audio_generator.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
std::unique_ptr<AudioGenerator> AudioGeneratorFactory::Create(
const std::string& file_name) {
std::unique_ptr<WavReader> input_audio_file(new WavReader(file_name));
- return rtc::MakeUnique<FileAudioGenerator>(std::move(input_audio_file));
+ return absl::make_unique<FileAudioGenerator>(std::move(input_audio_file));
}
} // namespace webrtc
diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc
index dce875e..e9ca151 100644
--- a/modules/audio_processing/test/audio_processing_simulator.cc
+++ b/modules/audio_processing/test/audio_processing_simulator.cc
@@ -18,6 +18,7 @@
#include <utility>
#include <vector>
+#include "absl/memory/memory.h"
#include "api/audio/echo_canceller3_factory.h"
#include "common_audio/include/audio_util.h"
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
@@ -26,7 +27,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/json.h"
#include "rtc_base/logging.h"
-#include "rtc_base/ptr_util.h"
#include "rtc_base/stringutils.h"
namespace webrtc {
@@ -355,7 +355,7 @@
std::unique_ptr<AudioProcessingBuilder> ap_builder)
: settings_(settings),
ap_builder_(ap_builder ? std::move(ap_builder)
- : rtc::MakeUnique<AudioProcessingBuilder>()),
+ : absl::make_unique<AudioProcessingBuilder>()),
analog_mic_level_(settings.initial_mic_level),
fake_recording_device_(
settings.initial_mic_level,
diff --git a/modules/audio_processing/test/audioproc_float_main.cc b/modules/audio_processing/test/audioproc_float_main.cc
index af81e78..900b927 100644
--- a/modules/audio_processing/test/audioproc_float_main.cc
+++ b/modules/audio_processing/test/audioproc_float_main.cc
@@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "absl/memory/memory.h"
#include "api/test/audioproc_float.h"
#include "modules/audio_processing/include/audio_processing.h"
-#include "rtc_base/ptr_util.h"
int main(int argc, char* argv[]) {
return webrtc::test::AudioprocFloat(
- rtc::MakeUnique<webrtc::AudioProcessingBuilder>(), argc, argv);
+ absl::make_unique<webrtc::AudioProcessingBuilder>(), argc, argv);
}
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn
index d292604..2e6e50e 100644
--- a/modules/audio_processing/test/conversational_speech/BUILD.gn
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -25,6 +25,7 @@
"../../../../rtc_base:rtc_base_approved",
"../../../../test:fileutils",
"../../../../test:test_support",
+ "//third_party/abseil-cpp/absl/memory",
]
}
@@ -51,6 +52,7 @@
"../../../../common_audio",
"../../../../rtc_base:checks",
"../../../../rtc_base:rtc_base_approved",
+ "//third_party/abseil-cpp/absl/memory",
]
visibility = [ ":*" ] # Only targets in this file can depend on this.
}
diff --git a/modules/audio_processing/test/conversational_speech/generator.cc b/modules/audio_processing/test/conversational_speech/generator.cc
index f6a0b46..741a1ca 100644
--- a/modules/audio_processing/test/conversational_speech/generator.cc
+++ b/modules/audio_processing/test/conversational_speech/generator.cc
@@ -10,13 +10,13 @@
#include <iostream>
+#include "absl/memory/memory.h"
#include "modules/audio_processing/test/conversational_speech/config.h"
#include "modules/audio_processing/test/conversational_speech/multiend_call.h"
#include "modules/audio_processing/test/conversational_speech/simulator.h"
#include "modules/audio_processing/test/conversational_speech/timing.h"
#include "modules/audio_processing/test/conversational_speech/wavreader_factory.h"
#include "rtc_base/flags.h"
-#include "rtc_base/ptr_util.h"
#include "test/testsupport/fileutils.h"
namespace webrtc {
@@ -61,7 +61,7 @@
// Parse timing and audio tracks.
auto wavreader_factory =
- rtc::MakeUnique<conversational_speech::WavReaderFactory>();
+ absl::make_unique<conversational_speech::WavReaderFactory>();
conversational_speech::MultiEndCall multiend_call(
timing, config.audiotracks_path(), std::move(wavreader_factory));
diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc
index 946aee1..c2fb780 100644
--- a/modules/audio_processing/test/conversational_speech/simulator.cc
+++ b/modules/audio_processing/test/conversational_speech/simulator.cc
@@ -17,6 +17,7 @@
#include <utility>
#include <vector>
+#include "absl/memory/memory.h"
#include "api/array_view.h"
#include "common_audio/include/audio_util.h"
#include "common_audio/wav_file.h"
@@ -25,7 +26,6 @@
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/pathutils.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
namespace test {
@@ -42,7 +42,7 @@
const std::string& output_path) {
// Create map.
auto speaker_output_file_paths_map =
- rtc::MakeUnique<std::map<std::string, SpeakerOutputFilePaths>>();
+ absl::make_unique<std::map<std::string, SpeakerOutputFilePaths>>();
// Add near-end and far-end output paths into the map.
for (const auto& speaker_name : speaker_names) {
@@ -90,7 +90,7 @@
int sample_rate) {
// Create map.
auto speaker_wav_writers_map =
- rtc::MakeUnique<std::map<std::string, SpeakerWavWriters>>();
+ absl::make_unique<std::map<std::string, SpeakerWavWriters>>();
// Add SpeakerWavWriters instance into the map.
for (auto it = speaker_output_file_paths.begin();
@@ -109,7 +109,7 @@
audiotrack_readers) {
// Create map.
auto audiotracks_map =
- rtc::MakeUnique<std::map<std::string, std::vector<int16_t>>>();
+ absl::make_unique<std::map<std::string, std::vector<int16_t>>>();
// Add audio track vectors.
for (auto it = audiotrack_readers.begin(); it != audiotrack_readers.end();
diff --git a/modules/audio_processing/test/fake_recording_device.cc b/modules/audio_processing/test/fake_recording_device.cc
index 214cf91..ee134ea 100644
--- a/modules/audio_processing/test/fake_recording_device.cc
+++ b/modules/audio_processing/test/fake_recording_device.cc
@@ -12,12 +12,12 @@
#include <algorithm>
+#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "modules/audio_processing/agc/gain_map_internal.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/numerics/safe_minmax.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
namespace test {
@@ -140,13 +140,14 @@
int device_kind) {
switch (device_kind) {
case 0:
- worker_ = rtc::MakeUnique<FakeRecordingDeviceIdentity>(initial_mic_level);
+ worker_ =
+ absl::make_unique<FakeRecordingDeviceIdentity>(initial_mic_level);
break;
case 1:
- worker_ = rtc::MakeUnique<FakeRecordingDeviceLinear>(initial_mic_level);
+ worker_ = absl::make_unique<FakeRecordingDeviceLinear>(initial_mic_level);
break;
case 2:
- worker_ = rtc::MakeUnique<FakeRecordingDeviceAgc1>(initial_mic_level);
+ worker_ = absl::make_unique<FakeRecordingDeviceAgc1>(initial_mic_level);
break;
default:
RTC_NOTREACHED();
diff --git a/modules/audio_processing/test/fake_recording_device_unittest.cc b/modules/audio_processing/test/fake_recording_device_unittest.cc
index 95a4f80..65940f2 100644
--- a/modules/audio_processing/test/fake_recording_device_unittest.cc
+++ b/modules/audio_processing/test/fake_recording_device_unittest.cc
@@ -14,9 +14,9 @@
#include <string>
#include <vector>
+#include "absl/memory/memory.h"
#include "api/array_view.h"
#include "modules/audio_processing/test/fake_recording_device.h"
-#include "rtc_base/ptr_util.h"
#include "test/gtest.h"
namespace webrtc {
@@ -47,7 +47,7 @@
std::unique_ptr<ChannelBuffer<float>> CreateChannelBufferWithData(
const std::vector<std::vector<float>>& data) {
auto buff =
- rtc::MakeUnique<ChannelBuffer<float>>(data[0].size(), data.size());
+ absl::make_unique<ChannelBuffer<float>>(data[0].size(), data.size());
WritesDataIntoChannelBuffer(data, buff.get());
return buff;
}