// services/network/public/mojom/ssl_info.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_SSL_INFO_MOJOM_BLINK_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_SSL_INFO_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/ssl_info.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/ssl_info.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/ssl_info.mojom-blink-forward.h"  // IWYU pragma: export
#include "services/network/public/mojom/ct_policy_status.mojom-blink.h"
#include "services/network/public/mojom/hash_value.mojom-blink.h"
#include "services/network/public/mojom/signed_certificate_timestamp_and_status.mojom-blink.h"
#include "services/network/public/mojom/x509_certificate.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 "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 SSLInfo {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<SSLInfo, T>::value>;
  using DataView = SSLInfoDataView;
  using Data_ = internal::SSLInfo_Data;

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

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

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


  SSLInfo();

  SSLInfo(
      const ::scoped_refptr<::net::X509Certificate>& cert,
      const ::scoped_refptr<::net::X509Certificate>& unverified_cert,
      uint32_t cert_status,
      uint16_t key_exchange_group,
      uint16_t peer_signature_algorithm,
      int32_t connection_status,
      bool is_issued_by_known_root,
      bool pkp_bypassed,
      bool client_cert_sent,
      bool encrypted_client_hello,
      SSLInfoHandshakeType handshake_type,
      ::blink::Vector<::network::mojom::blink::SHA256HashValuePtr> public_key_hashes,
      ::blink::Vector<::net::SignedCertificateTimestampAndStatus> signed_certificate_timestamps,
      ::net::ct::CTPolicyCompliance ct_policy_compliance,
      bool is_fatal_cert_error);

SSLInfo(const SSLInfo&) = delete;
SSLInfo& operator=(const SSLInfo&) = delete;

  ~SSLInfo();

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

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

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

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

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

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

  
  ::scoped_refptr<::net::X509Certificate> cert;
  
  ::scoped_refptr<::net::X509Certificate> unverified_cert;
  
  uint32_t cert_status;
  
  uint16_t key_exchange_group;
  
  uint16_t peer_signature_algorithm;
  
  int32_t connection_status;
  
  bool is_issued_by_known_root;
  
  bool pkp_bypassed;
  
  bool client_cert_sent;
  
  bool encrypted_client_hello;
  
  SSLInfoHandshakeType handshake_type;
  
  ::blink::Vector<::network::mojom::blink::SHA256HashValuePtr> public_key_hashes;
  
  ::blink::Vector<::net::SignedCertificateTimestampAndStatus> signed_certificate_timestamps;
  
  ::net::ct::CTPolicyCompliance ct_policy_compliance;
  
  bool is_fatal_cert_error;

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

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

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

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

template <typename StructPtrType>
SSLInfoPtr SSLInfo::Clone() const {
  return New(
      mojo::Clone(cert),
      mojo::Clone(unverified_cert),
      mojo::Clone(cert_status),
      mojo::Clone(key_exchange_group),
      mojo::Clone(peer_signature_algorithm),
      mojo::Clone(connection_status),
      mojo::Clone(is_issued_by_known_root),
      mojo::Clone(pkp_bypassed),
      mojo::Clone(client_cert_sent),
      mojo::Clone(encrypted_client_hello),
      mojo::Clone(handshake_type),
      mojo::Clone(public_key_hashes),
      mojo::Clone(signed_certificate_timestamps),
      mojo::Clone(ct_policy_compliance),
      mojo::Clone(is_fatal_cert_error)
  );
}

template <typename T, SSLInfo::EnableIfSame<T>*>
bool SSLInfo::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->cert, other_struct.cert))
    return false;
  if (!mojo::Equals(this->unverified_cert, other_struct.unverified_cert))
    return false;
  if (!mojo::Equals(this->cert_status, other_struct.cert_status))
    return false;
  if (!mojo::Equals(this->key_exchange_group, other_struct.key_exchange_group))
    return false;
  if (!mojo::Equals(this->peer_signature_algorithm, other_struct.peer_signature_algorithm))
    return false;
  if (!mojo::Equals(this->connection_status, other_struct.connection_status))
    return false;
  if (!mojo::Equals(this->is_issued_by_known_root, other_struct.is_issued_by_known_root))
    return false;
  if (!mojo::Equals(this->pkp_bypassed, other_struct.pkp_bypassed))
    return false;
  if (!mojo::Equals(this->client_cert_sent, other_struct.client_cert_sent))
    return false;
  if (!mojo::Equals(this->encrypted_client_hello, other_struct.encrypted_client_hello))
    return false;
  if (!mojo::Equals(this->handshake_type, other_struct.handshake_type))
    return false;
  if (!mojo::Equals(this->public_key_hashes, other_struct.public_key_hashes))
    return false;
  if (!mojo::Equals(this->signed_certificate_timestamps, other_struct.signed_certificate_timestamps))
    return false;
  if (!mojo::Equals(this->ct_policy_compliance, other_struct.ct_policy_compliance))
    return false;
  if (!mojo::Equals(this->is_fatal_cert_error, other_struct.is_fatal_cert_error))
    return false;
  return true;
}

