// services/network/public/mojom/connection_allowlist.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_CONNECTION_ALLOWLIST_MOJOM_BLINK_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_CONNECTION_ALLOWLIST_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/connection_allowlist.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/connection_allowlist.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/connection_allowlist.mojom-blink-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/unguessable_token.mojom-blink.h"
#include "url/mojom/url.mojom-blink.h"

#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 "services/network/public/cpp/connection_allowlist_mojom_traits.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 ConnectionAllowlist {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<ConnectionAllowlist, T>::value>;
  using DataView = ConnectionAllowlistDataView;
  using Data_ = internal::ConnectionAllowlist_Data;

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

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

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


  ConnectionAllowlist();

  ConnectionAllowlist(
      ::blink::Vector<::blink::String> allowlist,
      const ::blink::String& reporting_endpoint,
      ::blink::Vector<ConnectionAllowlistIssue> issues,
      RedirectBehavior redirect_behavior,
      WebRtcBehavior webrtc_behavior,
      bool match_response_origin,
      const ::blink::String& serialized_value);


  ~ConnectionAllowlist();

  // 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 = ConnectionAllowlistPtr>
  ConnectionAllowlistPtr 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, ConnectionAllowlist::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

  template <typename T, ConnectionAllowlist::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<
        ConnectionAllowlist::DataView, ::blink::Vector<uint8_t>, send_validation>(input);
  }

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

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        ConnectionAllowlist::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::ConnectionAllowlist_UnserializedMessageContext<
            UserType, ConnectionAllowlist::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<ConnectionAllowlist::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return ConnectionAllowlist::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::ConnectionAllowlist_UnserializedMessageContext<
            UserType, ConnectionAllowlist::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<ConnectionAllowlist::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::blink::Vector<::blink::String> allowlist;
  
  ::blink::String reporting_endpoint;
  
  ::blink::Vector<ConnectionAllowlistIssue> issues;
  
  RedirectBehavior redirect_behavior;
  
  WebRtcBehavior webrtc_behavior;
  
  bool match_response_origin;
  
  ::blink::String serialized_value;

  // 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, ConnectionAllowlist::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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





class BLINK_PLATFORM_EXPORT ConnectionAllowlists {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<ConnectionAllowlists, T>::value>;
  using DataView = ConnectionAllowlistsDataView;
  using Data_ = internal::ConnectionAllowlists_Data;

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

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

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


  ConnectionAllowlists();

  ConnectionAllowlists(
      const ::blink::KURL& response_url,
      const std::optional<::network::ConnectionAllowlist>& enforced,
      const std::optional<::network::ConnectionAllowlist>& report_only,
      const std::optional<::base::UnguessableToken>& reporting_source);


  ~ConnectionAllowlists();

  // 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 = ConnectionAllowlistsPtr>
  ConnectionAllowlistsPtr 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, ConnectionAllowlists::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

  template <typename T, ConnectionAllowlists::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<
        ConnectionAllowlists::DataView, ::blink::Vector<uint8_t>, send_validation>(input);
  }

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

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        ConnectionAllowlists::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::ConnectionAllowlists_UnserializedMessageContext<
            UserType, ConnectionAllowlists::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<ConnectionAllowlists::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return ConnectionAllowlists::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::ConnectionAllowlists_UnserializedMessageContext<
            UserType, ConnectionAllowlists::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<ConnectionAllowlists::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::blink::KURL response_url;
  
  std::optional<::network::ConnectionAllowlist> enforced;
  
  std::optional<::network::ConnectionAllowlist> report_only;
  
  std::optional<::base::UnguessableToken> reporting_source;

  // 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, ConnectionAllowlists::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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

template <typename StructPtrType>
ConnectionAllowlistPtr ConnectionAllowlist::Clone() const {
  return New(
      mojo::Clone(allowlist),
      mojo::Clone(reporting_endpoint),
      mojo::Clone(issues),
      mojo::Clone(redirect_behavior),
      mojo::Clone(webrtc_behavior),
      mojo::Clone(match_response_origin),
      mojo::Clone(serialized_value)
  );
}

template <typename T, ConnectionAllowlist::EnableIfSame<T>*>
bool ConnectionAllowlist::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->allowlist, other_struct.allowlist))
    return false;
  if (!mojo::Equals(this->reporting_endpoint, other_struct.reporting_endpoint))
    return false;
  if (!mojo::Equals(this->issues, other_struct.issues))
    return false;
  if (!mojo::Equals(this->redirect_behavior, other_struct.redirect_behavior))
    return false;
  if (!mojo::Equals(this->webrtc_behavior, other_struct.webrtc_behavior))
    return false;
  if (!mojo::Equals(this->match_response_origin, other_struct.match_response_origin))
    return false;
  if (!mojo::Equals(this->serialized_value, other_struct.serialized_value))
    return false;
  return true;
}

