diff options
author | 2015-06-01 11:31:08 -0700 | |
---|---|---|
committer | 2015-06-01 11:31:08 -0700 | |
commit | a0abe37367755b4256f8591e3ef4ba3600a4f636 (patch) | |
tree | baab44e5c7977751a0b248f8a10b5b274f18320c /src/core/httpcli/httpcli.c | |
parent | fe020aa06045c14b5e9cf26c2ea5fd0dd1c55c2d (diff) |
Rephrase integration for httpcli
Diffstat (limited to 'src/core/httpcli/httpcli.c')
-rw-r--r-- | src/core/httpcli/httpcli.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c index 7c8c80d162..53ec070900 100644 --- a/src/core/httpcli/httpcli.c +++ b/src/core/httpcli/httpcli.c @@ -59,12 +59,24 @@ typedef struct { int use_ssl; grpc_httpcli_response_cb on_response; void *user_data; - grpc_pollset_set *interested_parties; + grpc_httpcli_context *context; } internal_request; static grpc_httpcli_get_override g_get_override = NULL; static grpc_httpcli_post_override g_post_override = NULL; +void grpc_httpcli_context_init(grpc_httpcli_context *context) { + grpc_pollset_set_init(&context->pollset_set); +} + +void grpc_httpcli_context_destroy(grpc_httpcli_context *context) { + grpc_pollset_set_destroy(&context->pollset_set); +} + +void grpc_httpcli_context_add_interested_party(grpc_httpcli_context *context, grpc_pollset *pollset) { + grpc_pollset_set_add_pollset(&context->pollset_set, pollset); +} + static void next_address(internal_request *req); static void finish(internal_request *req, int success) { @@ -198,7 +210,7 @@ static void next_address(internal_request *req) { return; } addr = &req->addresses->addrs[req->next_address++]; - grpc_tcp_client_connect(on_connected, req, req->interested_parties, + grpc_tcp_client_connect(on_connected, req, &req->context->pollset_set, (struct sockaddr *)&addr->addr, addr->len, req->deadline); } @@ -214,9 +226,9 @@ static void on_resolved(void *arg, grpc_resolved_addresses *addresses) { next_address(req); } -void grpc_httpcli_get(const grpc_httpcli_request *request, +void grpc_httpcli_get(grpc_httpcli_context *context, + const grpc_httpcli_request *request, gpr_timespec deadline, - grpc_pollset_set *interested_parties, grpc_httpcli_response_cb on_response, void *user_data) { internal_request *req; if (g_get_override && @@ -231,7 +243,7 @@ void grpc_httpcli_get(const grpc_httpcli_request *request, req->user_data = user_data; req->deadline = deadline; req->use_ssl = request->use_ssl; - req->interested_parties = interested_parties; + req->context = context; if (req->use_ssl) { req->host = gpr_strdup(request->host); } @@ -240,10 +252,10 @@ void grpc_httpcli_get(const grpc_httpcli_request *request, on_resolved, req); } -void grpc_httpcli_post(const grpc_httpcli_request *request, +void grpc_httpcli_post(grpc_httpcli_context *context, + const grpc_httpcli_request *request, const char *body_bytes, size_t body_size, gpr_timespec deadline, - grpc_pollset_set *interested_parties, grpc_httpcli_response_cb on_response, void *user_data) { internal_request *req; if (g_post_override && g_post_override(request, body_bytes, body_size, @@ -259,7 +271,7 @@ void grpc_httpcli_post(const grpc_httpcli_request *request, req->user_data = user_data; req->deadline = deadline; req->use_ssl = request->use_ssl; - req->interested_parties = interested_parties; + req->context = context; if (req->use_ssl) { req->host = gpr_strdup(request->host); } |