Replaced grpc_core::MakeUnique with absl::make_unique

pull/21843/head
Esun Kim 5 years ago
parent ee020be62c
commit 7a14955759
  1. 1
      BUILD
  2. 1
      BUILD.gn
  3. 1
      CMakeLists.txt
  4. 1
      build.yaml
  5. 1
      gRPC-C++.podspec
  6. 1
      gRPC-Core.podspec
  7. 1
      grpc.gyp
  8. 4
      src/core/ext/filters/client_channel/client_channel.cc
  9. 2
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  10. 8
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  11. 20
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  12. 12
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
  13. 8
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  14. 10
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  15. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  16. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc
  17. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  18. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  19. 6
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  20. 4
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
  21. 2
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  22. 6
      src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
  23. 4
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  24. 8
      src/core/ext/filters/client_channel/resolver_result_parsing.cc
  25. 8
      src/core/ext/filters/client_channel/resolving_lb_policy.cc
  26. 2
      src/core/ext/filters/client_channel/service_config.cc
  27. 4
      src/core/ext/filters/client_channel/xds/xds_bootstrap.cc
  28. 6
      src/core/ext/filters/message_size/message_size_filter.cc
  29. 8
      src/core/lib/gprpp/memory.h
  30. 4
      src/core/lib/security/transport/security_handshaker.cc
  31. 2
      src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc
  32. 2
      src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
  33. 2
      src/cpp/common/alts_util.cc
  34. 4
      test/core/channel/channelz_test.cc
  35. 2
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
  36. 4
      test/core/client_channel/resolvers/dns_resolver_test.cc
  37. 4
      test/core/client_channel/resolvers/sockaddr_resolver_test.cc
  38. 29
      test/core/client_channel/service_config_test.cc
  39. 1206
      test/core/end2end/fuzzers/api_fuzzer.cc
  40. 2
      test/core/end2end/goaway_server_test.cc
  41. 16
      test/core/gprpp/inlined_vector_test.cc
  42. 2
      test/core/handshake/readahead_handshaker_server_ssl.cc

@ -561,6 +561,7 @@ grpc_cc_library(
"src/core/lib/profiling/timers.h",
],
external_deps = [
"absl/memory",
"absl/strings",
],
language = "c++",

@ -162,6 +162,7 @@ config("grpc_config") {
]
deps = [
":absl/container:inlined_vector",
":absl/memory:memory",
":absl/strings:strings",
":absl/types:optional",
]

@ -1439,6 +1439,7 @@ target_include_directories(gpr
target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES}
absl::inlined_vector
absl::memory
absl::strings
absl::optional
)

@ -271,6 +271,7 @@ filegroups:
- src/core/lib/profiling/stap_timers.cc
deps:
- absl/container:inlined_vector
- absl/memory:memory
- absl/strings:strings
- absl/types:optional
uses:

@ -215,6 +215,7 @@ Pod::Spec.new do |s|
ss.dependency 'gRPC-Core', version
abseil_version = '0.20190808.1'
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/types/optional', abseil_version

@ -175,6 +175,7 @@ Pod::Spec.new do |s|
ss.dependency 'BoringSSL-GRPC', '0.0.7'
abseil_version = '0.20190808.1'
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/types/optional', abseil_version
ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS'

@ -442,6 +442,7 @@
'type': 'static_library',
'dependencies': [
'absl/container:inlined_vector',
'absl/memory:memory',
'absl/strings:strings',
'absl/types:optional',
],

