blob: b82df2eabd8f6f56a42d4569a839a9aa1b2ab383 [file] [log] [blame]
// Copyright 2018 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.
#include <memory>
#include <string>
#include "base/macros.h"
#include "media/base/media_export.h"
namespace media {
// 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.
class MEDIA_EXPORT ScopedAsyncTrace {
// Create a ScopedAsyncTrace if tracing for "media" is enabled, else return
// nullptr. |name| provided to the trace as the name(!).
// IMPORTANT: These strings must outlive |this|, since tracing needs it. In
// other words, use literal strings only. See trace_event_common.h .
static std::unique_ptr<ScopedAsyncTrace> CreateIfEnabled(const char* name);
// TODO(liberato): Add StepInto / StepPast.
explicit ScopedAsyncTrace(const char* name);
const char* name_ = nullptr;
} // namespace media