template <typename T, ConnectionAllowlist::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.allowlist < rhs.allowlist)
    return true;
  if (rhs.allowlist < lhs.allowlist)
    return false;
  if (lhs.reporting_endpoint < rhs.reporting_endpoint)
    return true;
  if (rhs.reporting_endpoint < lhs.reporting_endpoint)
    return false;
  if (lhs.issues < rhs.issues)
    return true;
  if (rhs.issues < lhs.issues)
    return false;
  if (lhs.redirect_behavior < rhs.redirect_behavior)
    return true;
  if (rhs.redirect_behavior < lhs.redirect_behavior)
    return false;
  if (lhs.webrtc_behavior < rhs.webrtc_behavior)
    return true;
  if (rhs.webrtc_behavior < lhs.webrtc_behavior)
    return false;
  if (lhs.match_response_origin < rhs.match_response_origin)
    return true;
  if (rhs.match_response_origin < lhs.match_response_origin)
    return false;
  if (lhs.serialized_value < rhs.serialized_value)
    return true;
  if (rhs.serialized_value < lhs.serialized_value)
    return false;
  return false;
}
template <typename StructPtrType>
ConnectionAllowlistsPtr ConnectionAllowlists::Clone() const {
  return New(
      mojo::Clone(response_url),
      mojo::Clone(enforced),
      mojo::Clone(report_only),
      mojo::Clone(reporting_source)
  );
}

template <typename T, ConnectionAllowlists::EnableIfSame<T>*>
bool ConnectionAllowlists::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->response_url, other_struct.response_url))
    return false;
  if (!mojo::Equals(this->enforced, other_struct.enforced))
    return false;
  if (!mojo::Equals(this->report_only, other_struct.report_only))
    return false;
  if (!mojo::Equals(this->reporting_source, other_struct.reporting_source))
    return false;
  return true;
}

template <typename T, ConnectionAllowlists::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.response_url < rhs.response_url)
    return true;
  if (rhs.response_url < lhs.response_url)
    return false;
  if (lhs.enforced < rhs.enforced)
    return true;
  if (rhs.enforced < lhs.enforced)
    return false;
  if (lhs.report_only < rhs.report_only)
    return true;
  if (rhs.report_only < lhs.report_only)
    return false;
  if (lhs.reporting_source < rhs.reporting_source)
    return true;
  if (rhs.reporting_source < lhs.reporting_source)
    return false;
  return false;
}


}  // network::mojom::blink

namespace mojo {


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

  static const decltype(::network::mojom::blink::ConnectionAllowlist::allowlist)& allowlist(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->allowlist;
  }

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

  static const decltype(::network::mojom::blink::ConnectionAllowlist::issues)& issues(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->issues;
  }

  static decltype(::network::mojom::blink::ConnectionAllowlist::redirect_behavior) redirect_behavior(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->redirect_behavior;
  }

  static decltype(::network::mojom::blink::ConnectionAllowlist::webrtc_behavior) webrtc_behavior(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->webrtc_behavior;
  }

  static decltype(::network::mojom::blink::ConnectionAllowlist::match_response_origin) match_response_origin(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->match_response_origin;
  }

  static const decltype(::network::mojom::blink::ConnectionAllowlist::serialized_value)& serialized_value(
      const ::network::mojom::blink::ConnectionAllowlistPtr& input) {
    return input->serialized_value;
  }

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


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

  static const decltype(::network::mojom::blink::ConnectionAllowlists::response_url)& response_url(
      const ::network::mojom::blink::ConnectionAllowlistsPtr& input) {
    return input->response_url;
  }

  static const decltype(::network::mojom::blink::ConnectionAllowlists::enforced)& enforced(
      const ::network::mojom::blink::ConnectionAllowlistsPtr& input) {
    return input->enforced;
  }

  static const decltype(::network::mojom::blink::ConnectionAllowlists::report_only)& report_only(
      const ::network::mojom::blink::ConnectionAllowlistsPtr& input) {
    return input->report_only;
  }

  static const decltype(::network::mojom::blink::ConnectionAllowlists::reporting_source)& reporting_source(
      const ::network::mojom::blink::ConnectionAllowlistsPtr& input) {
    return input->reporting_source;
  }

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

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_CONNECTION_ALLOWLIST_MOJOM_BLINK_H_