aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/transport/chttp2
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-12-09 14:03:58 -0800
committerGravatar Mark D. Roth <roth@google.com>2016-12-09 14:03:58 -0800
commitc217e490b176669bf93c04e772218d88b5fef764 (patch)
treed4b1bcfa4e464e8da9f4fab1f7dd55ac1d93cc78 /src/core/ext/transport/chttp2
parent389f272b49940a66e2f7876416c375754d67e571 (diff)
Add function to create channel arg for client channel factory.
Diffstat (limited to 'src/core/ext/transport/chttp2')
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.c18
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.c27
2 files changed, 2 insertions, 43 deletions
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,