chromium/third_party/openscreen/src/util/trace_logging/scoped_trace_operations.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UTIL_TRACE_LOGGING_SCOPED_TRACE_OPERATIONS_H_
#define UTIL_TRACE_LOGGING_SCOPED_TRACE_OPERATIONS_H_

#include <atomic>
#include <cstring>
#include <memory>
#include <stack>
#include <utility>
#include <vector>

#include "platform/api/time.h"
#include "platform/api/trace_logging_platform.h"
#include "platform/base/error.h"
#include "platform/base/trace_logging_types.h"
#include "util/osp_logging.h"

#if defined(ENABLE_TRACE_LOGGING)

namespace openscreen::internal {

// A base class for all trace logging objects which will create new entries in
// the Trace Hierarchy.
// 1) The sharing of all static and thread_local variables across template
// specializations.
// 2) Including all children in the same traces vector.
class ScopedTraceOperation {};

// The class which does actual trace logging.
class TraceLoggerBase : public ScopedTraceOperation {};

class SynchronousTraceLogger : public TraceLoggerBase {};

class AsynchronousTraceLogger : public TraceLoggerBase {};

// Inserts a fake element into the ScopedTraceOperation stack to set
// the current TraceId Hierarchy manually.
class TraceIdSetter final : public ScopedTraceOperation {};

// This helper object allows us to delete objects allocated on the stack in a
// unique_ptr.
template <class T>
class TraceInstanceHelper {};

}  // namespace openscreen::internal

#endif  // defined(ENABLE_TRACE_LOGGING)

#endif  // UTIL_TRACE_LOGGING_SCOPED_TRACE_OPERATIONS_H_