@ -1595,7 +1595,7 @@ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() {
LoadBalancingPolicy::Args lb_args;
lb_args.combiner = combiner_;
lb_args.channel_control_helper =
grpc_core::MakeUnique<ClientChannelControlHelper>(this);
absl::make_unique<ClientChannelControlHelper>(this);
lb_args.args = channel_args_;
grpc_core::UniquePtr<char> target_uri(gpr_strdup(target_uri_.get()));
resolving_lb_policy_.reset(new ResolvingLoadBalancingPolicy(
@ -1871,7 +1871,7 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* /*ignored*/) {
MemoryOrder::RELEASE);
chand->UpdateStateAndPickerLocked(
GRPC_CHANNEL_SHUTDOWN, "shutdown from API",
grpc_core::MakeUnique<LoadBalancingPolicy::TransientFailurePicker>(
absl::make_unique<LoadBalancingPolicy::TransientFailurePicker>(
GRPC_ERROR_REF(op->disconnect_with_error)));
}
}

@ -385,5 +385,5 @@ void grpc_http_connect_register_handshaker_factory() {
using namespace grpc_core;
HandshakerRegistry::RegisterHandshakerFactory(
true /* at_start */, HANDSHAKER_CLIENT,
grpc_core::MakeUnique<HttpConnectHandshakerFactory>());
absl::make_unique<HttpConnectHandshakerFactory>());
}

@ -714,9 +714,9 @@ void GrpcLb::Helper::UpdateState(grpc_connectivity_state state,
client_stats = parent_->lb_calld_->client_stats()->Ref();
}
parent_->channel_control_helper()->UpdateState(
state, grpc_core::MakeUnique<Picker>(parent_.get(), parent_->serverlist_,
std::move(picker),
std::move(client_stats)));
state,
absl::make_unique<Picker>(parent_.get(), parent_->serverlist_,
std::move(picker), std::move(client_stats)));
}
void GrpcLb::Helper::RequestReresolution() {
@ -1946,7 +1946,7 @@ bool maybe_add_client_load_reporting_filter(grpc_channel_stack_builder* builder,
void grpc_lb_policy_grpclb_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::MakeUnique<grpc_core::GrpcLbFactory>());
absl::make_unique<grpc_core::GrpcLbFactory>());
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_client_load_reporting_filter,

@ -201,7 +201,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
return;
}
// If one of the subchannels in the new list is already in state
@ -319,10 +319,10 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
} else {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, grpc_core::MakeUnique<QueuePicker>(p->Ref(
GRPC_CHANNEL_CONNECTING, absl::make_unique<QueuePicker>(p->Ref(
DEBUG_LOCATION, "QueuePicker")));
}
} else {
@ -338,7 +338,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
p->selected_ = nullptr;
p->subchannel_list_.reset();
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_IDLE, grpc_core::MakeUnique<QueuePicker>(
GRPC_CHANNEL_IDLE, absl::make_unique<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker")));
} else {
// This is unlikely but can happen when a subchannel has been asked
@ -347,10 +347,10 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
if (connectivity_state == GRPC_CHANNEL_READY) {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY,
grpc_core::MakeUnique<Picker>(subchannel()->Ref()));
absl::make_unique<Picker>(subchannel()->Ref()));
} else { // CONNECTING
p->channel_control_helper()->UpdateState(
connectivity_state, grpc_core::MakeUnique<QueuePicker>(
connectivity_state, absl::make_unique<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker")));
}
}
@ -395,7 +395,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
}
}
sd->CheckConnectivityStateAndStartWatchingLocked();
@ -406,7 +406,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
// Only update connectivity state in case 1.
if (subchannel_list() == p->subchannel_list_.get()) {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, grpc_core::MakeUnique<QueuePicker>(p->Ref(
GRPC_CHANNEL_CONNECTING, absl::make_unique<QueuePicker>(p->Ref(
DEBUG_LOCATION, "QueuePicker")));
}
break;
@ -446,7 +446,7 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() {
}
p->selected_ = this;
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY, grpc_core::MakeUnique<Picker>(subchannel()->Ref()));
GRPC_CHANNEL_READY, absl::make_unique<Picker>(subchannel()->Ref()));
for (size_t i = 0; i < subchannel_list()->num_subchannels(); ++i) {
if (i != Index()) {
subchannel_list()->subchannel(i)->ShutdownLocked();
@ -503,7 +503,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_pick_first_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::MakeUnique<grpc_core::PickFirstFactory>());
absl::make_unique<grpc_core::PickFirstFactory>());
}
void grpc_lb_policy_pick_first_shutdown() {}

