Merge pull request #24453 from veblush/tidy-modernize-make-unique

[Clang-Tidy] Enable modernize-make-unique
pull/24459/head
Esun Kim 5 years ago committed by GitHub
commit 84df61b31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .clang-tidy
  2. 4
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
  3. 4
      src/core/lib/surface/server.cc
  4. 3
      src/cpp/ext/filters/census/context.h
  5. 7
      src/cpp/server/health/default_health_check_service.cc
  6. 16
      src/cpp/server/load_reporter/load_reporter_async_service_impl.cc
  7. 12
      src/cpp/server/server_cc.cc
  8. 4
      test/core/iomgr/work_serializer_test.cc
  9. 4
      test/core/transport/chttp2/settings_timeout_test.cc
  10. 53
      test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc
  11. 5
      test/cpp/end2end/async_end2end_test.cc
  12. 6
      test/cpp/end2end/channelz_service_test.cc
  13. 8
      test/cpp/end2end/client_callback_end2end_test.cc
  14. 4
      test/cpp/end2end/client_crash_test.cc
  15. 85
      test/cpp/end2end/client_interceptors_end2end_test.cc
  16. 8
      test/cpp/end2end/client_lb_end2end_test.cc
  17. 15
      test/cpp/end2end/end2end_test.cc
  18. 4
      test/cpp/end2end/filter_end2end_test.cc
  19. 10
      test/cpp/end2end/flaky_network_test.cc
  20. 4
      test/cpp/end2end/generic_end2end_test.cc
  21. 5
      test/cpp/end2end/interceptors_util.cc
  22. 5
      test/cpp/end2end/nonblocking_test.cc
  23. 6
      test/cpp/end2end/proto_server_reflection_test.cc
  24. 4
      test/cpp/end2end/server_builder_plugin_test.cc
  25. 5
      test/cpp/end2end/server_crash_test.cc
  26. 25
      test/cpp/end2end/server_interceptors_end2end_test.cc
  27. 5
      test/cpp/end2end/service_config_end2end_test.cc
  28. 4
      test/cpp/end2end/time_change_test.cc
  29. 5
      test/cpp/end2end/xds_end2end_test.cc
  30. 4
      test/cpp/microbenchmarks/bm_fullstack_trickle.cc
  31. 8
      test/cpp/naming/resolver_component_test.cc
  32. 5
      test/cpp/qps/client.h
  33. 6
      test/cpp/qps/client_async.cc
  34. 12
      test/cpp/qps/client_callback.cc
  35. 4
      test/cpp/qps/qps_server_builder.cc
  36. 4
      test/cpp/qps/qps_worker.cc
  37. 10
      test/cpp/server/load_reporter/load_reporter_test.cc
  38. 4
      test/cpp/util/byte_buffer_proto_helper.cc
  39. 12
      test/cpp/util/grpc_tool.cc
  40. 20
      test/cpp/util/proto_file_parser.cc

@ -24,7 +24,7 @@ Checks: '-*,
misc-uniqueptr-reset-release,
misc-unused-alias-decls,
-misc-unused-using-decls,
-modernize-make-unique,
modernize-make-unique,
-modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-shrink-to-fit,
@ -42,3 +42,7 @@ WarningsAsErrors: '*'
CheckOptions:
- key: readability-function-size.StatementThreshold
value: '450'
- key: modernize-make-unique.MakeSmartPtrFunction
value: 'absl::make_unique'
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
value: 'absl/memory/memory.h'

