| 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_CORE_LIB_CHANNEL_CONTEXT_H |
| 20 |
#define GRPC_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 CallTracer object. |
| 40 |
GRPC_CONTEXT_CALL_TRACER, |
| 41 |
|
| 42 |
/// Reserved for traffic_class_context. |
| 43 |
GRPC_CONTEXT_TRAFFIC, |
| 44 |
|
| 45 |
/// Holds a pointer to ServiceConfigCallData associated with this call. |
| 46 |
GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA, |
| 47 |
|
| 48 |
GRPC_CONTEXT_COUNT |
| 49 |
} grpc_context_index; |
| 50 |
|
| 51 |
struct grpc_call_context_element { |
| 52 |
void* value = nullptr; |
| 53 |
void (*destroy)(void*) = nullptr; |
| 54 |
}; |
| 55 |
|
| 56 |
namespace grpc_core { |
| 57 |
// Bind the legacy context array into the new style structure |
| 58 |
// TODO(ctiller): remove as we migrate these contexts to the new system. |
| 59 |
template <> |
| 60 |
struct ContextType<grpc_call_context_element> {}; |
| 61 |
} // namespace grpc_core |
| 62 |
|
| 63 |
#endif /* GRPC_CORE_LIB_CHANNEL_CONTEXT_H */ |