|  | @@ -371,6 +371,12 @@ XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  namespace {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// Works for both std::string and absl::string_view.
 | 
	
		
			
				|  |  | +template <typename T>
 | 
	
		
			
				|  |  | +inline upb_strview StdStringToUpbString(const T& str) {
 | 
	
		
			
				|  |  | +  return upb_strview_make(str.data(), str.size());
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
 | 
	
		
			
				|  |  |                             const Json& value);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -388,7 +394,7 @@ void PopulateMetadata(upb_arena* arena, google_protobuf_Struct* metadata_pb,
 | 
	
		
			
				|  |  |      google_protobuf_Value* value = google_protobuf_Value_new(arena);
 | 
	
		
			
				|  |  |      PopulateMetadataValue(arena, value, p.second);
 | 
	
		
			
				|  |  |      google_protobuf_Struct_fields_set(
 | 
	
		
			
				|  |  | -        metadata_pb, upb_strview_makez(p.first.c_str()), value, arena);
 | 
	
		
			
				|  |  | +        metadata_pb, StdStringToUpbString(p.first), value, arena);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -404,7 +410,7 @@ void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
 | 
	
		
			
				|  |  |        break;
 | 
	
		
			
				|  |  |      case Json::Type::STRING:
 | 
	
		
			
				|  |  |        google_protobuf_Value_set_string_value(
 | 
	
		
			
				|  |  | -          value_pb, upb_strview_makez(value.string_value().c_str()));
 | 
	
		
			
				|  |  | +          value_pb, StdStringToUpbString(value.string_value()));
 | 
	
		
			
				|  |  |        break;
 | 
	
		
			
				|  |  |      case Json::Type::JSON_TRUE:
 | 
	
		
			
				|  |  |        google_protobuf_Value_set_bool_value(value_pb, true);
 | 
	
	
		
			
				|  | @@ -468,11 +474,11 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
 | 
	
		
			
				|  |  |    if (node != nullptr) {
 | 
	
		
			
				|  |  |      if (!node->id.empty()) {
 | 
	
		
			
				|  |  |        envoy_config_core_v3_Node_set_id(node_msg,
 | 
	
		
			
				|  |  | -                                       upb_strview_makez(node->id.c_str()));
 | 
	
		
			
				|  |  | +                                       StdStringToUpbString(node->id));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!node->cluster.empty()) {
 | 
	
		
			
				|  |  |        envoy_config_core_v3_Node_set_cluster(
 | 
	
		
			
				|  |  | -          node_msg, upb_strview_makez(node->cluster.c_str()));
 | 
	
		
			
				|  |  | +          node_msg, StdStringToUpbString(node->cluster));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!node->metadata.object_value().empty()) {
 | 
	
		
			
				|  |  |        google_protobuf_Struct* metadata =
 | 
	
	
		
			
				|  | @@ -483,8 +489,8 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
 | 
	
		
			
				|  |  |        google_protobuf_Struct* metadata =
 | 
	
		
			
				|  |  |            envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
 | 
	
		
			
				|  |  |        google_protobuf_Value* value = google_protobuf_Value_new(arena);
 | 
	
		
			
				|  |  | -      google_protobuf_Value_set_string_value(
 | 
	
		
			
				|  |  | -          value, upb_strview_make(server_name.data(), server_name.size()));
 | 
	
		
			
				|  |  | +      google_protobuf_Value_set_string_value(value,
 | 
	
		
			
				|  |  | +                                             StdStringToUpbString(server_name));
 | 
	
		
			
				|  |  |        google_protobuf_Struct_fields_set(
 | 
	
		
			
				|  |  |            metadata, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"), value,
 | 
	
		
			
				|  |  |            arena);
 | 
	
	
		
			
				|  | @@ -495,15 +501,15 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
 | 
	
		
			
				|  |  |            envoy_config_core_v3_Node_mutable_locality(node_msg, arena);
 | 
	
		
			
				|  |  |        if (!node->locality_region.empty()) {
 | 
	
		
			
				|  |  |          envoy_config_core_v3_Locality_set_region(
 | 
	
		
			
				|  |  | -            locality, upb_strview_makez(node->locality_region.c_str()));
 | 
	
		
			
				|  |  | +            locality, StdStringToUpbString(node->locality_region));
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        if (!node->locality_zone.empty()) {
 | 
	
		
			
				|  |  |          envoy_config_core_v3_Locality_set_zone(
 | 
	
		
			
				|  |  | -            locality, upb_strview_makez(node->locality_zone.c_str()));
 | 
	
		
			
				|  |  | +            locality, StdStringToUpbString(node->locality_zone));
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        if (!node->locality_subzone.empty()) {
 | 
	
		
			
				|  |  |          envoy_config_core_v3_Locality_set_sub_zone(
 | 
	
		
			
				|  |  | -            locality, upb_strview_makez(node->locality_subzone.c_str()));
 | 
	
		
			
				|  |  | +            locality, StdStringToUpbString(node->locality_subzone));
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -511,8 +517,7 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
 | 
	
		
			
				|  |  |      PopulateBuildVersion(arena, node_msg, build_version);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    envoy_config_core_v3_Node_set_user_agent_name(
 | 
	
		
			
				|  |  | -      node_msg,
 | 
	
		
			
				|  |  | -      upb_strview_make(user_agent_name.data(), user_agent_name.size()));
 | 
	
		
			
				|  |  | +      node_msg, StdStringToUpbString(user_agent_name));
 | 
	
		
			
				|  |  |    envoy_config_core_v3_Node_set_user_agent_version(
 | 
	
		
			
				|  |  |        node_msg, upb_strview_makez(grpc_version_string()));
 | 
	
		
			
				|  |  |    envoy_config_core_v3_Node_add_client_features(
 | 
	
	
		
			
				|  | @@ -739,16 +744,16 @@ grpc_slice XdsApi::CreateAdsRequest(
 | 
	
		
			
				|  |  |    absl::string_view real_type_url =
 | 
	
		
			
				|  |  |        TypeUrlExternalToInternal(use_v3_, type_url);
 | 
	
		
			
				|  |  |    envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
 | 
	
		
			
				|  |  | -      request, upb_strview_make(real_type_url.data(), real_type_url.size()));
 | 
	
		
			
				|  |  | +      request, StdStringToUpbString(real_type_url));
 | 
	
		
			
				|  |  |    // Set version_info.
 | 
	
		
			
				|  |  |    if (!version.empty()) {
 | 
	
		
			
				|  |  |      envoy_service_discovery_v3_DiscoveryRequest_set_version_info(
 | 
	
		
			
				|  |  | -        request, upb_strview_make(version.data(), version.size()));
 | 
	
		
			
				|  |  | +        request, StdStringToUpbString(version));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Set nonce.
 | 
	
		
			
				|  |  |    if (!nonce.empty()) {
 | 
	
		
			
				|  |  |      envoy_service_discovery_v3_DiscoveryRequest_set_response_nonce(
 | 
	
		
			
				|  |  | -        request, upb_strview_make(nonce.data(), nonce.size()));
 | 
	
		
			
				|  |  | +        request, StdStringToUpbString(nonce));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Set error_detail if it's a NACK.
 | 
	
		
			
				|  |  |    if (error != GRPC_ERROR_NONE) {
 | 
	
	
		
			
				|  | @@ -776,8 +781,7 @@ grpc_slice XdsApi::CreateAdsRequest(
 | 
	
		
			
				|  |  |    // Add resource_names.
 | 
	
		
			
				|  |  |    for (const auto& resource_name : resource_names) {
 | 
	
		
			
				|  |  |      envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
 | 
	
		
			
				|  |  | -        request, upb_strview_make(resource_name.data(), resource_name.size()),
 | 
	
		
			
				|  |  | -        arena.ptr());
 | 
	
		
			
				|  |  | +        request, StdStringToUpbString(resource_name), arena.ptr());
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    MaybeLogDiscoveryRequest(client_, tracer_, request, build_version_);
 | 
	
		
			
				|  |  |    return SerializeDiscoveryRequest(arena.ptr(), request);
 | 
	
	
		
			
				|  | @@ -1214,19 +1218,19 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
 | 
	
		
			
				|  |  |                                  XdsApi::RdsUpdate::RdsRoute* rds_route,
 | 
	
		
			
				|  |  |                                  bool* ignore_route) {
 | 
	
		
			
				|  |  |    if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
 | 
	
		
			
				|  |  | -    upb_strview prefix = envoy_config_route_v3_RouteMatch_prefix(match);
 | 
	
		
			
				|  |  | +    absl::string_view prefix =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
 | 
	
		
			
				|  |  |      // Empty prefix "" is accepted.
 | 
	
		
			
				|  |  | -    if (prefix.size > 0) {
 | 
	
		
			
				|  |  | +    if (prefix.size() > 0) {
 | 
	
		
			
				|  |  |        // Prefix "/" is accepted.
 | 
	
		
			
				|  |  | -      if (prefix.data[0] != '/') {
 | 
	
		
			
				|  |  | +      if (prefix[0] != '/') {
 | 
	
		
			
				|  |  |          // Prefix which does not start with a / will never match anything, so
 | 
	
		
			
				|  |  |          // ignore this route.
 | 
	
		
			
				|  |  |          *ignore_route = true;
 | 
	
		
			
				|  |  |          return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        std::vector<absl::string_view> prefix_elements =
 | 
	
		
			
				|  |  | -          absl::StrSplit(absl::string_view(prefix.data, prefix.size).substr(1),
 | 
	
		
			
				|  |  | -                         absl::MaxSplits('/', 2));
 | 
	
		
			
				|  |  | +          absl::StrSplit(prefix.substr(1), absl::MaxSplits('/', 2));
 | 
	
		
			
				|  |  |        if (prefix_elements.size() > 2) {
 | 
	
		
			
				|  |  |          // Prefix cannot have more than 2 slashes.
 | 
	
		
			
				|  |  |          *ignore_route = true;
 | 
	
	
		
			
				|  | @@ -1239,24 +1243,23 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
 | 
	
		
			
				|  |  |          Matchers::PathMatcher::PathMatcherType::PREFIX;
 | 
	
		
			
				|  |  | -    rds_route->matchers.path_matcher.string_matcher =
 | 
	
		
			
				|  |  | -        UpbStringToStdString(prefix);
 | 
	
		
			
				|  |  | +    rds_route->matchers.path_matcher.string_matcher = std::string(prefix);
 | 
	
		
			
				|  |  |    } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
 | 
	
		
			
				|  |  | -    upb_strview path = envoy_config_route_v3_RouteMatch_path(match);
 | 
	
		
			
				|  |  | -    if (path.size == 0) {
 | 
	
		
			
				|  |  | +    absl::string_view path =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
 | 
	
		
			
				|  |  | +    if (path.size() == 0) {
 | 
	
		
			
				|  |  |        // Path that is empty will never match anything, so ignore this route.
 | 
	
		
			
				|  |  |        *ignore_route = true;
 | 
	
		
			
				|  |  |        return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    if (path.data[0] != '/') {
 | 
	
		
			
				|  |  | +    if (path[0] != '/') {
 | 
	
		
			
				|  |  |        // Path which does not start with a / will never match anything, so
 | 
	
		
			
				|  |  |        // ignore this route.
 | 
	
		
			
				|  |  |        *ignore_route = true;
 | 
	
		
			
				|  |  |        return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      std::vector<absl::string_view> path_elements =
 | 
	
		
			
				|  |  | -        absl::StrSplit(absl::string_view(path.data, path.size).substr(1),
 | 
	
		
			
				|  |  | -                       absl::MaxSplits('/', 2));
 | 
	
		
			
				|  |  | +        absl::StrSplit(path.substr(1), absl::MaxSplits('/', 2));
 | 
	
		
			
				|  |  |      if (path_elements.size() != 2) {
 | 
	
		
			
				|  |  |        // Path not in the required format of /service/method will never match
 | 
	
		
			
				|  |  |        // anything, so ignore this route.
 | 
	
	
		
			
				|  | @@ -1275,15 +1278,14 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
 | 
	
		
			
				|  |  |          Matchers::PathMatcher::PathMatcherType::PATH;
 | 
	
		
			
				|  |  | -    rds_route->matchers.path_matcher.string_matcher =
 | 
	
		
			
				|  |  | -        UpbStringToStdString(path);
 | 
	
		
			
				|  |  | +    rds_route->matchers.path_matcher.string_matcher = std::string(path);
 | 
	
		
			
				|  |  |    } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
 | 
	
		
			
				|  |  |      const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
 | 
	
		
			
				|  |  |          envoy_config_route_v3_RouteMatch_safe_regex(match);
 | 
	
		
			
				|  |  |      GPR_ASSERT(regex_matcher != nullptr);
 | 
	
		
			
				|  |  | -    const std::string matcher = UpbStringToStdString(
 | 
	
		
			
				|  |  | +    std::string matcher = UpbStringToStdString(
 | 
	
		
			
				|  |  |          envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
 | 
	
		
			
				|  |  | -    std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
 | 
	
		
			
				|  |  | +    std::unique_ptr<RE2> regex = absl::make_unique<RE2>(std::move(matcher));
 | 
	
		
			
				|  |  |      if (!regex->ok()) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
 | 
	
		
			
				|  |  |            "Invalid regex string specified in path matcher.");
 | 
	
	
		
			
				|  | @@ -1413,13 +1415,12 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route,
 | 
	
		
			
				|  |  |        envoy_config_route_v3_Route_route(route);
 | 
	
		
			
				|  |  |    // Get the cluster or weighted_clusters in the RouteAction.
 | 
	
		
			
				|  |  |    if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
 | 
	
		
			
				|  |  | -    const upb_strview cluster_name =
 | 
	
		
			
				|  |  | -        envoy_config_route_v3_RouteAction_cluster(route_action);
 | 
	
		
			
				|  |  | -    if (cluster_name.size == 0) {
 | 
	
		
			
				|  |  | +    rds_route->cluster_name = UpbStringToStdString(
 | 
	
		
			
				|  |  | +        envoy_config_route_v3_RouteAction_cluster(route_action));
 | 
	
		
			
				|  |  | +    if (rds_route->cluster_name.size() == 0) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
 | 
	
		
			
				|  |  |            "RouteAction cluster contains empty cluster name.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    rds_route->cluster_name = UpbStringToStdString(cluster_name);
 | 
	
		
			
				|  |  |    } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
 | 
	
		
			
				|  |  |                   route_action)) {
 | 
	
		
			
				|  |  |      const envoy_config_route_v3_WeightedCluster* weighted_cluster =
 | 
	
	
		
			
				|  | @@ -1587,8 +1588,9 @@ grpc_error* LdsResponseParse(
 | 
	
		
			
				|  |  |        envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
 | 
	
		
			
				|  |  |    for (size_t i = 0; i < size; ++i) {
 | 
	
		
			
				|  |  |      // Check the type_url of the resource.
 | 
	
		
			
				|  |  | -    const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
 | 
	
		
			
				|  |  | -    if (!IsLds(UpbStringToAbsl(type_url))) {
 | 
	
		
			
				|  |  | +    absl::string_view type_url =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
 | 
	
		
			
				|  |  | +    if (!IsLds(type_url)) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not LDS.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Decode the listener.
 | 
	
	
		
			
				|  | @@ -1601,10 +1603,9 @@ grpc_error* LdsResponseParse(
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode listener.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Check listener name. Ignore unexpected listeners.
 | 
	
		
			
				|  |  | -    const upb_strview name = envoy_config_listener_v3_Listener_name(listener);
 | 
	
		
			
				|  |  | -    const upb_strview expected_name =
 | 
	
		
			
				|  |  | -        upb_strview_makez(expected_server_name.c_str());
 | 
	
		
			
				|  |  | -    if (!upb_strview_eql(name, expected_name)) continue;
 | 
	
		
			
				|  |  | +    absl::string_view name =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(envoy_config_listener_v3_Listener_name(listener));
 | 
	
		
			
				|  |  | +    if (name != expected_server_name) continue;
 | 
	
		
			
				|  |  |      // Get api_listener and decode it to http_connection_manager.
 | 
	
		
			
				|  |  |      const envoy_config_listener_v3_ApiListener* api_listener =
 | 
	
		
			
				|  |  |          envoy_config_listener_v3_Listener_api_listener(listener);
 | 
	
	
		
			
				|  | @@ -1679,8 +1680,9 @@ grpc_error* RdsResponseParse(
 | 
	
		
			
				|  |  |        envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
 | 
	
		
			
				|  |  |    for (size_t i = 0; i < size; ++i) {
 | 
	
		
			
				|  |  |      // Check the type_url of the resource.
 | 
	
		
			
				|  |  | -    const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
 | 
	
		
			
				|  |  | -    if (!IsRds(UpbStringToAbsl(type_url))) {
 | 
	
		
			
				|  |  | +    absl::string_view type_url =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
 | 
	
		
			
				|  |  | +    if (!IsRds(type_url)) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not RDS.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Decode the route_config.
 | 
	
	
		
			
				|  | @@ -1693,11 +1695,9 @@ grpc_error* RdsResponseParse(
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Check route_config_name. Ignore unexpected route_config.
 | 
	
		
			
				|  |  | -    const upb_strview route_config_name =
 | 
	
		
			
				|  |  | -        envoy_config_route_v3_RouteConfiguration_name(route_config);
 | 
	
		
			
				|  |  | -    absl::string_view route_config_name_strview(route_config_name.data,
 | 
	
		
			
				|  |  | -                                                route_config_name.size);
 | 
	
		
			
				|  |  | -    if (expected_route_configuration_names.find(route_config_name_strview) ==
 | 
	
		
			
				|  |  | +    absl::string_view route_config_name = UpbStringToAbsl(
 | 
	
		
			
				|  |  | +        envoy_config_route_v3_RouteConfiguration_name(route_config));
 | 
	
		
			
				|  |  | +    if (expected_route_configuration_names.find(route_config_name) ==
 | 
	
		
			
				|  |  |          expected_route_configuration_names.end()) {
 | 
	
		
			
				|  |  |        continue;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1725,8 +1725,9 @@ grpc_error* CdsResponseParse(
 | 
	
		
			
				|  |  |    for (size_t i = 0; i < size; ++i) {
 | 
	
		
			
				|  |  |      XdsApi::CdsUpdate cds_update;
 | 
	
		
			
				|  |  |      // Check the type_url of the resource.
 | 
	
		
			
				|  |  | -    const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
 | 
	
		
			
				|  |  | -    if (!IsCds(UpbStringToAbsl(type_url))) {
 | 
	
		
			
				|  |  | +    absl::string_view type_url =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
 | 
	
		
			
				|  |  | +    if (!IsCds(type_url)) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not CDS.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Decode the cluster.
 | 
	
	
		
			
				|  | @@ -1739,10 +1740,9 @@ grpc_error* CdsResponseParse(
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      MaybeLogCluster(client, tracer, cluster);
 | 
	
		
			
				|  |  |      // Ignore unexpected cluster names.
 | 
	
		
			
				|  |  | -    upb_strview cluster_name = envoy_config_cluster_v3_Cluster_name(cluster);
 | 
	
		
			
				|  |  | -    absl::string_view cluster_name_strview(cluster_name.data,
 | 
	
		
			
				|  |  | -                                           cluster_name.size);
 | 
	
		
			
				|  |  | -    if (expected_cluster_names.find(cluster_name_strview) ==
 | 
	
		
			
				|  |  | +    std::string cluster_name =
 | 
	
		
			
				|  |  | +        UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
 | 
	
		
			
				|  |  | +    if (expected_cluster_names.find(cluster_name) ==
 | 
	
		
			
				|  |  |          expected_cluster_names.end()) {
 | 
	
		
			
				|  |  |        continue;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1787,8 +1787,7 @@ grpc_error* CdsResponseParse(
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        cds_update.lrs_load_reporting_server_name.emplace("");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    cds_update_map->emplace(UpbStringToStdString(cluster_name),
 | 
	
		
			
				|  |  | -                            std::move(cds_update));
 | 
	
		
			
				|  |  | +    cds_update_map->emplace(std::move(cluster_name), std::move(cds_update));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -1810,19 +1809,15 @@ grpc_error* ServerAddressParseAndAppend(
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_Endpoint_address(endpoint);
 | 
	
		
			
				|  |  |    const envoy_config_core_v3_SocketAddress* socket_address =
 | 
	
		
			
				|  |  |        envoy_config_core_v3_Address_socket_address(address);
 | 
	
		
			
				|  |  | -  upb_strview address_strview =
 | 
	
		
			
				|  |  | -      envoy_config_core_v3_SocketAddress_address(socket_address);
 | 
	
		
			
				|  |  | +  std::string address_str = UpbStringToStdString(
 | 
	
		
			
				|  |  | +      envoy_config_core_v3_SocketAddress_address(socket_address));
 | 
	
		
			
				|  |  |    uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
 | 
	
		
			
				|  |  |    if (GPR_UNLIKELY(port >> 16) != 0) {
 | 
	
		
			
				|  |  |      return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port.");
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Populate grpc_resolved_address.
 | 
	
		
			
				|  |  |    grpc_resolved_address addr;
 | 
	
		
			
				|  |  | -  char* address_str = static_cast<char*>(gpr_malloc(address_strview.size + 1));
 | 
	
		
			
				|  |  | -  memcpy(address_str, address_strview.data, address_strview.size);
 | 
	
		
			
				|  |  | -  address_str[address_strview.size] = '\0';
 | 
	
		
			
				|  |  | -  grpc_string_to_sockaddr(&addr, address_str, port);
 | 
	
		
			
				|  |  | -  gpr_free(address_str);
 | 
	
		
			
				|  |  | +  grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
 | 
	
		
			
				|  |  |    // Append the address to the list.
 | 
	
		
			
				|  |  |    list->emplace_back(addr, nullptr);
 | 
	
		
			
				|  |  |    return GRPC_ERROR_NONE;
 | 
	
	
		
			
				|  | @@ -1845,12 +1840,14 @@ grpc_error* LocalityParse(
 | 
	
		
			
				|  |  |    const envoy_config_core_v3_Locality* locality =
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
 | 
	
		
			
				|  |  |            locality_lb_endpoints);
 | 
	
		
			
				|  |  | -  upb_strview region = envoy_config_core_v3_Locality_region(locality);
 | 
	
		
			
				|  |  | -  upb_strview zone = envoy_config_core_v3_Locality_region(locality);
 | 
	
		
			
				|  |  | -  upb_strview sub_zone = envoy_config_core_v3_Locality_sub_zone(locality);
 | 
	
		
			
				|  |  | +  std::string region =
 | 
	
		
			
				|  |  | +      UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
 | 
	
		
			
				|  |  | +  std::string zone =
 | 
	
		
			
				|  |  | +      UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
 | 
	
		
			
				|  |  | +  std::string sub_zone =
 | 
	
		
			
				|  |  | +      UpbStringToStdString(envoy_config_core_v3_Locality_sub_zone(locality));
 | 
	
		
			
				|  |  |    output_locality->name = MakeRefCounted<XdsLocalityName>(
 | 
	
		
			
				|  |  | -      UpbStringToStdString(region), UpbStringToStdString(zone),
 | 
	
		
			
				|  |  | -      UpbStringToStdString(sub_zone));
 | 
	
		
			
				|  |  | +      std::move(region), std::move(zone), std::move(sub_zone));
 | 
	
		
			
				|  |  |    // Parse the addresses.
 | 
	
		
			
				|  |  |    size_t size;
 | 
	
		
			
				|  |  |    const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
 | 
	
	
		
			
				|  | @@ -1873,10 +1870,10 @@ grpc_error* DropParseAndAppend(
 | 
	
		
			
				|  |  |          drop_overload,
 | 
	
		
			
				|  |  |      XdsApi::DropConfig* drop_config) {
 | 
	
		
			
				|  |  |    // Get the category.
 | 
	
		
			
				|  |  | -  upb_strview category =
 | 
	
		
			
				|  |  | +  std::string category = UpbStringToStdString(
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
 | 
	
		
			
				|  |  | -          drop_overload);
 | 
	
		
			
				|  |  | -  if (category.size == 0) {
 | 
	
		
			
				|  |  | +          drop_overload));
 | 
	
		
			
				|  |  | +  if (category.size() == 0) {
 | 
	
		
			
				|  |  |      return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Get the drop rate (per million).
 | 
	
	
		
			
				|  | @@ -1903,7 +1900,7 @@ grpc_error* DropParseAndAppend(
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Cap numerator to 1000000.
 | 
	
		
			
				|  |  |    numerator = GPR_MIN(numerator, 1000000);
 | 
	
		
			
				|  |  | -  drop_config->AddCategory(UpbStringToStdString(category), numerator);
 | 
	
		
			
				|  |  | +  drop_config->AddCategory(std::move(category), numerator);
 | 
	
		
			
				|  |  |    return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1919,8 +1916,9 @@ grpc_error* EdsResponseParse(
 | 
	
		
			
				|  |  |    for (size_t i = 0; i < size; ++i) {
 | 
	
		
			
				|  |  |      XdsApi::EdsUpdate eds_update;
 | 
	
		
			
				|  |  |      // Check the type_url of the resource.
 | 
	
		
			
				|  |  | -    upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
 | 
	
		
			
				|  |  | -    if (!IsEds(UpbStringToAbsl(type_url))) {
 | 
	
		
			
				|  |  | +    absl::string_view type_url =
 | 
	
		
			
				|  |  | +        UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
 | 
	
		
			
				|  |  | +    if (!IsEds(type_url)) {
 | 
	
		
			
				|  |  |        return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not EDS.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Get the cluster_load_assignment.
 | 
	
	
		
			
				|  | @@ -1937,12 +1935,10 @@ grpc_error* EdsResponseParse(
 | 
	
		
			
				|  |  |      MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
 | 
	
		
			
				|  |  |      // Check the cluster name (which actually means eds_service_name). Ignore
 | 
	
		
			
				|  |  |      // unexpected names.
 | 
	
		
			
				|  |  | -    upb_strview cluster_name =
 | 
	
		
			
				|  |  | +    std::string eds_service_name = UpbStringToStdString(
 | 
	
		
			
				|  |  |          envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
 | 
	
		
			
				|  |  | -            cluster_load_assignment);
 | 
	
		
			
				|  |  | -    absl::string_view cluster_name_strview(cluster_name.data,
 | 
	
		
			
				|  |  | -                                           cluster_name.size);
 | 
	
		
			
				|  |  | -    if (expected_eds_service_names.find(cluster_name_strview) ==
 | 
	
		
			
				|  |  | +            cluster_load_assignment));
 | 
	
		
			
				|  |  | +    if (expected_eds_service_names.find(eds_service_name) ==
 | 
	
		
			
				|  |  |          expected_eds_service_names.end()) {
 | 
	
		
			
				|  |  |        continue;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1984,8 +1980,7 @@ grpc_error* EdsResponseParse(
 | 
	
		
			
				|  |  |          if (error != GRPC_ERROR_NONE) return error;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    eds_update_map->emplace(UpbStringToStdString(cluster_name),
 | 
	
		
			
				|  |  | -                            std::move(eds_update));
 | 
	
		
			
				|  |  | +    eds_update_map->emplace(std::move(eds_service_name), std::move(eds_update));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    return GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -2025,16 +2020,12 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    MaybeLogDiscoveryResponse(client_, tracer_, response);
 | 
	
		
			
				|  |  |    // Record the type_url, the version_info, and the nonce of the response.
 | 
	
		
			
				|  |  | -  upb_strview type_url_strview =
 | 
	
		
			
				|  |  | -      envoy_service_discovery_v3_DiscoveryResponse_type_url(response);
 | 
	
		
			
				|  |  | -  result.type_url =
 | 
	
		
			
				|  |  | -      TypeUrlInternalToExternal(UpbStringToAbsl(type_url_strview));
 | 
	
		
			
				|  |  | -  upb_strview version_info =
 | 
	
		
			
				|  |  | -      envoy_service_discovery_v3_DiscoveryResponse_version_info(response);
 | 
	
		
			
				|  |  | -  result.version = UpbStringToStdString(version_info);
 | 
	
		
			
				|  |  | -  upb_strview nonce_strview =
 | 
	
		
			
				|  |  | -      envoy_service_discovery_v3_DiscoveryResponse_nonce(response);
 | 
	
		
			
				|  |  | -  result.nonce = UpbStringToStdString(nonce_strview);
 | 
	
		
			
				|  |  | +  result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
 | 
	
		
			
				|  |  | +      envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
 | 
	
		
			
				|  |  | +  result.version = UpbStringToStdString(
 | 
	
		
			
				|  |  | +      envoy_service_discovery_v3_DiscoveryResponse_version_info(response));
 | 
	
		
			
				|  |  | +  result.nonce = UpbStringToStdString(
 | 
	
		
			
				|  |  | +      envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
 | 
	
		
			
				|  |  |    // Parse the response according to the resource type.
 | 
	
		
			
				|  |  |    if (IsLds(result.type_url)) {
 | 
	
		
			
				|  |  |      result.parse_error =
 | 
	
	
		
			
				|  | @@ -2217,15 +2208,15 @@ void LocalityStatsPopulate(
 | 
	
		
			
				|  |  |                                                                        arena);
 | 
	
		
			
				|  |  |    if (!locality_name.region().empty()) {
 | 
	
		
			
				|  |  |      envoy_config_core_v3_Locality_set_region(
 | 
	
		
			
				|  |  | -        locality, upb_strview_makez(locality_name.region().c_str()));
 | 
	
		
			
				|  |  | +        locality, StdStringToUpbString(locality_name.region()));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (!locality_name.zone().empty()) {
 | 
	
		
			
				|  |  |      envoy_config_core_v3_Locality_set_zone(
 | 
	
		
			
				|  |  | -        locality, upb_strview_makez(locality_name.zone().c_str()));
 | 
	
		
			
				|  |  | +        locality, StdStringToUpbString(locality_name.zone()));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (!locality_name.sub_zone().empty()) {
 | 
	
		
			
				|  |  |      envoy_config_core_v3_Locality_set_sub_zone(
 | 
	
		
			
				|  |  | -        locality, upb_strview_makez(locality_name.sub_zone().c_str()));
 | 
	
		
			
				|  |  | +        locality, StdStringToUpbString(locality_name.sub_zone()));
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Set total counts.
 | 
	
		
			
				|  |  |    envoy_config_endpoint_v3_UpstreamLocalityStats_set_total_successful_requests(
 | 
	
	
		
			
				|  | @@ -2244,7 +2235,7 @@ void LocalityStatsPopulate(
 | 
	
		
			
				|  |  |          envoy_config_endpoint_v3_UpstreamLocalityStats_add_load_metric_stats(
 | 
	
		
			
				|  |  |              output, arena);
 | 
	
		
			
				|  |  |      envoy_config_endpoint_v3_EndpointLoadMetricStats_set_metric_name(
 | 
	
		
			
				|  |  | -        load_metric, upb_strview_make(metric_name.data(), metric_name.size()));
 | 
	
		
			
				|  |  | +        load_metric, StdStringToUpbString(metric_name));
 | 
	
		
			
				|  |  |      envoy_config_endpoint_v3_EndpointLoadMetricStats_set_num_requests_finished_with_metric(
 | 
	
		
			
				|  |  |          load_metric, metric_value.num_requests_finished_with_metric);
 | 
	
		
			
				|  |  |      envoy_config_endpoint_v3_EndpointLoadMetricStats_set_total_metric_value(
 | 
	
	
		
			
				|  | @@ -2270,13 +2261,11 @@ grpc_slice XdsApi::CreateLrsRequest(
 | 
	
		
			
				|  |  |              request, arena.ptr());
 | 
	
		
			
				|  |  |      // Set the cluster name.
 | 
	
		
			
				|  |  |      envoy_config_endpoint_v3_ClusterStats_set_cluster_name(
 | 
	
		
			
				|  |  | -        cluster_stats,
 | 
	
		
			
				|  |  | -        upb_strview_make(cluster_name.data(), cluster_name.size()));
 | 
	
		
			
				|  |  | +        cluster_stats, StdStringToUpbString(cluster_name));
 | 
	
		
			
				|  |  |      // Set EDS service name, if non-empty.
 | 
	
		
			
				|  |  |      if (!eds_service_name.empty()) {
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_ClusterStats_set_cluster_service_name(
 | 
	
		
			
				|  |  | -          cluster_stats,
 | 
	
		
			
				|  |  | -          upb_strview_make(eds_service_name.data(), eds_service_name.size()));
 | 
	
		
			
				|  |  | +          cluster_stats, StdStringToUpbString(eds_service_name));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // Add locality stats.
 | 
	
		
			
				|  |  |      for (const auto& p : load_report.locality_stats) {
 | 
	
	
		
			
				|  | @@ -2291,13 +2280,13 @@ grpc_slice XdsApi::CreateLrsRequest(
 | 
	
		
			
				|  |  |      // Add dropped requests.
 | 
	
		
			
				|  |  |      uint64_t total_dropped_requests = 0;
 | 
	
		
			
				|  |  |      for (const auto& p : load_report.dropped_requests) {
 | 
	
		
			
				|  |  | -      const char* category = p.first.c_str();
 | 
	
		
			
				|  |  | +      const std::string& category = p.first;
 | 
	
		
			
				|  |  |        const uint64_t count = p.second;
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_ClusterStats_DroppedRequests* dropped_requests =
 | 
	
		
			
				|  |  |            envoy_config_endpoint_v3_ClusterStats_add_dropped_requests(
 | 
	
		
			
				|  |  |                cluster_stats, arena.ptr());
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_ClusterStats_DroppedRequests_set_category(
 | 
	
		
			
				|  |  | -          dropped_requests, upb_strview_makez(category));
 | 
	
		
			
				|  |  | +          dropped_requests, StdStringToUpbString(category));
 | 
	
		
			
				|  |  |        envoy_config_endpoint_v3_ClusterStats_DroppedRequests_set_dropped_count(
 | 
	
		
			
				|  |  |            dropped_requests, count);
 | 
	
		
			
				|  |  |        total_dropped_requests += count;
 | 
	
	
		
			
				|  | @@ -2343,7 +2332,7 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
 | 
	
		
			
				|  |  |          envoy_service_load_stats_v3_LoadStatsResponse_clusters(decoded_response,
 | 
	
		
			
				|  |  |                                                                 &size);
 | 
	
		
			
				|  |  |      for (size_t i = 0; i < size; ++i) {
 | 
	
		
			
				|  |  | -      cluster_names->emplace(clusters[i].data, clusters[i].size);
 | 
	
		
			
				|  |  | +      cluster_names->emplace(UpbStringToStdString(clusters[i]));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Get the load report interval.
 |