@ -322,12 +322,12 @@ void RoundRobin::RoundRobinSubchannelList::
if (num_ready_ > 0) {
/* 1) READY */
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY, grpc_core::MakeUnique<Picker>(p, this));
GRPC_CHANNEL_READY, absl::make_unique<Picker>(p, this));
} else if (num_connecting_ > 0) {
/* 2) CONNECTING */
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, grpc_core::MakeUnique<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker")));
GRPC_CHANNEL_CONNECTING,
absl::make_unique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
} else if (num_transient_failure_ == num_subchannels()) {
/* 3) TRANSIENT_FAILURE */
grpc_error* error =
@ -336,7 +336,7 @@ void RoundRobin::RoundRobinSubchannelList::
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
}
}
@ -453,7 +453,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
subchannel_list_ = std::move(latest_pending_subchannel_list_);
} else if (subchannel_list_ == nullptr) {
// If there is no current list, immediately promote the new list to
@ -498,7 +498,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_round_robin_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::MakeUnique<grpc_core::RoundRobinFactory>());
absl::make_unique<grpc_core::RoundRobinFactory>());
}
void grpc_lb_policy_round_robin_shutdown() {}

@ -148,7 +148,7 @@ void CdsLb::ClusterWatcher::OnClusterChanged(XdsApi::CdsUpdate cluster_data) {
LoadBalancingPolicy::Args args;
args.combiner = parent_->combiner();
args.args = parent_->args_;
args.channel_control_helper = grpc_core::MakeUnique<Helper>(parent_->Ref());
args.channel_control_helper = absl::make_unique<Helper>(parent_->Ref());
parent_->child_policy_ =
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
"xds_experimental", std::move(args));
@ -173,7 +173,7 @@ void CdsLb::ClusterWatcher::OnError(grpc_error* error) {
if (parent_->child_policy_ == nullptr) {
parent_->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
} else {
GRPC_ERROR_UNREF(error);
}
@ -273,7 +273,7 @@ void CdsLb::UpdateLocked(UpdateArgs args) {
xds_client_->CancelClusterDataWatch(
StringView(old_config->cluster().c_str()), cluster_watcher_);
}
auto watcher = grpc_core::MakeUnique<ClusterWatcher>(Ref());
auto watcher = absl::make_unique<ClusterWatcher>(Ref());
cluster_watcher_ = watcher.get();
xds_client_->WatchClusterData(StringView(config_->cluster().c_str()),
std::move(watcher));
@ -335,7 +335,7 @@ class CdsFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_cds_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::MakeUnique<grpc_core::CdsFactory>());
absl::make_unique<grpc_core::CdsFactory>());
}
void grpc_lb_policy_cds_shutdown() {}

@ -809,7 +809,7 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
xds_client()->CancelEndpointDataWatch(StringView(old_eds_service_name),
endpoint_watcher_);
}
auto watcher = grpc_core::MakeUnique<EndpointWatcher>(
auto watcher = absl::make_unique<EndpointWatcher>(
Ref(DEBUG_LOCATION, "EndpointWatcher"));
endpoint_watcher_ = watcher.get();
xds_client()->WatchEndpointData(StringView(eds_service_name()),
@ -1060,7 +1060,7 @@ void XdsLb::UpdateXdsPickerLocked() {
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(error));
absl::make_unique<TransientFailurePicker>(error));
return;
}
priorities_[current_priority_]->UpdateXdsPickerLocked();
@ -1150,7 +1150,7 @@ XdsLb::LocalityMap::LocalityMap(RefCountedPtr<XdsLb> xds_policy,
if (priority_ == 0) {
xds_policy_->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING,
grpc_core::MakeUnique<QueuePicker>(
absl::make_unique<QueuePicker>(
xds_policy_->Ref(DEBUG_LOCATION, "QueuePicker")));
}
}
@ -1225,7 +1225,7 @@ void XdsLb::LocalityMap::UpdateXdsPickerLocked() {
}
xds_policy()->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY,
grpc_core::MakeUnique<LocalityPicker>(
absl::make_unique<LocalityPicker>(
xds_policy_->Ref(DEBUG_LOCATION, "LocalityPicker"),
std::move(picker_list)));
}
@ -1870,7 +1870,7 @@ class XdsFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_xds_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::MakeUnique<grpc_core::XdsFactory>());
absl::make_unique<grpc_core::XdsFactory>());
}
void grpc_lb_policy_xds_shutdown() {}

