// services/network/public/mojom/load_timing_internal_info.mojom.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/load_timing_internal_info.mojom.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/load_timing_internal_info.mojom-params-data.h"
#include "services/network/public/mojom/load_timing_internal_info.mojom-shared-message-ids.h"

#include "services/network/public/mojom/load_timing_internal_info.mojom-import-headers.h"
#include "services/network/public/mojom/load_timing_internal_info.mojom-test-utils.h"


namespace network::mojom {
DohResolutionDetails::DohResolutionDetails()
    : session_source(),
      connection_info() {}

DohResolutionDetails::DohResolutionDetails(
    SessionSource session_source_in,
    HttpConnectionInfoCoarse connection_info_in)
    : session_source(std::move(session_source_in)),
      connection_info(std::move(connection_info_in)) {}

DohResolutionDetails::~DohResolutionDetails() = default;
size_t DohResolutionDetails::Hash(size_t seed) const {
  seed = mojo::internal::Hash(seed, this->session_source);
  seed = mojo::internal::Hash(seed, this->connection_info);
  return seed;
}

void DohResolutionDetails::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "session_source"), this->session_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type SessionSource>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "connection_info"), this->connection_info,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type HttpConnectionInfoCoarse>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool DohResolutionDetails::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
ResolutionDetails::ResolutionDetails()
    : source(),
      task_completion_delay(),
      secure_dns_attempted(),
      doh_details() {}

ResolutionDetails::ResolutionDetails(
    ResolutionSource source_in,
    std::optional<::base::TimeDelta> task_completion_delay_in,
    bool secure_dns_attempted_in,
    DohResolutionDetailsPtr doh_details_in)
    : source(std::move(source_in)),
      task_completion_delay(std::move(task_completion_delay_in)),
      secure_dns_attempted(std::move(secure_dns_attempted_in)),
      doh_details(std::move(doh_details_in)) {}

ResolutionDetails::~ResolutionDetails() = default;

void ResolutionDetails::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "source"), this->source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ResolutionSource>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "task_completion_delay"), this->task_completion_delay,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::base::TimeDelta>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "secure_dns_attempted"), this->secure_dns_attempted,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "doh_details"), this->doh_details,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type DohResolutionDetailsPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ResolutionDetails::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
LoadTimingInternalInfo::LoadTimingInternalInfo()
    : max_stream_limit_pending_delay(),
      create_stream_delay(),
      connected_callback_delay(),
      accept_ch_frame_received(),
      initialize_stream_delay(),
      session_source(),
      advertised_alt_svc_state(),
      http_network_session_quic_enabled(),
      resolution_details() {}

LoadTimingInternalInfo::LoadTimingInternalInfo(
    std::optional<::base::TimeDelta> max_stream_limit_pending_delay_in,
    ::base::TimeDelta create_stream_delay_in,
    ::base::TimeDelta connected_callback_delay_in,
    bool accept_ch_frame_received_in,
    ::base::TimeDelta initialize_stream_delay_in,
    std::optional<SessionSource> session_source_in,
    AdvertisedAltSvcState advertised_alt_svc_state_in,
    bool http_network_session_quic_enabled_in,
    ResolutionDetailsPtr resolution_details_in)
    : max_stream_limit_pending_delay(std::move(max_stream_limit_pending_delay_in)),
      create_stream_delay(std::move(create_stream_delay_in)),
      connected_callback_delay(std::move(connected_callback_delay_in)),
      accept_ch_frame_received(std::move(accept_ch_frame_received_in)),
      initialize_stream_delay(std::move(initialize_stream_delay_in)),
      session_source(std::move(session_source_in)),
      advertised_alt_svc_state(std::move(advertised_alt_svc_state_in)),
      http_network_session_quic_enabled(std::move(http_network_session_quic_enabled_in)),
      resolution_details(std::move(resolution_details_in)) {}

LoadTimingInternalInfo::~LoadTimingInternalInfo() = default;

void LoadTimingInternalInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "max_stream_limit_pending_delay"), this->max_stream_limit_pending_delay,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::base::TimeDelta>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "create_stream_delay"), this->create_stream_delay,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeDelta>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "connected_callback_delay"), this->connected_callback_delay,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeDelta>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "accept_ch_frame_received"), this->accept_ch_frame_received,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "initialize_stream_delay"), this->initialize_stream_delay,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeDelta>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "session_source"), this->session_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<SessionSource>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "advertised_alt_svc_state"), this->advertised_alt_svc_state,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type AdvertisedAltSvcState>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "http_network_session_quic_enabled"), this->http_network_session_quic_enabled,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "resolution_details"), this->resolution_details,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ResolutionDetailsPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // network::mojom


namespace mojo {


// static
bool StructTraits<::network::mojom::DohResolutionDetails::DataView, ::network::mojom::DohResolutionDetailsPtr>::Read(
    ::network::mojom::DohResolutionDetails::DataView input,
    ::network::mojom::DohResolutionDetailsPtr* output) {
  bool success = true;
  ::network::mojom::DohResolutionDetailsPtr result(::network::mojom::DohResolutionDetails::New());
  
      if (success && !input.ReadSessionSource(&result->session_source))
        success = false;
      if (success && !input.ReadConnectionInfo(&result->connection_info))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::network::mojom::ResolutionDetails::DataView, ::network::mojom::ResolutionDetailsPtr>::Read(
    ::network::mojom::ResolutionDetails::DataView input,
    ::network::mojom::ResolutionDetailsPtr* output) {
  bool success = true;
  ::network::mojom::ResolutionDetailsPtr result(::network::mojom::ResolutionDetails::New());
  
      if (success && !input.ReadSource(&result->source))
        success = false;
      if (success && !input.ReadTaskCompletionDelay(&result->task_completion_delay))
        success = false;
      if (success)
        result->secure_dns_attempted = input.secure_dns_attempted();
      if (success && !input.ReadDohDetails(&result->doh_details))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::network::mojom::LoadTimingInternalInfo::DataView, ::network::mojom::LoadTimingInternalInfoPtr>::Read(
    ::network::mojom::LoadTimingInternalInfo::DataView input,
    ::network::mojom::LoadTimingInternalInfoPtr* output) {
  bool success = true;
  ::network::mojom::LoadTimingInternalInfoPtr result(::network::mojom::LoadTimingInternalInfo::New());
  
      if (success && !input.ReadMaxStreamLimitPendingDelay(&result->max_stream_limit_pending_delay))
        success = false;
      if (success && !input.ReadCreateStreamDelay(&result->create_stream_delay))
        success = false;
      if (success && !input.ReadConnectedCallbackDelay(&result->connected_callback_delay))
        success = false;
      if (success)
        result->accept_ch_frame_received = input.accept_ch_frame_received();
      if (success && !input.ReadInitializeStreamDelay(&result->initialize_stream_delay))
        success = false;
      if (success && !input.ReadSessionSource(&result->session_source)) {
        success = false;
      }
      if (success && !input.ReadAdvertisedAltSvcState(&result->advertised_alt_svc_state))
        success = false;
      if (success)
        result->http_network_session_quic_enabled = input.http_network_session_quic_enabled();
      if (success && !input.ReadResolutionDetails(&result->resolution_details))
        success = false;
  *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 {




}  // network::mojom


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