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

#ifndef CONTENT_PUBLIC_BROWSER_PRELOAD_SERVING_METRICS_CAPSULE_H_
#define CONTENT_PUBLIC_BROWSER_PRELOAD_SERVING_METRICS_CAPSULE_H_

#include <memory>
#include <string_view>

#include "base/time/time.h"
#include "content/common/content_export.h"

namespace content {

class NavigationHandle;

// Allows `PageLoadMetricsObserver` to get/hold/record `PreloadServingMetrics`.
class CONTENT_EXPORT PreloadServingMetricsCapsule {
 public:
  // Takes `PreloadServingMetrics` from `PreloadServingMetricsHolder` of
  // `NavigationHandle`.
  static std::unique_ptr<PreloadServingMetricsCapsule> TakeFromNavigationHandle(
      NavigationHandle& navigation_handle);

  virtual ~PreloadServingMetricsCapsule();

  virtual void RecordMetricsForNonPrerenderNavigationCommitted() const = 0;

  virtual void RecordPreloadServingMetricsByNavigationInitiator(
      bool did_nav_use_bfcache,
      bool is_served_by_legacy_search_prefetch,
      std::string_view navigation_initiator_string,
      bool is_url_srp) const = 0;

  // Records FirstContentfulPaint
  //
  // The parameter `corrected_first_contentful_paint` is the return value of
  // `page_load_metrics::CorrectEventAsNavigationOrActivationOrigined()`.
  virtual void RecordFirstContentfulPaint(
      base::TimeDelta corrected_first_contentful_paint,
      bool is_in_foreground,
      bool is_served_by_legacy_search_prefetch,
      std::string_view navigation_initiator_string,
      bool is_url_srp) const = 0;
};

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_PRELOAD_SERVING_METRICS_CAPSULE_H_
