• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_IMPL_H
16 #define GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_IMPL_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include "absl/status/statusor.h"
21 #include "src/core/lib/channel/channel_fwd.h"
22 #include "src/core/lib/channel/channel_stack_builder.h"
23 #include "src/core/util/ref_counted_ptr.h"
24 
25 namespace grpc_core {
26 
27 class Blackboard;
28 
29 // Build a channel stack.
30 // Allows interested parties to add filters to the stack, and to query an
31 // in-progress build.
32 // Carries some useful context for the channel stack, such as a target string
33 // and a transport.
34 class ChannelStackBuilderImpl final : public ChannelStackBuilder {
35  public:
36   using ChannelStackBuilder::ChannelStackBuilder;
37 
SetBlackboards(const Blackboard * old_blackboard,Blackboard * new_blackboard)38   void SetBlackboards(const Blackboard* old_blackboard,
39                       Blackboard* new_blackboard) {
40     old_blackboard_ = old_blackboard;
41     new_blackboard_ = new_blackboard;
42   }
43 
44   // Build the channel stack.
45   // After success, *result holds the new channel stack,
46   // prefix_bytes are allocated before the channel stack,
47   // initial_refs, destroy, destroy_arg are as per grpc_channel_stack_init
48   // On failure, *result is nullptr.
49   absl::StatusOr<RefCountedPtr<grpc_channel_stack>> Build() override;
50 
51  private:
52   const Blackboard* old_blackboard_ = nullptr;
53   Blackboard* new_blackboard_ = nullptr;
54 };
55 
56 }  // namespace grpc_core
57 
58 #endif  // GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_IMPL_H
59