Convert resolver API to C++.
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index 6b93644..a4dcd52 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -165,7 +165,7 @@
typedef struct client_channel_channel_data {
/** resolver for this channel */
- grpc_resolver* resolver;
+ grpc_core::OrphanablePtr<grpc_core::Resolver> resolver;
/** have we started resolving this channel */
bool started_resolving;
/** is deadline checking enabled? */
@@ -300,8 +300,8 @@
GPR_ASSERT(!chand->started_resolving);
chand->started_resolving = true;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
- grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
- &chand->on_resolver_result_changed);
+ chand->resolver->NextLocked(&chand->resolver_result,
+ &chand->on_resolver_result_changed);
}
typedef struct {
@@ -378,7 +378,7 @@
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: started name re-resolving", chand);
}
- grpc_resolver_channel_saw_error_locked(chand->resolver);
+ chand->resolver->RequestReresolutionLocked();
// Give back the closure to the LB policy.
grpc_lb_policy_set_reresolve_closure_locked(chand->lb_policy, &args->closure);
}
@@ -568,9 +568,7 @@
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
}
- grpc_resolver_shutdown_locked(chand->resolver);
- GRPC_RESOLVER_UNREF(chand->resolver, "channel");
- chand->resolver = nullptr;
+ chand->resolver.reset();
}
set_channel_connectivity_state_locked(
chand, GRPC_CHANNEL_SHUTDOWN,
@@ -606,8 +604,8 @@
set_channel_connectivity_state_locked(
chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver");
}
- grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
- &chand->on_resolver_result_changed);
+ chand->resolver->NextLocked(&chand->resolver_result,
+ &chand->on_resolver_result_changed);
GRPC_ERROR_UNREF(state_error);
}
}
@@ -648,9 +646,7 @@
set_channel_connectivity_state_locked(
chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
- grpc_resolver_shutdown_locked(chand->resolver);
- GRPC_RESOLVER_UNREF(chand->resolver, "channel");
- chand->resolver = nullptr;
+ chand->resolver.reset();
if (!chand->started_resolving) {
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_REF(op->disconnect_with_error));
@@ -759,7 +755,7 @@
grpc_proxy_mappers_map_name(arg->value.string, args->channel_args,
&proxy_name, &new_args);
// Instantiate resolver.
- chand->resolver = grpc_resolver_create(
+ chand->resolver = grpc_core::ResolverRegistry::CreateResolver(
proxy_name != nullptr ? proxy_name : arg->value.string,
new_args != nullptr ? new_args : args->channel_args,
chand->interested_parties, chand->combiner);
@@ -774,9 +770,8 @@
}
static void shutdown_resolver_locked(void* arg, grpc_error* error) {
- grpc_resolver* resolver = (grpc_resolver*)arg;
- grpc_resolver_shutdown_locked(resolver);
- GRPC_RESOLVER_UNREF(resolver, "channel");
+ grpc_core::Resolver* resolver = static_cast<grpc_core::Resolver*>(arg);
+ resolver->Orphan();
}
/* Destructor for channel_data */
@@ -784,7 +779,7 @@
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->resolver != nullptr) {
GRPC_CLOSURE_SCHED(
- GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
+ GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver.release(),
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}