// services/network/public/mojom/ssl_info.mojom-blink.cc 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.

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "services/network/public/mojom/ssl_info.mojom-blink.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "services/network/public/mojom/ssl_info.mojom-params-data.h"
#include "services/network/public/mojom/ssl_info.mojom-shared-message-ids.h"

#include "services/network/public/mojom/ssl_info.mojom-blink-import-headers.h"
#include "services/network/public/mojom/ssl_info.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace network::mojom::blink {
SSLInfo::SSLInfo()
    : cert(),
      unverified_cert(),
      cert_status(),
      key_exchange_group(),
      peer_signature_algorithm(),
      connection_status(),
      is_issued_by_known_root(),
      pkp_bypassed(),
      client_cert_sent(),
      encrypted_client_hello(),
      handshake_type(),
      public_key_hashes(),
      signed_certificate_timestamps(),
      ct_policy_compliance(),
      is_fatal_cert_error() {}

SSLInfo::SSLInfo(
    const ::scoped_refptr<::net::X509Certificate>& cert_in,
    const ::scoped_refptr<::net::X509Certificate>& unverified_cert_in,
    uint32_t cert_status_in,
    uint16_t key_exchange_group_in,
    uint16_t peer_signature_algorithm_in,
    int32_t connection_status_in,
    bool is_issued_by_known_root_in,
    bool pkp_bypassed_in,
    bool client_cert_sent_in,
    bool encrypted_client_hello_in,
    SSLInfoHandshakeType handshake_type_in,
    ::blink::Vector<::network::mojom::blink::SHA256HashValuePtr> public_key_hashes_in,
    ::blink::Vector<::net::SignedCertificateTimestampAndStatus> signed_certificate_timestamps_in,
    ::net::ct::CTPolicyCompliance ct_policy_compliance_in,
    bool is_fatal_cert_error_in)
    : cert(std::move(cert_in)),
      unverified_cert(std::move(unverified_cert_in)),
      cert_status(std::move(cert_status_in)),
      key_exchange_group(std::move(key_exchange_group_in)),
      peer_signature_algorithm(std::move(peer_signature_algorithm_in)),
      connection_status(std::move(connection_status_in)),
      is_issued_by_known_root(std::move(is_issued_by_known_root_in)),
      pkp_bypassed(std::move(pkp_bypassed_in)),
      client_cert_sent(std::move(client_cert_sent_in)),
      encrypted_client_hello(std::move(encrypted_client_hello_in)),
      handshake_type(std::move(handshake_type_in)),
      public_key_hashes(std::move(public_key_hashes_in)),
      signed_certificate_timestamps(std::move(signed_certificate_timestamps_in)),
      ct_policy_compliance(std::move(ct_policy_compliance_in)),
      is_fatal_cert_error(std::move(is_fatal_cert_error_in)) {}

SSLInfo::~SSLInfo() = default;

void SSLInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "cert"), this->cert,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::scoped_refptr<::net::X509Certificate>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "unverified_cert"), this->unverified_cert,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::scoped_refptr<::net::X509Certificate>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "cert_status"), this->cert_status,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "key_exchange_group"), this->key_exchange_group,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint16_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "peer_signature_algorithm"), this->peer_signature_algorithm,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint16_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "connection_status"), this->connection_status,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_issued_by_known_root"), this->is_issued_by_known_root,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "pkp_bypassed"), this->pkp_bypassed,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "client_cert_sent"), this->client_cert_sent,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "encrypted_client_hello"), this->encrypted_client_hello,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "handshake_type"), this->handshake_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type SSLInfoHandshakeType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "public_key_hashes"), this->public_key_hashes,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::blink::Vector<::network::mojom::blink::SHA256HashValuePtr>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "signed_certificate_timestamps"), this->signed_certificate_timestamps,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::Vector<::net::SignedCertificateTimestampAndStatus>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ct_policy_compliance"), this->ct_policy_compliance,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::net::ct::CTPolicyCompliance>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_fatal_cert_error"), this->is_fatal_cert_error,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool SSLInfo::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // network::mojom::blink


namespace mojo {


// static
bool StructTraits<::network::mojom::blink::SSLInfo::DataView, ::network::mojom::blink::SSLInfoPtr>::Read(
    ::network::mojom::blink::SSLInfo::DataView input,
    ::network::mojom::blink::SSLInfoPtr* output) {
  bool success = true;
  ::network::mojom::blink::SSLInfoPtr result(::network::mojom::blink::SSLInfo::New());
  
      if (success && !input.ReadCert(&result->cert))
        success = false;
      if (success && !input.ReadUnverifiedCert(&result->unverified_cert))
        success = false;
      if (success)
        result->cert_status = input.cert_status();
      if (success)
        result->key_exchange_group = input.key_exchange_group();
      if (success)
        result->peer_signature_algorithm = input.peer_signature_algorithm();
      if (success)
        result->connection_status = input.connection_status();
      if (success)
        result->is_issued_by_known_root = input.is_issued_by_known_root();
      if (success)
        result->pkp_bypassed = input.pkp_bypassed();
      if (success)
        result->client_cert_sent = input.client_cert_sent();
      if (success)
        result->encrypted_client_hello = input.encrypted_client_hello();
      if (success && !input.ReadHandshakeType(&result->handshake_type))
        success = false;
      if (success && !input.ReadPublicKeyHashes(&result->public_key_hashes))
        success = false;
      if (success && !input.ReadSignedCertificateTimestamps(&result->signed_certificate_timestamps))
        success = false;
      if (success && !input.ReadCtPolicyCompliance(&result->ct_policy_compliance))
        success = false;
      if (success)
        result->is_fatal_cert_error = input.is_fatal_cert_error();
  *output = std::move(result);
  return success;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace network::mojom::blink {




}  // network::mojom::blink


#if defined(__clang__)
#pragma clang diagnostic pop
#endif