|  | @@ -44,8 +44,8 @@
 | 
	
		
			
				|  |  |  #include <grpc/support/useful.h>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #include "src/core/ext/client_channel/http_connect_handshaker.h"
 | 
	
		
			
				|  |  | -#include "src/core/ext/client_channel/http_proxy.h"
 | 
	
		
			
				|  |  |  #include "src/core/ext/client_channel/lb_policy_registry.h"
 | 
	
		
			
				|  |  | +#include "src/core/ext/client_channel/proxy_mapper_registry.h"
 | 
	
		
			
				|  |  |  #include "src/core/ext/client_channel/resolver_registry.h"
 | 
	
		
			
				|  |  |  #include "src/core/ext/client_channel/subchannel.h"
 | 
	
		
			
				|  |  |  #include "src/core/lib/channel/channel_args.h"
 | 
	
	
		
			
				|  | @@ -153,10 +153,6 @@ static void *method_parameters_create_from_json(const grpc_json *json) {
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  typedef struct client_channel_channel_data {
 | 
	
		
			
				|  |  | -  /** server name */
 | 
	
		
			
				|  |  | -  char *server_name;
 | 
	
		
			
				|  |  | -  /** HTTP CONNECT proxy to use, if any */
 | 
	
		
			
				|  |  | -  char *proxy_name;
 | 
	
		
			
				|  |  |    /** resolver for this channel */
 | 
	
		
			
				|  |  |    grpc_resolver *resolver;
 | 
	
		
			
				|  |  |    /** have we started resolving this channel */
 | 
	
	
		
			
				|  | @@ -317,17 +313,6 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg,
 | 
	
		
			
				|  |  |      // Use pick_first if nothing was specified and we didn't select grpclb
 | 
	
		
			
				|  |  |      // above.
 | 
	
		
			
				|  |  |      if (lb_policy_name == NULL) lb_policy_name = "pick_first";
 | 
	
		
			
				|  |  | -    // If using a proxy, add channel arg for server in HTTP CONNECT request.
 | 
	
		
			
				|  |  | -    if (chand->proxy_name != NULL) {
 | 
	
		
			
				|  |  | -      grpc_arg new_arg;
 | 
	
		
			
				|  |  | -      new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
 | 
	
		
			
				|  |  | -      new_arg.type = GRPC_ARG_STRING;
 | 
	
		
			
				|  |  | -      new_arg.value.string = chand->server_name;
 | 
	
		
			
				|  |  | -      grpc_channel_args *tmp_args = chand->resolver_result;
 | 
	
		
			
				|  |  | -      chand->resolver_result =
 | 
	
		
			
				|  |  | -          grpc_channel_args_copy_and_add(chand->resolver_result, &new_arg, 1);
 | 
	
		
			
				|  |  | -      grpc_channel_args_destroy(exec_ctx, tmp_args);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |      // Instantiate LB policy.
 | 
	
		
			
				|  |  |      grpc_lb_policy_args lb_policy_args;
 | 
	
		
			
				|  |  |      lb_policy_args.args = chand->resolver_result;
 | 
	
	
		
			
				|  | @@ -542,24 +527,21 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
 | 
	
		
			
				|  |  |    GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
 | 
	
		
			
				|  |  |    grpc_client_channel_factory_ref(arg->value.pointer.p);
 | 
	
		
			
				|  |  |    chand->client_channel_factory = arg->value.pointer.p;
 | 
	
		
			
				|  |  | -  // Instantiate resolver.
 | 
	
		
			
				|  |  | +  // Get server name to resolve, using proxy mapper if needed.
 | 
	
		
			
				|  |  |    arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
 | 
	
		
			
				|  |  |    GPR_ASSERT(arg != NULL);
 | 
	
		
			
				|  |  |    GPR_ASSERT(arg->type == GRPC_ARG_STRING);
 | 
	
		
			
				|  |  | -  grpc_uri *uri = grpc_uri_parse(arg->value.string, true);
 | 
	
		
			
				|  |  | -  if (uri == NULL) return GRPC_ERROR_CREATE("cannot parse server URI");
 | 
	
		
			
				|  |  | -  if (uri->path[0] == '\0') {
 | 
	
		
			
				|  |  | -    grpc_uri_destroy(uri);
 | 
	
		
			
				|  |  | -    return GRPC_ERROR_CREATE("server URI is missing path");
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -  chand->server_name =
 | 
	
		
			
				|  |  | -      gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
 | 
	
		
			
				|  |  | -  grpc_uri_destroy(uri);
 | 
	
		
			
				|  |  | -  chand->proxy_name = grpc_get_http_proxy_server();
 | 
	
		
			
				|  |  | -  char *name_to_resolve =
 | 
	
		
			
				|  |  | -      chand->proxy_name == NULL ? arg->value.string : chand->proxy_name;
 | 
	
		
			
				|  |  | +  char *proxy_name = NULL;
 | 
	
		
			
				|  |  | +  grpc_channel_args *new_args = NULL;
 | 
	
		
			
				|  |  | +  grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
 | 
	
		
			
				|  |  | +                              &proxy_name, &new_args);
 | 
	
		
			
				|  |  | +  // Instantiate resolver.
 | 
	
		
			
				|  |  |    chand->resolver = grpc_resolver_create(
 | 
	
		
			
				|  |  | -      exec_ctx, name_to_resolve, args->channel_args, chand->interested_parties);
 | 
	
		
			
				|  |  | +      exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
 | 
	
		
			
				|  |  | +      new_args != NULL ? new_args : args->channel_args,
 | 
	
		
			
				|  |  | +      chand->interested_parties);
 | 
	
		
			
				|  |  | +  if (proxy_name != NULL) gpr_free(proxy_name);
 | 
	
		
			
				|  |  | +  if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
 | 
	
		
			
				|  |  |    if (chand->resolver == NULL) {
 | 
	
		
			
				|  |  |      return GRPC_ERROR_CREATE("resolver creation failed");
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -570,8 +552,6 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
 | 
	
		
			
				|  |  |  static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
 | 
	
		
			
				|  |  |                                      grpc_channel_element *elem) {
 | 
	
		
			
				|  |  |    channel_data *chand = elem->channel_data;
 | 
	
		
			
				|  |  | -  gpr_free(chand->server_name);
 | 
	
		
			
				|  |  | -  gpr_free(chand->proxy_name);
 | 
	
		
			
				|  |  |    if (chand->resolver != NULL) {
 | 
	
		
			
				|  |  |      grpc_resolver_shutdown(exec_ctx, chand->resolver);
 | 
	
		
			
				|  |  |      GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
 |