1 //
2 //
3 // Copyright 2015 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 #ifndef GRPC_SRC_CORE_LIB_CHANNEL_CONTEXT_H
20 #define GRPC_SRC_CORE_LIB_CHANNEL_CONTEXT_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include "src/core/lib/promise/context.h"
25 
26 /// Call object context pointers.
27 
28 /// Call context is represented as an array of \a grpc_call_context_elements.
29 /// This enum represents the indexes into the array, where each index
30 /// contains a different type of value.
31 typedef enum {
32   /// Value is either a \a grpc_client_security_context or a
33   /// \a grpc_server_security_context.
34   GRPC_CONTEXT_SECURITY = 0,
35 
36   /// Value is a \a census_context.
37   GRPC_CONTEXT_TRACING,
38 
39   /// Value is a CallTracerAnnotationInterface. (ClientCallTracer object on the
40   /// client-side call, or ServerCallTracer on the server-side.)
41   GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE,
42 
43   /// Value is a CallTracerInterface (ServerCallTracer on the server-side,
44   /// CallAttemptTracer on a subchannel call.)
45   /// TODO(yashykt): Maybe come up with a better name. This will go away in the
46   /// future anyway, so not super important.
47   GRPC_CONTEXT_CALL_TRACER,
48 
49   /// Reserved for traffic_class_context.
50   GRPC_CONTEXT_TRAFFIC,
51 
52   /// Holds a pointer to ServiceConfigCallData associated with this call.
53   GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA,
54 
55   /// Holds a pointer to BackendMetricProvider associated with this call on
56   /// the server.
57   GRPC_CONTEXT_BACKEND_METRIC_PROVIDER,
58 
59   GRPC_CONTEXT_COUNT
60 } grpc_context_index;
61 
62 struct grpc_call_context_element {
63   void* value = nullptr;
64   void (*destroy)(void*) = nullptr;
65 };
66 
67 namespace grpc_core {
68 // Bind the legacy context array into the new style structure
69 // TODO(ctiller): remove as we migrate these contexts to the new system.
70 template <>
71 struct ContextType<grpc_call_context_element> {};
72 }  // namespace grpc_core
73 
74 #endif  // GRPC_SRC_CORE_LIB_CHANNEL_CONTEXT_H
75