• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2016 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #include "src/core/lib/channel/channel_stack_builder.h"
20 
21 #include <grpc/support/port_platform.h>
22 
23 #include <algorithm>
24 
25 #include "src/core/lib/channel/channel_args.h"
26 
27 namespace grpc_core {
28 
ChannelStackBuilder(const char * name,grpc_channel_stack_type type,const ChannelArgs & channel_args)29 ChannelStackBuilder::ChannelStackBuilder(const char* name,
30                                          grpc_channel_stack_type type,
31                                          const ChannelArgs& channel_args)
32     : name_(name), type_(type), args_(channel_args) {}
33 
SetTarget(const char * target)34 ChannelStackBuilder& ChannelStackBuilder::SetTarget(const char* target) {
35   if (target == nullptr) {
36     target_ = unknown_target();
37   } else {
38     target_ = target;
39   }
40   return *this;
41 }
42 
PrependFilter(const grpc_channel_filter * filter)43 void ChannelStackBuilder::PrependFilter(const grpc_channel_filter* filter) {
44   stack_.insert(stack_.begin(), filter);
45 }
46 
AppendFilter(const grpc_channel_filter * filter)47 void ChannelStackBuilder::AppendFilter(const grpc_channel_filter* filter) {
48   stack_.push_back(filter);
49 }
50 
51 }  // namespace grpc_core
52