@ -25,6 +25,8 @@
#include <grpc/support/atm.h>
#include <grpc/support/string_util.h>
#include "absl/memory/memory.h"
#include "src/core/lib/gprpp/sync.h"
namespace grpc_core {
@ -52,7 +54,7 @@ void GrpcLbClientStats::AddCallDropped(const char* token) {
// Record the drop.
MutexLock lock(&drop_count_mu_);
if (drop_token_counts_ == nullptr) {
drop_token_counts_.reset(new DroppedCallCounts());
drop_token_counts_ = absl::make_unique<DroppedCallCounts>();
}
for (size_t i = 0; i < drop_token_counts_->size(); ++i) {
if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) {

@ -30,6 +30,7 @@
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include <grpc/support/alloc.h>
@ -1000,7 +1001,8 @@ void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
if (num_registered_methods > 0) {
uint32_t max_probes = 0;
size_t slots = 2 * num_registered_methods;
registered_methods_.reset(new std::vector<ChannelRegisteredMethod>(slots));
registered_methods_ =
absl::make_unique<std::vector<ChannelRegisteredMethod>>(slots);
for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) {
ExternallyManagedSlice host;
ExternallyManagedSlice method(rm->method.c_str());

@ -22,15 +22,18 @@
#include <grpc/support/port_platform.h>
#include <grpc/status.h>
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "opencensus/context/context.h"
#include "opencensus/tags/tag_map.h"
#include "opencensus/trace/context_util.h"
#include "opencensus/trace/span.h"
#include "opencensus/trace/span_context.h"
#include "opencensus/trace/trace_params.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/cpp/common/channel_filter.h"
#include "src/cpp/ext/filters/census/rpc_encoding.h"

@ -18,6 +18,7 @@
#include <memory>
#include "absl/memory/memory.h"
#include "upb/upb.hpp"
#include <grpc/slice.h>
@ -114,7 +115,7 @@ DefaultHealthCheckService::HealthCheckServiceImpl*
DefaultHealthCheckService::GetHealthCheckService(
std::unique_ptr<ServerCompletionQueue> cq) {
GPR_ASSERT(impl_ == nullptr);
impl_.reset(new HealthCheckServiceImpl(this, std::move(cq)));
impl_ = absl::make_unique<HealthCheckServiceImpl>(this, std::move(cq));
return impl_.get();
}
@ -160,8 +161,8 @@ DefaultHealthCheckService::HealthCheckServiceImpl::HealthCheckServiceImpl(
AddMethod(new internal::RpcServiceMethod(
kHealthWatchMethodName, internal::RpcMethod::SERVER_STREAMING, nullptr));
// Create serving thread.
thread_ = std::unique_ptr<::grpc_core::Thread>(
new ::grpc_core::Thread("grpc_health_check_service", Serve, this));
thread_ = absl::make_unique<::grpc_core::Thread>("grpc_health_check_service",
Serve, this);
}
DefaultHealthCheckService::HealthCheckServiceImpl::~HealthCheckServiceImpl() {

@ -18,6 +18,8 @@
#include <grpc/support/port_platform.h>
#include "absl/memory/memory.h"
#include "src/cpp/server/load_reporter/load_reporter_async_service_impl.h"
namespace grpc {
@ -32,16 +34,16 @@ void LoadReporterAsyncServiceImpl::CallableTag::Run(bool ok) {
LoadReporterAsyncServiceImpl::LoadReporterAsyncServiceImpl(
std::unique_ptr<ServerCompletionQueue> cq)
: cq_(std::move(cq)) {
thread_ = std::unique_ptr<::grpc_core::Thread>(
new ::grpc_core::Thread("server_load_reporting", Work, this));
thread_ = absl::make_unique<::grpc_core::Thread>("server_load_reporting",
Work, this);
std::unique_ptr<CpuStatsProvider> cpu_stats_provider = nullptr;
#if defined(GPR_LINUX) || defined(GPR_WINDOWS) || defined(GPR_APPLE)
cpu_stats_provider.reset(new CpuStatsProviderDefaultImpl());
cpu_stats_provider = absl::make_unique<CpuStatsProviderDefaultImpl>();
#endif
load_reporter_ = std::unique_ptr<LoadReporter>(new LoadReporter(
load_reporter_ = absl::make_unique<LoadReporter>(
kFeedbackSampleWindowSeconds,
std::unique_ptr<CensusViewProvider>(new CensusViewProviderDefaultImpl()),
std::move(cpu_stats_provider)));
std::move(cpu_stats_provider));
}
LoadReporterAsyncServiceImpl::~LoadReporterAsyncServiceImpl() {
@ -66,7 +68,7 @@ void LoadReporterAsyncServiceImpl::ScheduleNextFetchAndSample() {
if (shutdown_) return;
// TODO(juanlishen): Improve the Alarm implementation to reuse a single
// instance for multiple events.
next_fetch_and_sample_alarm_.reset(new Alarm);
next_fetch_and_sample_alarm_ = absl::make_unique<Alarm>();
next_fetch_and_sample_alarm_->Set(cq_.get(), next_fetch_and_sample_time,
this);
}
@ -266,7 +268,7 @@ void LoadReporterAsyncServiceImpl::ReportLoadHandler::ScheduleNextReport(
std::move(self));
// TODO(juanlishen): Improve the Alarm implementation to reuse a single
// instance for multiple events.
next_report_alarm_.reset(new Alarm);
next_report_alarm_ = absl::make_unique<Alarm>();
next_report_alarm_->Set(cq_, next_report_time, &next_outbound_);
}
gpr_log(GPR_DEBUG,

@ -42,6 +42,8 @@
#include <grpcpp/server_context.h>
#include <grpcpp/support/time.h>
#include "absl/memory/memory.h"
#include "src/core/ext/transport/inproc/inproc_transport.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/profiling/timers.h"
@ -814,9 +816,9 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager {
void AddUnknownSyncMethod() {
if (!sync_requests_.empty()) {
unknown_method_.reset(new grpc::internal::RpcServiceMethod(
unknown_method_ = absl::make_unique<grpc::internal::RpcServiceMethod>(
"unknown", grpc::internal::RpcMethod::BIDI_STREAMING,
new grpc::internal::UnknownMethodHandler));
new grpc::internal::UnknownMethodHandler);
sync_requests_.emplace_back(
new SyncRequest(unknown_method_.get(), nullptr));
}
@ -1159,7 +1161,7 @@ void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) {
// service to handle any unimplemented methods using the default reactor
// creator
if (has_callback_methods_ && !has_callback_generic_service_) {
unimplemented_service_.reset(new grpc::CallbackGenericService);
unimplemented_service_ = absl::make_unique<grpc::CallbackGenericService>();
RegisterCallbackGenericService(unimplemented_service_.get());
}
@ -1190,8 +1192,8 @@ void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) {
// server CQs), make sure that we have a ResourceExhausted handler
// to deal with the case of thread exhaustion
if (sync_server_cqs_ != nullptr && !sync_server_cqs_->empty()) {
resource_exhausted_handler_.reset(
new grpc::internal::ResourceExhaustedHandler);
resource_exhausted_handler_ =
absl::make_unique<grpc::internal::ResourceExhaustedHandler>();
}
for (const auto& value : sync_req_mgrs_) {

@ -24,6 +24,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "absl/memory/memory.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/work_serializer.h"
@ -94,7 +96,7 @@ TEST(WorkSerializerTest, ExecuteMany) {
{
std::vector<std::unique_ptr<TestThread>> threads;
for (size_t i = 0; i < 100; ++i) {
threads.push_back(std::unique_ptr<TestThread>(new TestThread(&lock)));
threads.push_back(absl::make_unique<TestThread>(&lock));
}
}
}

@ -23,6 +23,7 @@
#include <gtest/gtest.h>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include <grpc/grpc.h>
@ -61,7 +62,8 @@ class ServerThread {
cq_ = grpc_completion_queue_create_for_next(nullptr);
grpc_server_register_completion_queue(server_, cq_, nullptr);
grpc_server_start(server_);
thread_.reset(new std::thread(std::bind(&ServerThread::Serve, this)));
thread_ =
absl::make_unique<std::thread>(std::bind(&ServerThread::Serve, this));
}
void Shutdown() {

@ -31,6 +31,7 @@
#include <set>
#include <thread>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include <grpc/grpc.h>
@ -158,8 +159,7 @@ class TestServer {
grpc_server_start(server_);
gpr_log(GPR_DEBUG, "Start TestServer %p. listen on %s", this,
server_addr_.c_str());
server_thd_ =
std::unique_ptr<std::thread>(new std::thread(PollUntilShutdown, this));
server_thd_ = absl::make_unique<std::thread>(PollUntilShutdown, this);
}
~TestServer() {
@ -212,7 +212,7 @@ class ConnectLoopRunner {
loops_(loops),
expected_connectivity_states_(expected_connectivity_states),
reconnect_backoff_ms_(reconnect_backoff_ms) {
thd_ = std::unique_ptr<std::thread>(new std::thread(ConnectLoop, this));
thd_ = absl::make_unique<std::thread>(ConnectLoop, this);
}
~ConnectLoopRunner() { thd_->join(); }
@ -310,12 +310,11 @@ TEST(AltsConcurrentConnectivityTest, TestConcurrentClientServerHandshakes) {
gpr_log(GPR_DEBUG,
"start performing concurrent expected-to-succeed connects");
for (size_t i = 0; i < num_concurrent_connects; i++) {
connect_loop_runners.push_back(
std::unique_ptr<ConnectLoopRunner>(new ConnectLoopRunner(
test_server.address(), fake_handshake_server.address(),
15 /* per connect deadline seconds */, 5 /* loops */,
GRPC_CHANNEL_READY /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */)));
connect_loop_runners.push_back(absl::make_unique<ConnectLoopRunner>(
test_server.address(), fake_handshake_server.address(),
15 /* per connect deadline seconds */, 5 /* loops */,
GRPC_CHANNEL_READY /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */));
}
connect_loop_runners.clear();
gpr_log(GPR_DEBUG,
@ -381,8 +380,7 @@ class FakeTcpServer {
abort();
}
gpr_event_init(&stop_ev_);
run_server_loop_thd_ =
std::unique_ptr<std::thread>(new std::thread(RunServerLoop, this));
run_server_loop_thd_ = absl::make_unique<std::thread>(RunServerLoop, this);
}
~FakeTcpServer() {
@ -558,12 +556,11 @@ TEST(AltsConcurrentConnectivityTest,
size_t num_concurrent_connects = 100;
gpr_log(GPR_DEBUG, "start performing concurrent expected-to-fail connects");
for (size_t i = 0; i < num_concurrent_connects; i++) {
connect_loop_runners.push_back(
std::unique_ptr<ConnectLoopRunner>(new ConnectLoopRunner(
fake_backend_server.address(), fake_handshake_server.address(),
10 /* per connect deadline seconds */, 3 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */)));
connect_loop_runners.push_back(absl::make_unique<ConnectLoopRunner>(
fake_backend_server.address(), fake_handshake_server.address(),
10 /* per connect deadline seconds */, 3 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */));
}
connect_loop_runners.clear();
gpr_log(GPR_DEBUG, "done performing concurrent expected-to-fail connects");
@ -596,12 +593,11 @@ TEST(AltsConcurrentConnectivityTest,
size_t num_concurrent_connects = 100;
gpr_log(GPR_DEBUG, "start performing concurrent expected-to-fail connects");
for (size_t i = 0; i < num_concurrent_connects; i++) {
connect_loop_runners.push_back(
std::unique_ptr<ConnectLoopRunner>(new ConnectLoopRunner(
fake_backend_server.address(), fake_handshake_server.address(),
20 /* per connect deadline seconds */, 2 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */)));
connect_loop_runners.push_back(absl::make_unique<ConnectLoopRunner>(
fake_backend_server.address(), fake_handshake_server.address(),
20 /* per connect deadline seconds */, 2 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
0 /* reconnect_backoff_ms unset */));
}
connect_loop_runners.clear();
gpr_log(GPR_DEBUG, "done performing concurrent expected-to-fail connects");
@ -635,12 +631,11 @@ TEST(AltsConcurrentConnectivityTest,
size_t num_concurrent_connects = 100;
gpr_log(GPR_DEBUG, "start performing concurrent expected-to-fail connects");
for (size_t i = 0; i < num_concurrent_connects; i++) {
connect_loop_runners.push_back(
std::unique_ptr<ConnectLoopRunner>(new ConnectLoopRunner(
fake_backend_server.address(), fake_handshake_server.address(),
10 /* per connect deadline seconds */, 2 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
100 /* reconnect_backoff_ms */)));
connect_loop_runners.push_back(absl::make_unique<ConnectLoopRunner>(
fake_backend_server.address(), fake_handshake_server.address(),
10 /* per connect deadline seconds */, 2 /* loops */,
GRPC_CHANNEL_TRANSIENT_FAILURE /* expected connectivity states */,
100 /* reconnect_backoff_ms */));
}
connect_loop_runners.clear();
gpr_log(GPR_DEBUG, "done performing concurrent expected-to-fail connects");

@ -32,6 +32,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/core/ext/filters/client_channel/backup_poller.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/iomgr/port.h"
@ -282,7 +284,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> {
auto server_creds = GetCredentialsProvider()->GetServerCredentials(
GetParam().credentials_type);
builder.AddListeningPort(server_address_.str(), server_creds);
service_.reset(new grpc::testing::EchoTestService::AsyncService());
service_ =
absl::make_unique<grpc::testing::EchoTestService::AsyncService>();
builder.RegisterService(service_.get());
if (GetParam().health_check_service) {
builder.RegisterService(&health_check_);

@ -22,13 +22,15 @@
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/ext/channelz_service_plugin.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include <grpcpp/ext/channelz_service_plugin.h>
#include "absl/memory/memory.h"
#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/channelz/channelz.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -140,7 +142,7 @@ class ChannelzServerTest : public ::testing::Test {
"localhost:" + to_string(backends_[i].port);
backend_builder.AddListeningPort(backend_server_address,
InsecureServerCredentials());
backends_[i].service.reset(new TestServiceImpl);
backends_[i].service = absl::make_unique<TestServiceImpl>();
// ensure that the backend itself has channelz disabled.
backend_builder.AddChannelArgument(GRPC_ARG_ENABLE_CHANNELZ, 0);
backend_builder.RegisterService(backends_[i].service.get());

@ -34,6 +34,7 @@
#include <sstream>
#include <thread>
#include "absl/memory/memory.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -122,8 +123,7 @@ class ClientCallbackEnd2endTest
// Add 20 dummy server interceptors
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
}
@ -163,7 +163,7 @@ class ClientCallbackEnd2endTest
assert(false);
}
stub_ = grpc::testing::EchoTestService::NewStub(channel_);
generic_stub_.reset(new GenericStub(channel_));
generic_stub_ = absl::make_unique<GenericStub>(channel_);
DummyInterceptor::Reset();
}
@ -282,7 +282,7 @@ class ClientCallbackEnd2endTest
: reuses_remaining_(reuses), do_writes_done_(do_writes_done) {
activate_ = [this, test, method_name, test_str] {
if (reuses_remaining_ > 0) {
cli_ctx_.reset(new ClientContext);
cli_ctx_ = absl::make_unique<ClientContext>();
reuses_remaining_--;
test->generic_stub_->experimental().PrepareBidiStreamingCall(
cli_ctx_.get(), method_name, this);

@ -26,6 +26,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@ -54,7 +56,7 @@ class CrashTest : public ::testing::Test {
std::ostringstream addr_stream;
addr_stream << "localhost:" << port;
auto addr = addr_stream.str();
server_.reset(new SubProcess({
server_ = absl::make_unique<SubProcess>(std::vector<std::string>({
g_root + "/client_crash_test_server",
"--address=" + addr,
}));

@ -29,6 +29,7 @@
#include <grpcpp/server_context.h>
#include <grpcpp/support/client_interceptor.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@ -761,12 +762,10 @@ TEST_P(ParameterizedClientInterceptorsEnd2endTest,
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -805,8 +804,7 @@ TEST_F(ClientInterceptorsEnd2endTest,
ChannelArguments args;
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<HijackingInterceptorFactory>(
new HijackingInterceptorFactory()));
creators.push_back(absl::make_unique<HijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, nullptr, args, std::move(creators));
MakeCall(channel);
@ -820,15 +818,12 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingTest) {
// Add 20 dummy interceptors before hijacking interceptor
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
creators.push_back(std::unique_ptr<HijackingInterceptorFactory>(
new HijackingInterceptorFactory()));
creators.push_back(absl::make_unique<HijackingInterceptorFactory>());
// Add 20 dummy interceptors after hijacking interceptor
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -841,10 +836,8 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLogThenHijackTest) {
ChannelArguments args;
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(std::unique_ptr<HijackingInterceptorFactory>(
new HijackingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
creators.push_back(absl::make_unique<HijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
MakeCall(channel);
@ -860,16 +853,14 @@ TEST_F(ClientInterceptorsEnd2endTest,
// Add 5 dummy interceptors before hijacking interceptor
creators.reserve(5);
for (auto i = 0; i < 5; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
creators.push_back(
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>(
new HijackingInterceptorMakesAnotherCallFactory()));
// Add 7 dummy interceptors after hijacking interceptor
for (auto i = 0; i < 7; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = server_->experimental().InProcessChannelWithInterceptors(
args, std::move(creators));
@ -905,12 +896,10 @@ TEST_F(ClientInterceptorsCallbackEnd2endTest,
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = server_->experimental().InProcessChannelWithInterceptors(
args, std::move(creators));
@ -926,14 +915,11 @@ TEST_F(ClientInterceptorsCallbackEnd2endTest,
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors and 20 null interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(
std::unique_ptr<NullInterceptorFactory>(new NullInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
creators.push_back(absl::make_unique<NullInterceptorFactory>());
}
auto channel = server_->experimental().InProcessChannelWithInterceptors(
args, std::move(creators));
@ -967,12 +953,10 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingTest) {
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -987,12 +971,10 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingTest) {
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -1007,8 +989,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingHijackingTest) {
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(
std::unique_ptr<ClientStreamingRpcHijackingInterceptorFactory>(
new ClientStreamingRpcHijackingInterceptorFactory()));
absl::make_unique<ClientStreamingRpcHijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -1037,8 +1018,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingHijackingTest) {
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(
std::unique_ptr<ServerStreamingRpcHijackingInterceptorFactory>(
new ServerStreamingRpcHijackingInterceptorFactory()));
absl::make_unique<ServerStreamingRpcHijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
MakeServerStreamingCall(channel);
@ -1052,8 +1032,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest,
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(
std::unique_ptr<ServerStreamingRpcHijackingInterceptorFactory>(
new ServerStreamingRpcHijackingInterceptorFactory()));
absl::make_unique<ServerStreamingRpcHijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
MakeAsyncCQServerStreamingCall(channel);
@ -1066,8 +1045,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingHijackingTest) {
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(
std::unique_ptr<BidiStreamingRpcHijackingInterceptorFactory>(
new BidiStreamingRpcHijackingInterceptorFactory()));
absl::make_unique<BidiStreamingRpcHijackingInterceptorFactory>());
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
MakeBidiStreamingCall(channel);
@ -1078,12 +1056,10 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingTest) {
DummyInterceptor::Reset();
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
creators;
creators.push_back(std::unique_ptr<LoggingInterceptorFactory>(
new LoggingInterceptorFactory()));
creators.push_back(absl::make_unique<LoggingInterceptorFactory>());
// Add 20 dummy interceptors
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -1125,8 +1101,7 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, DummyGlobalInterceptor) {
// Add 20 dummy interceptors
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -1149,8 +1124,7 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, LoggingGlobalInterceptor) {
// Add 20 dummy interceptors
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));
@ -1174,8 +1148,7 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, HijackingGlobalInterceptor) {
// Add 20 dummy interceptors
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
auto channel = experimental::CreateCustomChannelWithInterceptors(
server_address_, InsecureChannelCredentials(), args, std::move(creators));

@ -24,6 +24,7 @@
#include <string>
#include <thread>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include <grpc/grpc.h>
@ -359,8 +360,8 @@ class ClientLbEnd2endTest : public ::testing::Test {
grpc::internal::Mutex mu;
grpc::internal::MutexLock lock(&mu);
grpc::internal::CondVar cond;
thread_.reset(new std::thread(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond)));
thread_ = absl::make_unique<std::thread>(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond));
cond.WaitUntil(&mu, [this] { return server_ready_; });
server_ready_ = false;
gpr_log(GPR_INFO, "server startup complete");
@ -1752,7 +1753,8 @@ class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest {
self->trailers_intercepted_++;
self->trailing_metadata_ = args_seen.metadata;
if (backend_metric_data != nullptr) {
self->load_report_.reset(new udpa::data::orca::v1::OrcaLoadReport);
self->load_report_ =
absl::make_unique<udpa::data::orca::v1::OrcaLoadReport>();
self->load_report_->set_cpu_utilization(
backend_metric_data->cpu_utilization);
self->load_report_->set_mem_utilization(

@ -37,7 +37,9 @@
#include <mutex>
#include <thread>
#include "absl/memory/memory.h"
#include "absl/strings/str_format.h"
#include "src/core/ext/filters/client_channel/backup_poller.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/iomgr.h"
@ -376,8 +378,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
// Add 20 dummy server interceptors
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
}
@ -447,7 +448,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
interceptor_creators = {}) {
ResetChannel(std::move(interceptor_creators));
if (GetParam().use_proxy) {
proxy_service_.reset(new Proxy(channel_));
proxy_service_ = absl::make_unique<Proxy>(channel_);
int port = grpc_pick_unused_port_or_die();
std::ostringstream proxyaddr;
proxyaddr << "localhost:" << port;
@ -1887,8 +1888,8 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterception) {
}
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators;
interceptor_creators.push_back(std::unique_ptr<CredentialsInterceptorFactory>(
new CredentialsInterceptorFactory()));
interceptor_creators.push_back(
absl::make_unique<CredentialsInterceptorFactory>());
ResetStub(std::move(interceptor_creators));
EchoRequest request;
EchoResponse response;
@ -1917,8 +1918,8 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) {
}
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators;
interceptor_creators.push_back(std::unique_ptr<CredentialsInterceptorFactory>(
new CredentialsInterceptorFactory()));
interceptor_creators.push_back(
absl::make_unique<CredentialsInterceptorFactory>());
ResetStub(std::move(interceptor_creators));
EchoRequest request;
EchoResponse response;

@ -34,6 +34,8 @@
#include <grpcpp/support/config.h>
#include <grpcpp/support/slice.h>
#include "absl/memory/memory.h"
#include "src/cpp/common/channel_filter.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@ -160,7 +162,7 @@ class FilterEnd2endTest : public ::testing::Test {
void ResetStub() {
std::shared_ptr<Channel> channel = grpc::CreateChannel(
server_address_.str(), InsecureChannelCredentials());
generic_stub_.reset(new GenericStub(channel));
generic_stub_ = absl::make_unique<GenericStub>(channel);
ResetConnectionCounter();
ResetCallCounter();
}

@ -38,6 +38,8 @@
#include <random>
#include <thread>
#include "absl/memory/memory.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -180,7 +182,7 @@ class FlakyNetworkTest : public ::testing::TestWithParam<TestScenario> {
// ip6-looopback, but ipv6 support is not enabled by default in docker.
port_ = SERVER_PORT;
server_.reset(new ServerData(port_, GetParam().credentials_type));
server_ = absl::make_unique<ServerData>(port_, GetParam().credentials_type);
server_->Start(server_host_);
}
void StopServer() { server_->Shutdown(); }
@ -206,7 +208,7 @@ class FlakyNetworkTest : public ::testing::TestWithParam<TestScenario> {
bool SendRpc(
const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub,
int timeout_ms = 0, bool wait_for_ready = false) {
auto response = std::unique_ptr<EchoResponse>(new EchoResponse());
auto response = absl::make_unique<EchoResponse>();
EchoRequest request;
auto& msg = GetParam().message_content;
request.set_message(msg);
@ -257,8 +259,8 @@ class FlakyNetworkTest : public ::testing::TestWithParam<TestScenario> {
std::mutex mu;
std::unique_lock<std::mutex> lock(mu);
std::condition_variable cond;
thread_.reset(new std::thread(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond)));
thread_ = absl::make_unique<std::thread>(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond));
cond.wait(lock, [this] { return server_ready_; });
server_ready_ = false;
gpr_log(GPR_INFO, "server startup complete");

@ -32,6 +32,8 @@
#include <grpcpp/server_context.h>
#include <grpcpp/support/slice.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@ -98,7 +100,7 @@ class GenericEnd2endTest : public ::testing::Test {
std::shared_ptr<Channel> channel = grpc::CreateChannel(
server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel);
generic_stub_.reset(new GenericStub(channel));
generic_stub_ = absl::make_unique<GenericStub>(channel);
}
void server_ok(int i) { verify_ok(srv_cq_.get(), i, true); }

@ -18,6 +18,8 @@
#include "test/cpp/end2end/interceptors_util.h"
#include "absl/memory/memory.h"
namespace grpc {
namespace testing {
@ -203,8 +205,7 @@ CreateDummyClientInterceptors() {
// Add 20 dummy interceptors before hijacking interceptor
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
return creators;
}

@ -25,6 +25,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/iomgr/port.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -109,7 +111,8 @@ class NonblockingTest : public ::testing::Test {
ServerBuilder builder;
builder.AddListeningPort(server_address_.str(),
grpc::InsecureServerCredentials());
service_.reset(new grpc::testing::EchoTestService::AsyncService());
service_ =
absl::make_unique<grpc::testing::EchoTestService::AsyncService>();
builder.RegisterService(service_.get());
cq_ = builder.AddCompletionQueue();
server_ = builder.BuildAndStart();

@ -27,6 +27,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@ -57,8 +59,8 @@ class ProtoServerReflectionTest : public ::testing::Test {
std::shared_ptr<Channel> channel =
grpc::CreateChannel(target, InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel);
desc_db_.reset(new ProtoReflectionDescriptorDatabase(channel));
desc_pool_.reset(new protobuf::DescriptorPool(desc_db_.get()));
desc_db_ = absl::make_unique<ProtoReflectionDescriptorDatabase>(channel);
desc_pool_ = absl::make_unique<protobuf::DescriptorPool>(desc_db_.get());
}
string to_string(const int number) {

@ -31,6 +31,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@ -138,7 +140,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
void SetUp() override {
port_ = grpc_pick_unused_port_or_die();
builder_.reset(new ServerBuilder());
builder_ = absl::make_unique<ServerBuilder>();
}
void InsertPlugin() {

@ -26,6 +26,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@ -99,7 +101,8 @@ class CrashTest : public ::testing::Test {
std::ostringstream addr_stream;
addr_stream << "localhost:" << port;
auto addr = addr_stream.str();
client_.reset(new SubProcess({g_root + "/server_crash_test_client",
client_ = absl::make_unique<SubProcess>(
std::vector<std::string>({g_root + "/server_crash_test_client",
"--address=" + addr, "--mode=" + mode}));
GPR_ASSERT(client_);

@ -29,6 +29,7 @@
#include <grpcpp/server_context.h>
#include <grpcpp/support/server_interceptor.h>
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -253,10 +254,8 @@ class ServerInterceptorsEnd2endSyncUnaryTest : public ::testing::Test {
new LoggingInterceptorFactory()));
// Add 20 dummy interceptor factories and null interceptor factories
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(std::unique_ptr<NullInterceptorFactory>(
new NullInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
creators.push_back(absl::make_unique<NullInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
server_ = builder.BuildAndStart();
@ -299,8 +298,7 @@ class ServerInterceptorsEnd2endSyncStreamingTest : public ::testing::Test {
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
new LoggingInterceptorFactory()));
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
server_ = builder.BuildAndStart();
@ -356,8 +354,7 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, UnaryTest) {
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
new LoggingInterceptorFactory()));
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
auto cq = builder.AddCompletionQueue();
@ -429,8 +426,7 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, BidiStreamingTest) {
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
new LoggingInterceptorFactory()));
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
auto cq = builder.AddCompletionQueue();
@ -510,8 +506,7 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, GenericRPCTest) {
creators;
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
auto srv_cq = builder.AddCompletionQueue();
@ -616,8 +611,7 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, UnimplementedRpcTest) {
creators;
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
auto cq = builder.AddCompletionQueue();
@ -670,8 +664,7 @@ TEST_F(ServerInterceptorsSyncUnimplementedEnd2endTest, UnimplementedRpcTest) {
creators;
creators.reserve(20);
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
new DummyInterceptorFactory()));
creators.push_back(absl::make_unique<DummyInterceptorFactory>());
}
builder.experimental().SetInterceptorCreators(std::move(creators));
auto server = builder.BuildAndStart();

@ -24,6 +24,7 @@
#include <string>
#include <thread>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include <grpc/grpc.h>
@ -311,8 +312,8 @@ class ServiceConfigEnd2endTest : public ::testing::Test {
grpc::internal::Mutex mu;
grpc::internal::MutexLock lock(&mu);
grpc::internal::CondVar cond;
thread_.reset(new std::thread(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond)));
thread_ = absl::make_unique<std::thread>(
std::bind(&ServerData::Serve, this, server_host, &mu, &cond));
cond.WaitUntil(&mu, [this] { return server_ready_; });
server_ready_ = false;
gpr_log(GPR_INFO, "server startup complete");

@ -26,6 +26,8 @@
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "absl/memory/memory.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@ -133,7 +135,7 @@ class TimeChangeTest : public ::testing::Test {
std::ostringstream addr_stream;
addr_stream << "localhost:" << port;
server_address_ = addr_stream.str();
server_.reset(new SubProcess({
server_ = absl::make_unique<SubProcess>(std::vector<std::string>({
g_root + "/client_crash_test_server",
"--address=" + server_address_,
}));

@ -29,6 +29,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
@ -1858,8 +1859,8 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> {
// by ServerThread::Serve from firing before the wait below is hit.
grpc_core::MutexLock lock(&mu);
grpc_core::CondVar cond;
thread_.reset(
new std::thread(std::bind(&ServerThread::Serve, this, &mu, &cond)));
thread_ = absl::make_unique<std::thread>(
std::bind(&ServerThread::Serve, this, &mu, &cond));
cond.Wait(&mu);
gpr_log(GPR_INFO, "%s server startup complete", Type());
}

@ -22,6 +22,8 @@
#include <gflags/gflags.h>
#include <fstream>
#include "absl/memory/memory.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/iomgr/timer_manager.h"
@ -89,7 +91,7 @@ class TrickledCHTTP2 : public EndpointPairFixture {
std::ostringstream fn;
fn << "trickle." << (streaming ? "streaming" : "unary") << "." << req_size
<< "." << resp_size << "." << kilobits_per_second << ".csv";
log_.reset(new std::ofstream(fn.str().c_str()));
log_ = absl::make_unique<std::ofstream>(fn.str().c_str());
write_csv(log_.get(), "t", "iteration", "client_backlog",
"server_backlog", "client_t_stall", "client_s_stall",
"server_t_stall", "server_s_stall", "client_t_remote",

@ -29,6 +29,7 @@
#include <gflags/gflags.h>
#include <gmock/gmock.h>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -590,9 +591,10 @@ void RunResolvesRelevantRecordsTest(
fake_non_responsive_dns_server;
if (FLAGS_inject_broken_nameserver_list == "True") {
g_fake_non_responsive_dns_server_port = grpc_pick_unused_port_or_die();
fake_non_responsive_dns_server.reset(
new grpc::testing::FakeNonResponsiveDNSServer(
g_fake_non_responsive_dns_server_port));
fake_non_responsive_dns_server =
absl::make_unique<grpc::testing::FakeNonResponsiveDNSServer>(
g_fake_non_responsive_dns_server_port);
grpc_ares_test_only_inject_config = InjectBrokenNameServerList;
whole_uri = absl::StrCat("dns:///", FLAGS_target_name);
} else if (FLAGS_inject_broken_nameserver_list == "False") {

@ -34,6 +34,7 @@
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/slice.h>
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
@ -362,8 +363,8 @@ class Client {
// Closed-loop doesn't use random dist at all
break;
case LoadParams::kPoisson:
random_dist.reset(
new ExpDist(load.poisson().offered_load() / num_threads));
random_dist = absl::make_unique<ExpDist>(load.poisson().offered_load() /
num_threads);
break;
default:
GPR_ASSERT(false);

@ -35,6 +35,8 @@
#include <grpcpp/client_context.h>
#include <grpcpp/generic/generic_stub.h>
#include "absl/memory/memory.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "test/cpp/qps/client.h"
@ -802,7 +804,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
break; // loop around, don't return
case State::WAIT:
next_state_ = State::READY_TO_WRITE;
alarm_.reset(new Alarm);
alarm_ = absl::make_unique<Alarm>();
alarm_->Set(cq_, next_issue_(), ClientRpcContext::tag(this));
return true;
case State::READY_TO_WRITE:
@ -899,7 +901,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
static std::unique_ptr<grpc::GenericStub> GenericStubCreator(
const std::shared_ptr<Channel>& ch) {
return std::unique_ptr<grpc::GenericStub>(new grpc::GenericStub(ch));
return absl::make_unique<grpc::GenericStub>(ch);
}
class GenericAsyncStreamingClient final

@ -32,6 +32,8 @@
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include "absl/memory/memory.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "test/cpp/qps/client.h"
#include "test/cpp/qps/usage_timer.h"
@ -171,7 +173,7 @@ class CallbackUnaryClient final : public CallbackClient {
// Start an alarm callback to run the internal callback after
// next_issue_time
if (ctx_[vector_idx]->alarm_ == nullptr) {
ctx_[vector_idx]->alarm_.reset(new Alarm);
ctx_[vector_idx]->alarm_ = absl::make_unique<Alarm>();
}
ctx_[vector_idx]->alarm_->experimental().Set(
next_issue_time, [this, t, vector_idx](bool /*ok*/) {
@ -201,8 +203,8 @@ class CallbackUnaryClient final : public CallbackClient {
NotifyMainThreadOfThreadCompletion();
} else {
// Reallocate ctx for next RPC
ctx_[vector_idx].reset(
new CallbackClientRpcContext(ctx_[vector_idx]->stub_));
ctx_[vector_idx] = absl::make_unique<CallbackClientRpcContext>(
ctx_[vector_idx]->stub_);
// Schedule a new RPC
ScheduleRpc(t, vector_idx);
}
@ -308,7 +310,7 @@ class CallbackStreamingPingPongReactor final
client_->NotifyMainThreadOfThreadCompletion();
return;
}
ctx_.reset(new CallbackClientRpcContext(ctx_->stub_));
ctx_ = absl::make_unique<CallbackClientRpcContext>(ctx_->stub_);
ScheduleRpc();
}
@ -318,7 +320,7 @@ class CallbackStreamingPingPongReactor final
// Start an alarm callback to run the internal callback after
// next_issue_time
if (ctx_->alarm_ == nullptr) {
ctx_->alarm_.reset(new Alarm);
ctx_->alarm_ = absl::make_unique<Alarm>();
}
ctx_->alarm_->experimental().Set(next_issue_time,
[this](bool /*ok*/) { StartNewRpc(); });

@ -18,6 +18,8 @@
#include "qps_server_builder.h"
#include "absl/memory/memory.h"
using grpc::ServerBuilder;
namespace grpc {
@ -25,7 +27,7 @@ namespace testing {
namespace {
std::unique_ptr<ServerBuilder> DefaultCreateQpsServerBuilder() {
return std::unique_ptr<ServerBuilder>(new ServerBuilder());
return absl::make_unique<ServerBuilder>();
}
std::function<std::unique_ptr<ServerBuilder>()> g_create_qps_server_builder =

@ -34,6 +34,8 @@
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include "absl/memory/memory.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/proto/grpc/testing/worker_service.grpc.pb.h"
#include "test/core/util/grpc_profiler.h"
@ -276,7 +278,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
QpsWorker::QpsWorker(int driver_port, int server_port,
const std::string& credential_type) {
impl_.reset(new WorkerServiceImpl(server_port, this));
impl_ = absl::make_unique<WorkerServiceImpl>(server_port, this);
gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
std::unique_ptr<ServerBuilder> builder = CreateQpsServerBuilder();

@ -25,6 +25,8 @@
#include <grpc/grpc.h>
#include <gtest/gtest.h>
#include "absl/memory/memory.h"
#include "src/core/ext/filters/load_reporting/registered_opencensus_objects.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/cpp/server/load_reporter/constants.h"
@ -140,10 +142,10 @@ class LoadReporterTest : public ::testing::Test {
EXPECT_CALL(*mock_cpu, GetCpuStats())
.WillOnce(Return(initial_cpu_stats_))
.RetiresOnSaturation();
load_reporter_ = std::unique_ptr<LoadReporter>(
new LoadReporter(kFeedbackSampleWindowSeconds,
std::unique_ptr<CensusViewProvider>(mock_census),
std::unique_ptr<CpuStatsProvider>(mock_cpu)));
load_reporter_ = absl::make_unique<LoadReporter>(
kFeedbackSampleWindowSeconds,
std::unique_ptr<CensusViewProvider>(mock_census),
std::unique_ptr<CpuStatsProvider>(mock_cpu));
}
};

@ -18,6 +18,8 @@
#include "test/cpp/util/byte_buffer_proto_helper.h"
#include "absl/memory/memory.h"
namespace grpc {
namespace testing {
@ -37,7 +39,7 @@ std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
std::string buf;
message->SerializeToString(&buf);
Slice slice(buf);
return std::unique_ptr<ByteBuffer>(new ByteBuffer(&slice, 1));
return absl::make_unique<ByteBuffer>(&slice, 1);
}
bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,

@ -35,6 +35,8 @@
#include <string>
#include <thread>
#include "absl/memory/memory.h"
#include "test/cpp/util/cli_call.h"
#include "test/cpp/util/proto_file_parser.h"
#include "test/cpp/util/proto_reflection_descriptor_database.h"
@ -514,9 +516,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
CreateCliChannel(server_address, cred);
if (!FLAGS_binary_input || !FLAGS_binary_output) {
parser.reset(
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path, FLAGS_protofiles));
parser = absl::make_unique<grpc::testing::ProtoFileParser>(
FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles);
if (parser->HasError()) {
fprintf(
stderr,
@ -887,9 +888,8 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
if (!FLAGS_binary_input || !FLAGS_binary_output) {
std::shared_ptr<grpc::Channel> channel =
CreateCliChannel(server_address, cred);
parser.reset(
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path, FLAGS_protofiles));
parser = absl::make_unique<grpc::testing::ProtoFileParser>(
FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles);
if (parser->HasError()) {
fprintf(
stderr,

@ -23,6 +23,8 @@
#include <sstream>
#include <unordered_set>
#include "absl/memory/memory.h"
#include <grpcpp/support/config.h>
namespace grpc {
@ -70,16 +72,17 @@ ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
dynamic_factory_(new protobuf::DynamicMessageFactory()) {
std::vector<std::string> service_list;
if (channel) {
reflection_db_.reset(new grpc::ProtoReflectionDescriptorDatabase(channel));
reflection_db_ =
absl::make_unique<grpc::ProtoReflectionDescriptorDatabase>(channel);
reflection_db_->GetServices(&service_list);
}
std::unordered_set<std::string> known_services;
if (!protofiles.empty()) {
source_tree_.MapPath("", proto_path);
error_printer_.reset(new ErrorPrinter(this));
importer_.reset(
new protobuf::compiler::Importer(&source_tree_, error_printer_.get()));
error_printer_ = absl::make_unique<ErrorPrinter>(this);
importer_ = absl::make_unique<protobuf::compiler::Importer>(
&source_tree_, error_printer_.get());
std::string file_name;
std::stringstream ss(protofiles);
@ -95,7 +98,8 @@ ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
}
}
file_db_.reset(new protobuf::DescriptorPoolDatabase(*importer_->pool()));
file_db_ =
absl::make_unique<protobuf::DescriptorPoolDatabase>(*importer_->pool());
}
if (!reflection_db_ && !file_db_) {
@ -108,11 +112,11 @@ ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
} else if (!file_db_) {
desc_db_ = std::move(reflection_db_);
} else {
desc_db_.reset(new protobuf::MergedDescriptorDatabase(reflection_db_.get(),
file_db_.get()));
desc_db_ = absl::make_unique<protobuf::MergedDescriptorDatabase>(
reflection_db_.get(), file_db_.get());
}
desc_pool_.reset(new protobuf::DescriptorPool(desc_db_.get()));
desc_pool_ = absl::make_unique<protobuf::DescriptorPool>(desc_db_.get());
for (auto it = service_list.begin(); it != service_list.end(); it++) {
if (known_services.find(*it) == known_services.end()) {

Loading…
Cancel
Save