chromium/media/base/scoped_async_trace.h

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

#ifndef MEDIA_BASE_SCOPED_ASYNC_TRACE_H_
#define MEDIA_BASE_SCOPED_ASYNC_TRACE_H_

#include <memory>

#include "base/memory/raw_ptr.h"
#include "media/base/media_export.h"

namespace media {

// When adding a new TraceCategory there are two additional steps in the .cc:
//
//   1. Add a new Category::Name() implementation at the top.
//   2. Add a new  TypedScopedAsyncTrace<$NEW_CATEGORY> entry at the bottom.
//
// For frequently used scoped traces you may also add a "using" entry along with
// the "using ScopedAsyncTrace..." entry below.
enum class TraceCategory : uint32_t {};

// Utility class that starts and stops an async trace event.  The intention is
// that it it will be created somewhere to start the trace event, passed around
// such as via unique_ptr argument in a callback, and eventually freed to end
// the trace event.  This guarantees that it'll be closed, even if the callback
// is destroyed without being run.
template <TraceCategory category>
class MEDIA_EXPORT TypedScopedAsyncTrace {};

ScopedAsyncTrace;

}  // namespace media

#endif  // MEDIA_BASE_SCOPED_ASYNC_TRACE_H_