@ -499,7 +499,7 @@ void grpc_resolver_dns_ares_init() {
}
grpc_set_resolver_impl(&ares_resolver);
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::AresDnsResolverFactory>());
absl::make_unique<grpc_core::AresDnsResolverFactory>());
} else {
g_use_ares_dns_resolver = false;
}

@ -173,7 +173,7 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory {
std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* combiner) {
return grpc_core::MakeUnique<GrpcPolledFdFactoryLibuv>();
return absl::make_unique<GrpcPolledFdFactoryLibuv>();
}
} // namespace grpc_core

@ -99,7 +99,7 @@ class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory {
std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* /*combiner*/) {
return grpc_core::MakeUnique<GrpcPolledFdFactoryPosix>();
return absl::make_unique<GrpcPolledFdFactoryPosix>();
}
} // namespace grpc_core

@ -934,7 +934,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* combiner) {
return grpc_core::MakeUnique<GrpcPolledFdFactoryWindows>(combiner);
return absl::make_unique<GrpcPolledFdFactoryWindows>(combiner);
}
} // namespace grpc_core

@ -185,7 +185,7 @@ static void on_hostbyname_done_locked(void* arg, int status, int /*timeouts*/,
"request:%p on_hostbyname_done_locked host=%s ARES_SUCCESS", r,
hr->host);
if (*r->addresses_out == nullptr) {
*r->addresses_out = grpc_core::MakeUnique<ServerAddressList>();
*r->addresses_out = absl::make_unique<ServerAddressList>();
}
ServerAddressList& addresses = **r->addresses_out;
for (size_t i = 0; hostent->h_addr_list[i] != nullptr; ++i) {
@ -480,7 +480,7 @@ static bool inner_resolve_as_ip_literal_locked(
grpc_parse_ipv6_hostport(hostport->get(), &addr,
false /* log errors */)) {
GPR_ASSERT(*addrs == nullptr);
*addrs = grpc_core::MakeUnique<ServerAddressList>();
*addrs = absl::make_unique<ServerAddressList>();
(*addrs)->emplace_back(addr.addr, addr.len, nullptr /* args */);
return true;
}
@ -543,7 +543,7 @@ static bool inner_maybe_resolve_localhost_manually_locked(
}
if (gpr_stricmp(host->get(), "localhost") == 0) {
GPR_ASSERT(*addrs == nullptr);
*addrs = grpc_core::MakeUnique<grpc_core::ServerAddressList>();
*addrs = absl::make_unique<grpc_core::ServerAddressList>();
uint16_t numeric_port = grpc_strhtons(port->get());
// Append the ipv6 loopback address.
struct sockaddr_in6 ipv6_loopback_addr;

@ -305,7 +305,7 @@ void grpc_resolver_dns_native_init() {
if (gpr_stricmp(resolver.get(), "native") == 0) {
gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::NativeDnsResolverFactory>());
absl::make_unique<grpc_core::NativeDnsResolverFactory>());
} else {
grpc_core::ResolverRegistry::Builder::InitRegistry();
grpc_core::ResolverFactory* existing_factory =
@ -313,7 +313,7 @@ void grpc_resolver_dns_native_init() {
if (existing_factory == nullptr) {
gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::NativeDnsResolverFactory>());
absl::make_unique<grpc_core::NativeDnsResolverFactory>());
}
}
}

