2 // Copyright 2020 gRPC authors.
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <grpc/support/port_platform.h>
19 #include "src/core/ext/filters/client_channel/config_selector.h"
21 #include "src/core/lib/channel/channel_args.h"
27 void* ConfigSelectorArgCopy(void* p) {
28 ConfigSelector* config_selector = static_cast<ConfigSelector*>(p);
29 config_selector->Ref().release();
33 void ConfigSelectorArgDestroy(void* p) {
34 ConfigSelector* config_selector = static_cast<ConfigSelector*>(p);
35 config_selector->Unref();
38 int ConfigSelectorArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
40 const grpc_arg_pointer_vtable kChannelArgVtable = {
41 ConfigSelectorArgCopy, ConfigSelectorArgDestroy, ConfigSelectorArgCmp};
45 grpc_arg ConfigSelector::MakeChannelArg() const {
46 return grpc_channel_arg_pointer_create(
47 const_cast<char*>(GRPC_ARG_CONFIG_SELECTOR),
48 const_cast<ConfigSelector*>(this), &kChannelArgVtable);
51 RefCountedPtr<ConfigSelector> ConfigSelector::GetFromChannelArgs(
52 const grpc_channel_args& args) {
53 ConfigSelector* config_selector =
54 grpc_channel_args_find_pointer<ConfigSelector>(&args,
55 GRPC_ARG_CONFIG_SELECTOR);
56 return config_selector != nullptr ? config_selector->Ref() : nullptr;
59 } // namespace grpc_core