// services/network/public/mojom/declarative_performance_observer.mojom-blink.h is auto generated by mojom_bindings_generator.py, do not edit

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

#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_DECLARATIVE_PERFORMANCE_OBSERVER_MOJOM_BLINK_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_DECLARATIVE_PERFORMANCE_OBSERVER_MOJOM_BLINK_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "services/network/public/mojom/declarative_performance_observer.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/declarative_performance_observer.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/declarative_performance_observer.mojom-blink-forward.h"  // IWYU pragma: export

#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"




#include "third_party/blink/public/platform/web_common.h"
#if !BLINK_MOJO_IMPL && !INSIDE_BLINK
#error "File must only be imported inside blink"
#endif




namespace network::mojom::blink {








class BLINK_PLATFORM_EXPORT DeclarativePerformanceObserverPolicy {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<DeclarativePerformanceObserverPolicy, T>::value>;
  using DataView = DeclarativePerformanceObserverPolicyDataView;
  using Data_ = internal::DeclarativePerformanceObserverPolicy_Data;

  template <typename... Args>
  static DeclarativePerformanceObserverPolicyPtr New(Args&&... args) {
    return DeclarativePerformanceObserverPolicyPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static DeclarativePerformanceObserverPolicyPtr From(const U& u) {
    return mojo::TypeConverter<DeclarativePerformanceObserverPolicyPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, DeclarativePerformanceObserverPolicy>::Convert(*this);
  }


  DeclarativePerformanceObserverPolicy();

  DeclarativePerformanceObserverPolicy(
      const ::blink::String& reporting_endpoint,
      ::blink::Vector<PerformanceEntryType> entry_types,
      std::optional<::blink::Vector<::blink::String>> include_user_timing,
      bool capture_early_failures);


  ~DeclarativePerformanceObserverPolicy();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = DeclarativePerformanceObserverPolicyPtr>
  DeclarativePerformanceObserverPolicyPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DeclarativePerformanceObserverPolicy::DataView, ::blink::Vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DeclarativePerformanceObserverPolicy::DataView, ::blink::Vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        DeclarativePerformanceObserverPolicy::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::DeclarativePerformanceObserverPolicy_UnserializedMessageContext<
            UserType, DeclarativePerformanceObserverPolicy::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<DeclarativePerformanceObserverPolicy::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return DeclarativePerformanceObserverPolicy::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::DeclarativePerformanceObserverPolicy_UnserializedMessageContext<
            UserType, DeclarativePerformanceObserverPolicy::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<DeclarativePerformanceObserverPolicy::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::blink::String reporting_endpoint;
  
  ::blink::Vector<PerformanceEntryType> entry_types;
  
  std::optional<::blink::Vector<::blink::String>> include_user_timing;
  
  bool capture_early_failures;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
DeclarativePerformanceObserverPolicyPtr DeclarativePerformanceObserverPolicy::Clone() const {
  return New(
      mojo::Clone(reporting_endpoint),
      mojo::Clone(entry_types),
      mojo::Clone(include_user_timing),
      mojo::Clone(capture_early_failures)
  );
}

template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>*>
bool DeclarativePerformanceObserverPolicy::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->reporting_endpoint, other_struct.reporting_endpoint))
    return false;
  if (!mojo::Equals(this->entry_types, other_struct.entry_types))
    return false;
  if (!mojo::Equals(this->include_user_timing, other_struct.include_user_timing))
    return false;
  if (!mojo::Equals(this->capture_early_failures, other_struct.capture_early_failures))
    return false;
  return true;
}

template <typename T, DeclarativePerformanceObserverPolicy::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.reporting_endpoint < rhs.reporting_endpoint)
    return true;
  if (rhs.reporting_endpoint < lhs.reporting_endpoint)
    return false;
  if (lhs.entry_types < rhs.entry_types)
    return true;
  if (rhs.entry_types < lhs.entry_types)
    return false;
  if (lhs.include_user_timing < rhs.include_user_timing)
    return true;
  if (rhs.include_user_timing < lhs.include_user_timing)
    return false;
  if (lhs.capture_early_failures < rhs.capture_early_failures)
    return true;
  if (rhs.capture_early_failures < lhs.capture_early_failures)
    return false;
  return false;
}


}  // network::mojom::blink

namespace mojo {


template <>
struct BLINK_PLATFORM_EXPORT StructTraits<::network::mojom::blink::DeclarativePerformanceObserverPolicy::DataView,
                                         ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr> {
  static bool IsNull(const ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr& input) { return !input; }
  static void SetToNull(::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr* output) { output->reset(); }

  static const decltype(::network::mojom::blink::DeclarativePerformanceObserverPolicy::reporting_endpoint)& reporting_endpoint(
      const ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr& input) {
    return input->reporting_endpoint;
  }

  static const decltype(::network::mojom::blink::DeclarativePerformanceObserverPolicy::entry_types)& entry_types(
      const ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr& input) {
    return input->entry_types;
  }

  static const decltype(::network::mojom::blink::DeclarativePerformanceObserverPolicy::include_user_timing)& include_user_timing(
      const ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr& input) {
    return input->include_user_timing;
  }

  static decltype(::network::mojom::blink::DeclarativePerformanceObserverPolicy::capture_early_failures) capture_early_failures(
      const ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr& input) {
    return input->capture_early_failures;
  }

  static bool Read(::network::mojom::blink::DeclarativePerformanceObserverPolicy::DataView input, ::network::mojom::blink::DeclarativePerformanceObserverPolicyPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_DECLARATIVE_PERFORMANCE_OBSERVER_MOJOM_BLINK_H_