@ -386,7 +386,7 @@ class FakeResolverFactory : public ResolverFactory {
void grpc_resolver_fake_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::FakeResolverFactory>());
absl::make_unique<grpc_core::FakeResolverFactory>());
}
void grpc_resolver_fake_shutdown() {}

@ -176,12 +176,12 @@ class UnixResolverFactory : public ResolverFactory {
void grpc_resolver_sockaddr_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::IPv4ResolverFactory>());
absl::make_unique<grpc_core::IPv4ResolverFactory>());
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::IPv6ResolverFactory>());
absl::make_unique<grpc_core::IPv6ResolverFactory>());
#ifdef GRPC_HAVE_UNIX_SOCKET
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::UnixResolverFactory>());
absl::make_unique<grpc_core::UnixResolverFactory>());
#endif
}

@ -91,7 +91,7 @@ void XdsResolver::StartLocked() {
grpc_error* error = GRPC_ERROR_NONE;
xds_client_ = MakeOrphanable<XdsClient>(
combiner(), interested_parties_, StringView(server_name_.get()),
grpc_core::MakeUnique<ServiceConfigWatcher>(Ref()), *args_, &error);
absl::make_unique<ServiceConfigWatcher>(Ref()), *args_, &error);
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR,
"Failed to create xds client -- channel will remain in "
@ -129,7 +129,7 @@ class XdsResolverFactory : public ResolverFactory {
void grpc_resolver_xds_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::MakeUnique<grpc_core::XdsResolverFactory>());
absl::make_unique<grpc_core::XdsResolverFactory>());
}
void grpc_resolver_xds_shutdown() {}

@ -54,7 +54,7 @@ size_t ClientChannelServiceConfigParser::ParserIndex() {
void ClientChannelServiceConfigParser::Register() {
g_client_channel_service_config_parser_index = ServiceConfig::RegisterParser(
grpc_core::MakeUnique<ClientChannelServiceConfigParser>());
absl::make_unique<ClientChannelServiceConfigParser>());
}
namespace {
@ -95,7 +95,7 @@ std::unique_ptr<ClientChannelMethodParsedConfig::RetryPolicy> ParseRetryPolicy(
const Json& json, grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
auto retry_policy =
grpc_core::MakeUnique<ClientChannelMethodParsedConfig::RetryPolicy>();
absl::make_unique<ClientChannelMethodParsedConfig::RetryPolicy>();
if (json.type() != Json::Type::OBJECT) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:retryPolicy error:should be of type object");
@ -387,7 +387,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const Json& json,
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel global parser",
&error_list);
if (*error == GRPC_ERROR_NONE) {
return grpc_core::MakeUnique<ClientChannelGlobalParsedConfig>(
return absl::make_unique<ClientChannelGlobalParsedConfig>(
std::move(parsed_lb_config), std::move(lb_policy_name),
retry_throttling, health_check_service_name);
}
@ -433,7 +433,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const Json& json,
}
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list);
if (*error == GRPC_ERROR_NONE) {
return grpc_core::MakeUnique<ClientChannelMethodParsedConfig>(
return absl::make_unique<ClientChannelMethodParsedConfig>(
timeout, wait_for_ready, std::move(retry_policy));
}
return nullptr;

@ -188,15 +188,15 @@ ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
GPR_ASSERT(process_resolver_result != nullptr);
resolver_ = ResolverRegistry::CreateResolver(
target_uri_.get(), args.args, interested_parties(), combiner(),
grpc_core::MakeUnique<ResolverResultHandler>(Ref()));
absl::make_unique<ResolverResultHandler>(Ref()));
// Since the validity of args has been checked when create the channel,
// CreateResolver() must return a non-null result.
GPR_ASSERT(resolver_ != nullptr);
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this);
}
channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, grpc_core::MakeUnique<QueuePicker>(Ref()));
channel_control_helper()->UpdateState(GRPC_CHANNEL_CONNECTING,
absl::make_unique<QueuePicker>(Ref()));
resolver_->StartLocked();
}
@ -262,7 +262,7 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) {
"Resolver transient failure", &error, 1);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_core::MakeUnique<TransientFailurePicker>(state_error));
absl::make_unique<TransientFailurePicker>(state_error));
}
GRPC_ERROR_UNREF(error);
}

