Remove rtc::{Make,Wrap}Unique and their header file + unit tests

We've switched to absl::make_unique and absl::WrapUnique.

Bug: webrtc:9473
Change-Id: I08aef72d52b571c511c0f4adb4c68d6cc2654192
Reviewed-on: https://webrtc-review.googlesource.com/87262
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24225}
This commit is contained in:
Karl Wiberg
2018-08-08 11:39:52 +02:00
committed by Commit Bot
parent 58d2a5e976
commit c2342031f4
8 changed files with 4 additions and 118 deletions

View File

@ -166,5 +166,6 @@ rtc_source_set("video_stream_encoder_create") {
"../../rtc_base:ptr_util",
"../../video:video_stream_encoder_impl",
"../video_codecs:video_codecs_api",
"//third_party/abseil-cpp/absl/memory",
]
}

View File

@ -10,7 +10,7 @@
#include "api/video/video_stream_encoder_create.h"
#include "rtc_base/ptr_util.h"
#include "absl/memory/memory.h"
#include "video/video_stream_encoder.h"
namespace webrtc {
@ -20,8 +20,8 @@ std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder(
const VideoStreamEncoderSettings& settings,
// Deprecated, used for tests only.
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback) {
return rtc::MakeUnique<VideoStreamEncoder>(
return absl::make_unique<VideoStreamEncoder>(
number_of_cores, encoder_stats_observer, settings, pre_encode_callback,
rtc::MakeUnique<OveruseFrameDetector>(encoder_stats_observer));
absl::make_unique<OveruseFrameDetector>(encoder_stats_observer));
}
} // namespace webrtc

View File

@ -111,12 +111,8 @@ rtc_source_set("platform_thread_types") {
rtc_source_set("ptr_util") {
sources = [
"ptr_util.h",
"scoped_ref_ptr.h",
]
deps = [
"//third_party/abseil-cpp/absl/memory",
]
}
rtc_source_set("refcount") {
@ -1272,7 +1268,6 @@ if (rtc_include_tests) {
"network_unittest.cc",
"optionsfile_unittest.cc",
"proxy_unittest.cc",
"ptr_util_unittest.cc",
"rollingaccumulator_unittest.cc",
"rtccertificate_unittest.cc",
"rtccertificategenerator_unittest.cc",

View File

@ -1,38 +0,0 @@
/*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
// This file contains rtc::MakeUnique and rtc::WrapUnique, which are backwards
// compatibility aliases for absl::make_unique and absl::WrapUnique,
// respectively. This file will go away soon; use the Abseil types directly in
// new code.
#ifndef RTC_BASE_PTR_UTIL_H_
#define RTC_BASE_PTR_UTIL_H_
#include "absl/memory/memory.h"
namespace rtc {
template <typename T, typename... Args>
auto MakeUnique(Args&&... args)
-> decltype(absl::make_unique<T, Args...>(std::forward<Args>(args)...)) {
return absl::make_unique<T, Args...>(std::forward<Args>(args)...);
}
template <typename T>
auto MakeUnique(size_t n) -> decltype(absl::make_unique<T>(n)) {
return absl::make_unique<T>(n);
}
using absl::WrapUnique;
} // namespace rtc
#endif // RTC_BASE_PTR_UTIL_H_

View File

@ -1,69 +0,0 @@
/*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/ptr_util.h"
#include <stddef.h>
#include <string>
#include "rtc_base/gunit.h"
namespace rtc {
namespace {
class DeleteCounter {
public:
DeleteCounter() { ++count_; }
~DeleteCounter() { --count_; }
static size_t count() { return count_; }
private:
static size_t count_;
};
size_t DeleteCounter::count_ = 0;
} // namespace
TEST(PtrUtilTest, WrapUnique) {
EXPECT_EQ(0u, DeleteCounter::count());
DeleteCounter* counter = new DeleteCounter;
EXPECT_EQ(1u, DeleteCounter::count());
std::unique_ptr<DeleteCounter> owned_counter = WrapUnique(counter);
EXPECT_EQ(1u, DeleteCounter::count());
owned_counter.reset();
EXPECT_EQ(0u, DeleteCounter::count());
}
TEST(PtrUtilTest, MakeUniqueScalar) {
auto s = MakeUnique<std::string>();
EXPECT_EQ("", *s);
auto s2 = MakeUnique<std::string>("test");
EXPECT_EQ("test", *s2);
}
TEST(PtrUtilTest, MakeUniqueScalarWithMoveOnlyType) {
using MoveOnly = std::unique_ptr<std::string>;
auto p = MakeUnique<MoveOnly>(MakeUnique<std::string>("test"));
EXPECT_EQ("test", **p);
}
TEST(PtrUtilTest, MakeUniqueArray) {
EXPECT_EQ(0u, DeleteCounter::count());
auto a = MakeUnique<DeleteCounter[]>(5);
EXPECT_EQ(5u, DeleteCounter::count());
a.reset();
EXPECT_EQ(0u, DeleteCounter::count());
}
} // namespace rtc

View File

@ -23,7 +23,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/ptr_util.h"
#include "rtc_base/scoped_ref_ptr.h"
#include "rtc_base/thread.h"
#include "rtc_base/timeutils.h"

View File

@ -30,7 +30,6 @@
#include "rtc_base/bind.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/ptr_util.h"
#include "rtc_base/sequenced_task_checker.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/thread.h"

View File

@ -18,7 +18,6 @@
#include "api/videosourceproxy.h"
#include "media/engine/convert_legacy_video_factory.h"
#include "rtc_base/logging.h"
#include "rtc_base/ptr_util.h"
#include "sdk/android/src/jni/androidvideotracksource.h"
#include "sdk/android/src/jni/videodecoderfactorywrapper.h"
#include "sdk/android/src/jni/videoencoderfactorywrapper.h"