chromium/third_party/blink/renderer/bindings/core/v8/script_promise_resolver_with_tracker.h

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

#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SCRIPT_PROMISE_RESOLVER_WITH_TRACKER_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SCRIPT_PROMISE_RESOLVER_WITH_TRACKER_H_

#include "base/metrics/histogram_functions.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"

namespace blink {

// ScriptPromiseResolverWithTracker is a wrapper around
// ScriptPromiseResolverBase which simplifies recording UMA metric and latency
// for APIs.

// Callers should ensure that the ResultEnumType has kOk and kTimedOut as
// values. This is a sample usage CL: http://crrev.com/c/4053546.
template <typename ResultEnumType, typename IDLResolvedType>
class CORE_EXPORT ScriptPromiseResolverWithTracker
    : public GarbageCollected<
          ScriptPromiseResolverWithTracker<ResultEnumType, IDLResolvedType>>,
      public ExecutionContextLifecycleObserver {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SCRIPT_PROMISE_RESOLVER_WITH_TRACKER_H_