@ -95,7 +95,7 @@ grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigVectorTable(
const Json& json,
InlinedVector<SliceHashTable<const ParsedConfigVector*>::Entry, 10>*
entries) {
auto objs_vector = grpc_core::MakeUnique<ParsedConfigVector>();
auto objs_vector = absl::make_unique<ParsedConfigVector>();
InlinedVector<grpc_error*, 4> error_list;
for (size_t i = 0; i < g_registered_parsers->size(); i++) {
grpc_error* parser_error = GRPC_ERROR_NONE;

@ -42,7 +42,7 @@ std::unique_ptr<XdsBootstrap> XdsBootstrap::ReadFromFile(grpc_error** error) {
Json json = Json::Parse(StringViewFromSlice(contents), error);
grpc_slice_unref_internal(contents);
if (*error != GRPC_ERROR_NONE) return nullptr;
return grpc_core::MakeUnique<XdsBootstrap>(std::move(json), error);
return absl::make_unique<XdsBootstrap>(std::move(json), error);
}
XdsBootstrap::XdsBootstrap(Json json, grpc_error** error) {
@ -192,7 +192,7 @@ grpc_error* XdsBootstrap::ParseChannelCreds(Json* json, size_t idx,
grpc_error* XdsBootstrap::ParseNode(Json* json) {
InlinedVector<grpc_error*, 1> error_list;
node_ = grpc_core::MakeUnique<Node>();
node_ = absl::make_unique<Node>();
auto it = json->mutable_object()->find("id");
if (it != json->mutable_object()->end()) {
if (it->second.type() != Json::Type::STRING) {

@ -86,13 +86,13 @@ MessageSizeParser::ParsePerMethodParams(const Json& json, grpc_error** error) {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Message size parser", &error_list);
return nullptr;
}
return grpc_core::MakeUnique<MessageSizeParsedConfig>(
max_request_message_bytes, max_response_message_bytes);
return absl::make_unique<MessageSizeParsedConfig>(max_request_message_bytes,
max_response_message_bytes);
}
void MessageSizeParser::Register() {
g_message_size_parser_index =
ServiceConfig::RegisterParser(grpc_core::MakeUnique<MessageSizeParser>());
ServiceConfig::RegisterParser(absl::make_unique<MessageSizeParser>());
}
size_t MessageSizeParser::ParserIndex() { return g_message_size_parser_index; }

@ -28,6 +28,8 @@
#include <memory>
#include <utility>
#include "absl/memory/memory.h"
namespace grpc_core {
class DefaultDeleteChar {
@ -44,12 +46,6 @@ class DefaultDeleteChar {
template <typename T>
using UniquePtr = std::unique_ptr<T, DefaultDeleteChar>;
// TODO(veblush): Replace this with absl::make_unique once abseil is added.
template <typename T, typename... Args>
inline std::unique_ptr<T> MakeUnique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_MEMORY_H */

@ -559,10 +559,10 @@ RefCountedPtr<Handshaker> SecurityHandshakerCreate(
void SecurityRegisterHandshakerFactories() {
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_CLIENT,
grpc_core::MakeUnique<ClientSecurityHandshakerFactory>());
absl::make_unique<ClientSecurityHandshakerFactory>());
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_SERVER,
grpc_core::MakeUnique<ServerSecurityHandshakerFactory>());
absl::make_unique<ServerSecurityHandshakerFactory>());
}
} // namespace grpc_core

@ -49,7 +49,7 @@ class BoringSslCachedSession : public SslCachedSession {
std::unique_ptr<SslCachedSession> SslCachedSession::Create(
SslSessionPtr session) {
return grpc_core::MakeUnique<BoringSslCachedSession>(std::move(session));
return absl::make_unique<BoringSslCachedSession>(std::move(session));
}
} // namespace tsi

@ -67,7 +67,7 @@ class OpenSslCachedSession : public SslCachedSession {
std::unique_ptr<SslCachedSession> SslCachedSession::Create(
SslSessionPtr session) {
return grpc_core::MakeUnique<OpenSslCachedSession>(std::move(session));
return absl::make_unique<OpenSslCachedSession>(std::move(session));
}
} // namespace tsi

@ -53,7 +53,7 @@ std::unique_ptr<AltsContext> GetAltsContextFromAuthContext(
gpr_log(GPR_ERROR, "security_level is invalid.");
return nullptr;
}
return grpc_core::MakeUnique<AltsContext>(AltsContext(ctx));
return absl::make_unique<AltsContext>(AltsContext(ctx));
}
grpc::Status AltsClientAuthzCheck(

@ -481,8 +481,8 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsUuidAfterCompaction) {
// these will delete and unregister themselves after this block.
std::vector<std::unique_ptr<ChannelFixture>> odd_channels;
for (int i = 0; i < kLoopIterations; i++) {
odd_channels.push_back(grpc_core::MakeUnique<ChannelFixture>());
even_channels.push_back(grpc_core::MakeUnique<ChannelFixture>());
odd_channels.push_back(absl::make_unique<ChannelFixture>());
even_channels.push_back(absl::make_unique<ChannelFixture>());
}
}
std::string json_str = ChannelzRegistry::GetTopChannels(0);

@ -75,7 +75,7 @@ static grpc_ares_request* my_dns_lookup_ares_locked(
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
gpr_mu_unlock(&g_mu);
*addresses = grpc_core::MakeUnique<grpc_core::ServerAddressList>();
*addresses = absl::make_unique<grpc_core::ServerAddressList>();
grpc_resolved_address dummy_resolved_address;
memset(&dummy_resolved_address, 0, sizeof(dummy_resolved_address));
dummy_resolved_address.len = 123;

@ -45,7 +45,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
args.result_handler = absl::make_unique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver != nullptr);
@ -62,7 +62,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
args.result_handler = absl::make_unique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver == nullptr);

@ -47,7 +47,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
args.result_handler = absl::make_unique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver != nullptr);
@ -68,7 +68,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
args.result_handler = absl::make_unique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver == nullptr);

@ -59,7 +59,7 @@ class TestParser1 : public ServiceConfig::Parser {
GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage());
return nullptr;
}
return grpc_core::MakeUnique<TestParsedConfig1>(value);
return absl::make_unique<TestParsedConfig1>(value);
}
return nullptr;
}
@ -91,7 +91,7 @@ class TestParser2 : public ServiceConfig::Parser {
GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage());
return nullptr;
}
return grpc_core::MakeUnique<TestParsedConfig1>(value);
return absl::make_unique<TestParsedConfig1>(value);
}
return nullptr;
}
@ -139,10 +139,10 @@ class ServiceConfigTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<TestParser1>()) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<TestParser2>()) == 1);
EXPECT_TRUE(
ServiceConfig::RegisterParser(absl::make_unique<TestParser1>()) == 0);
EXPECT_TRUE(
ServiceConfig::RegisterParser(absl::make_unique<TestParser2>()) == 1);
}
};
@ -301,10 +301,10 @@ class ErroredParsersScopingTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<ErrorParser>()) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<ErrorParser>()) == 1);
EXPECT_TRUE(
ServiceConfig::RegisterParser(absl::make_unique<ErrorParser>()) == 0);
EXPECT_TRUE(
ServiceConfig::RegisterParser(absl::make_unique<ErrorParser>()) == 1);
}
};
@ -346,9 +346,10 @@ class ClientChannelParserTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<
internal::ClientChannelServiceConfigParser>()) == 0);
EXPECT_TRUE(
ServiceConfig::RegisterParser(
absl::make_unique<internal::ClientChannelServiceConfigParser>()) ==
0);
}
};
@ -915,7 +916,7 @@ class MessageSizeParserTest : public ::testing::Test {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
grpc_core::MakeUnique<MessageSizeParser>()) == 0);
absl::make_unique<MessageSizeParser>()) == 0);
}
};

