From c217e490b176669bf93c04e772218d88b5fef764 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 9 Dec 2016 14:03:58 -0800 Subject: Add function to create channel arg for client channel factory. --- .../chttp2/client/insecure/channel_create.c | 18 +-------------- .../chttp2/client/secure/secure_channel_create.c | 27 +--------------------- 2 files changed, 2 insertions(+), 43 deletions(-) (limited to 'src/core/ext/transport/chttp2') diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c index 3ad34b0870..1e1bed10dc 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -76,19 +76,6 @@ static const grpc_client_channel_factory_vtable client_channel_factory_vtable = static grpc_client_channel_factory client_channel_factory = { &client_channel_factory_vtable}; -static void *cc_factory_arg_copy(void *cc_factory) { return cc_factory; } - -static void cc_factory_arg_destroy(void *cc_factory) {} - -static int cc_factory_arg_cmp(void *cc_factory1, void *cc_factory2) { - if (cc_factory1 < cc_factory2) return -1; - if (cc_factory1 > cc_factory2) return 1; - return 0; -} - -static const grpc_arg_pointer_vtable cc_factory_arg_vtable = { - cc_factory_arg_copy, cc_factory_arg_destroy, cc_factory_arg_cmp}; - /* Create a client channel: Asynchronously: - resolve target - connect to it (trying alternatives as presented) @@ -108,10 +95,7 @@ grpc_channel *grpc_insecure_channel_create(const char *target, new_args[0].type = GRPC_ARG_STRING; new_args[0].key = GRPC_ARG_SERVER_URI; new_args[0].value.string = (char *)target; - new_args[1].type = GRPC_ARG_POINTER; - new_args[1].key = GRPC_ARG_CLIENT_CHANNEL_FACTORY; - new_args[1].value.pointer.p = factory; - new_args[1].value.pointer.vtable = &cc_factory_arg_vtable; + new_args[1] = grpc_client_channel_factory_create_channel_arg(factory); grpc_channel_args *args_copy = grpc_channel_args_copy_and_add(args, new_args, GPR_ARRAY_SIZE(new_args)); // Create channel. diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c index 2bef684398..2474f544cf 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c @@ -97,28 +97,6 @@ static const grpc_client_channel_factory_vtable client_channel_factory_vtable = client_channel_factory_create_subchannel, client_channel_factory_create_channel}; -static void *cc_factory_arg_copy(void *cc_factory) { - client_channel_factory_ref(cc_factory); - return cc_factory; -} - -static void cc_factory_arg_destroy(void *cc_factory) { - // TODO(roth): remove local exec_ctx when - // https://github.com/grpc/grpc/pull/8705 is merged - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - client_channel_factory_unref(&exec_ctx, cc_factory); - grpc_exec_ctx_finish(&exec_ctx); -} - -static int cc_factory_arg_cmp(void *cc_factory1, void *cc_factory2) { - if (cc_factory1 < cc_factory2) return -1; - if (cc_factory1 > cc_factory2) return 1; - return 0; -} - -static const grpc_arg_pointer_vtable cc_factory_arg_vtable = { - cc_factory_arg_copy, cc_factory_arg_destroy, cc_factory_arg_cmp}; - /* Create a secure client channel: Asynchronously: - resolve target - connect to it (trying alternatives as presented) @@ -165,10 +143,7 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds, new_args[0].type = GRPC_ARG_STRING; new_args[0].key = GRPC_ARG_SERVER_URI; new_args[0].value.string = (char *)target; - new_args[1].type = GRPC_ARG_POINTER; - new_args[1].key = GRPC_ARG_CLIENT_CHANNEL_FACTORY; - new_args[1].value.pointer.p = f; - new_args[1].value.pointer.vtable = &cc_factory_arg_vtable; + new_args[1] = grpc_client_channel_factory_create_channel_arg(&f->base); new_args[2] = grpc_security_connector_to_arg(&security_connector->base); grpc_channel_args *args_copy = grpc_channel_args_copy_and_add( new_args_from_connector != NULL ? new_args_from_connector : args, -- cgit v1.2.3