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/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn
index 52e1ee9..169172a 100644
--- a/api/audio_codecs/g711/BUILD.gn
+++ b/api/audio_codecs/g711/BUILD.gn
@@ -25,6 +25,7 @@
"../../../modules/audio_coding:g711",
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:safe_minmax",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
}
@@ -41,6 +42,7 @@
"../../..:webrtc_common",
"../../../modules/audio_coding:g711",
"../../../rtc_base:rtc_base_approved",
+ "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
}
diff --git a/api/audio_codecs/g711/audio_decoder_g711.cc b/api/audio_codecs/g711/audio_decoder_g711.cc
index e8afa60..cb16584 100644
--- a/api/audio_codecs/g711/audio_decoder_g711.cc
+++ b/api/audio_codecs/g711/audio_decoder_g711.cc
@@ -13,10 +13,10 @@
#include <memory>
#include <vector>
+#include "absl/memory/memory.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
#include "rtc_base/numerics/safe_conversions.h"
-#include "rtc_base/ptr_util.h"
namespace webrtc {
@@ -49,9 +49,9 @@
RTC_DCHECK(config.IsOk());
switch (config.type) {
case Config::Type::kPcmU:
- return rtc::MakeUnique<AudioDecoderPcmU>(config.num_channels);
+ return absl::make_unique<AudioDecoderPcmU>(config.num_channels);
case Config::Type::kPcmA:
- return rtc::MakeUnique<AudioDecoderPcmA>(config.num_channels);
+ return absl::make_unique<AudioDecoderPcmA>(config.num_channels);
default:
return nullptr;
}
diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc
index 95595fa..1d5e541 100644
--- a/api/audio_codecs/g711/audio_encoder_g711.cc
+++ b/api/audio_codecs/g711/audio_encoder_g711.cc
@@ -13,11 +13,11 @@
#include <memory>
#include <vector>
+#include "absl/memory/memory.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/numerics/safe_minmax.h"
-#include "rtc_base/ptr_util.h"
#include "rtc_base/string_to_number.h"
namespace webrtc {
@@ -70,14 +70,14 @@
impl_config.num_channels = config.num_channels;
impl_config.frame_size_ms = config.frame_size_ms;
impl_config.payload_type = payload_type;
- return rtc::MakeUnique<AudioEncoderPcmU>(impl_config);
+ return absl::make_unique<AudioEncoderPcmU>(impl_config);
}
case Config::Type::kPcmA: {
AudioEncoderPcmA::Config impl_config;
impl_config.num_channels = config.num_channels;
impl_config.frame_size_ms = config.frame_size_ms;
impl_config.payload_type = payload_type;
- return rtc::MakeUnique<AudioEncoderPcmA>(impl_config);
+ return absl::make_unique<AudioEncoderPcmA>(impl_config);
}
default: { return nullptr; }
}