File diff suppressed because it is too large Load Diff

@ -119,7 +119,7 @@ static grpc_ares_request* my_dns_lookup_ares_locked(
gpr_mu_unlock(&g_mu);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
*addresses = grpc_core::MakeUnique<grpc_core::ServerAddressList>();
*addresses = absl::make_unique<grpc_core::ServerAddressList>();
grpc_sockaddr_in sa;
sa.sin_family = GRPC_AF_INET;
sa.sin_addr.s_addr = 0x100007f;

@ -63,7 +63,7 @@ TEST(InlinedVectorTest, ValuesAreInlined) {
TEST(InlinedVectorTest, PushBackWithMove) {
InlinedVector<std::unique_ptr<int>, 1> v;
std::unique_ptr<int> i = grpc_core::MakeUnique<int>(3);
std::unique_ptr<int> i = absl::make_unique<int>(3);
v.push_back(std::move(i));
EXPECT_EQ(nullptr, i.get());
EXPECT_EQ(1UL, v.size());
@ -304,15 +304,15 @@ TEST(InlinedVectorTest, MoveAssignmentAllocatedAllocated) {
// and move methods are called correctly.
class Value {
public:
explicit Value(int v) : value_(grpc_core::MakeUnique<int>(v)) {}
explicit Value(int v) : value_(absl::make_unique<int>(v)) {}
// copyable
Value(const Value& v) {
value_ = grpc_core::MakeUnique<int>(*v.value_);
value_ = absl::make_unique<int>(*v.value_);
copied_ = true;
}
Value& operator=(const Value& v) {
value_ = grpc_core::MakeUnique<int>(*v.value_);
value_ = absl::make_unique<int>(*v.value_);
copied_ = true;
return *this;
}
@ -463,10 +463,10 @@ TEST(InlinedVectorTest, MoveAssignmentMovesElementsAllocated) {
TEST(InlinedVectorTest, PopBackInlined) {
InlinedVector<std::unique_ptr<int>, 2> v;
// Add two elements, pop one out
v.push_back(grpc_core::MakeUnique<int>(3));
v.push_back(absl::make_unique<int>(3));
EXPECT_EQ(1UL, v.size());
EXPECT_EQ(3, *v[0]);
v.push_back(grpc_core::MakeUnique<int>(5));
v.push_back(absl::make_unique<int>(5));
EXPECT_EQ(2UL, v.size());
EXPECT_EQ(5, *v[1]);
v.pop_back();
@ -478,7 +478,7 @@ TEST(InlinedVectorTest, PopBackAllocated) {
InlinedVector<std::unique_ptr<int>, kInlinedSize> v;
// Add elements to ensure allocated backing.
for (size_t i = 0; i < kInlinedSize + 1; ++i) {
v.push_back(grpc_core::MakeUnique<int>(3));
v.push_back(absl::make_unique<int>(3));
EXPECT_EQ(i + 1, v.size());
}
size_t sz = v.size();
@ -494,7 +494,7 @@ TEST(InlinedVectorTest, Resize) {
EXPECT_EQ(5UL, v.size());
EXPECT_EQ(nullptr, v[4]);
// Size down.
v[4] = grpc_core::MakeUnique<int>(5);
v[4] = absl::make_unique<int>(5);
v.resize(1);
EXPECT_EQ(1UL, v.size());
}

@ -81,7 +81,7 @@ int main(int /*argc*/, char* /*argv*/ []) {
grpc_init();
HandshakerRegistry::RegisterHandshakerFactory(
true /* at_start */, HANDSHAKER_SERVER,
grpc_core::MakeUnique<ReadAheadHandshakerFactory>());
absl::make_unique<ReadAheadHandshakerFactory>());
const char* full_alpn_list[] = {"grpc-exp", "h2"};
GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
grpc_shutdown_blocking();

Loading…
Cancel
Save