// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef QUICHE_QUIC_CORE_QUIC_CONNECTION_CONTEXT_H_ #define QUICHE_QUIC_CORE_QUIC_CONNECTION_CONTEXT_H_ #include <memory> #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "quiche/quic/platform/api/quic_export.h" #include "quiche/common/platform/api/quiche_logging.h" namespace quic { // QuicConnectionTracer is responsible for emit trace messages for a single // QuicConnection. // QuicConnectionTracer is part of the QuicConnectionContext. class QUICHE_EXPORT QuicConnectionTracer { … }; // QuicBugListener is a helper class for implementing QUIC_BUG. The QUIC_BUG // implementation can send the bug information into quic::CurrentBugListener(). class QUICHE_EXPORT QuicBugListener { … }; // QuicConnectionContextListener provides the interfaces that are called when // a QuicConnection becomes active or inactive. If there are platform-specific // preparation or cleanup work needed for the members of QuicConnectionContext // to function, those work can be done in the implementation of this interface. class QUICHE_EXPORT QuicConnectionContextListener { … }; // QuicConnectionContext is a per-QuicConnection context that includes // facilities useable by any part of a QuicConnection. A QuicConnectionContext // is owned by a QuicConnection. // // The 'top-level' QuicConnection functions are responsible for maintaining the // thread-local QuicConnectionContext pointer, such that any function called by // them(directly or indirectly) can access the context. // // Like QuicConnection, all facilities in QuicConnectionContext are assumed to // be called from a single thread at a time, they are NOT thread-safe. struct QUICHE_EXPORT QuicConnectionContext final { … }; // QuicConnectionContextSwitcher is a RAII object used for maintaining the // thread-local QuicConnectionContext pointer. class QUICHE_EXPORT QuicConnectionContextSwitcher final { … }; // Emit a trace message from a string literal to the current tracer(if any). inline void QUIC_TRACELITERAL(const char* literal) { … } // Emit a trace message from a string_view to the current tracer(if any). inline void QUIC_TRACESTRING(absl::string_view s) { … } // Emit a trace message from printf-style arguments to the current tracer(if // any). template <typename... Args> void QUIC_TRACEPRINTF(const absl::FormatSpec<Args...>& format, const Args&... args) { … } inline QuicBugListener* CurrentBugListener() { … } } // namespace quic #endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_CONTEXT_H_