template <typename T, SSLInfo::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.cert < rhs.cert)
    return true;
  if (rhs.cert < lhs.cert)
    return false;
  if (lhs.unverified_cert < rhs.unverified_cert)
    return true;
  if (rhs.unverified_cert < lhs.unverified_cert)
    return false;
  if (lhs.cert_status < rhs.cert_status)
    return true;
  if (rhs.cert_status < lhs.cert_status)
    return false;
  if (lhs.key_exchange_group < rhs.key_exchange_group)
    return true;
  if (rhs.key_exchange_group < lhs.key_exchange_group)
    return false;
  if (lhs.peer_signature_algorithm < rhs.peer_signature_algorithm)
    return true;
  if (rhs.peer_signature_algorithm < lhs.peer_signature_algorithm)
    return false;
  if (lhs.connection_status < rhs.connection_status)
    return true;
  if (rhs.connection_status < lhs.connection_status)
    return false;
  if (lhs.is_issued_by_known_root < rhs.is_issued_by_known_root)
    return true;
  if (rhs.is_issued_by_known_root < lhs.is_issued_by_known_root)
    return false;
  if (lhs.pkp_bypassed < rhs.pkp_bypassed)
    return true;
  if (rhs.pkp_bypassed < lhs.pkp_bypassed)
    return false;
  if (lhs.client_cert_sent < rhs.client_cert_sent)
    return true;
  if (rhs.client_cert_sent < lhs.client_cert_sent)
    return false;
  if (lhs.encrypted_client_hello < rhs.encrypted_client_hello)
    return true;
  if (rhs.encrypted_client_hello < lhs.encrypted_client_hello)
    return false;
  if (lhs.handshake_type < rhs.handshake_type)
    return true;
  if (rhs.handshake_type < lhs.handshake_type)
    return false;
  if (lhs.public_key_hashes < rhs.public_key_hashes)
    return true;
  if (rhs.public_key_hashes < lhs.public_key_hashes)
    return false;
  if (lhs.signed_certificate_timestamps < rhs.signed_certificate_timestamps)
    return true;
  if (rhs.signed_certificate_timestamps < lhs.signed_certificate_timestamps)
    return false;
  if (lhs.ct_policy_compliance < rhs.ct_policy_compliance)
    return true;
  if (rhs.ct_policy_compliance < lhs.ct_policy_compliance)
    return false;
  if (lhs.is_fatal_cert_error < rhs.is_fatal_cert_error)
    return true;
  if (rhs.is_fatal_cert_error < lhs.is_fatal_cert_error)
    return false;
  return false;
}


}  // network::mojom::blink

namespace mojo {


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

  static const decltype(::network::mojom::blink::SSLInfo::cert)& cert(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->cert;
  }

  static const decltype(::network::mojom::blink::SSLInfo::unverified_cert)& unverified_cert(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->unverified_cert;
  }

  static decltype(::network::mojom::blink::SSLInfo::cert_status) cert_status(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->cert_status;
  }

  static decltype(::network::mojom::blink::SSLInfo::key_exchange_group) key_exchange_group(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->key_exchange_group;
  }

  static decltype(::network::mojom::blink::SSLInfo::peer_signature_algorithm) peer_signature_algorithm(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->peer_signature_algorithm;
  }

  static decltype(::network::mojom::blink::SSLInfo::connection_status) connection_status(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->connection_status;
  }

  static decltype(::network::mojom::blink::SSLInfo::is_issued_by_known_root) is_issued_by_known_root(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->is_issued_by_known_root;
  }

  static decltype(::network::mojom::blink::SSLInfo::pkp_bypassed) pkp_bypassed(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->pkp_bypassed;
  }

  static decltype(::network::mojom::blink::SSLInfo::client_cert_sent) client_cert_sent(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->client_cert_sent;
  }

  static decltype(::network::mojom::blink::SSLInfo::encrypted_client_hello) encrypted_client_hello(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->encrypted_client_hello;
  }

  static decltype(::network::mojom::blink::SSLInfo::handshake_type) handshake_type(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->handshake_type;
  }

  static const decltype(::network::mojom::blink::SSLInfo::public_key_hashes)& public_key_hashes(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->public_key_hashes;
  }

  static const decltype(::network::mojom::blink::SSLInfo::signed_certificate_timestamps)& signed_certificate_timestamps(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->signed_certificate_timestamps;
  }

  static decltype(::network::mojom::blink::SSLInfo::ct_policy_compliance) ct_policy_compliance(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->ct_policy_compliance;
  }

  static decltype(::network::mojom::blink::SSLInfo::is_fatal_cert_error) is_fatal_cert_error(
      const ::network::mojom::blink::SSLInfoPtr& input) {
    return input->is_fatal_cert_error;
  }

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

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_SSL_INFO_MOJOM_BLINK_H_