// third_party/blink/public/mojom/timing/resource_timing.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 "third_party/blink/public/mojom/timing/resource_timing.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 "third_party/blink/public/mojom/timing/resource_timing.mojom-params-data.h"
#include "third_party/blink/public/mojom/timing/resource_timing.mojom-shared-message-ids.h"

#include "third_party/blink/public/mojom/timing/resource_timing.mojom-blink-import-headers.h"
#include "third_party/blink/public/mojom/timing/resource_timing.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace blink::mojom::blink {
ServerTimingInfo::ServerTimingInfo()
    : name(),
      duration(),
      description() {}

ServerTimingInfo::ServerTimingInfo(
    const ::blink::String& name_in,
    double duration_in,
    const ::blink::String& description_in)
    : name(std::move(name_in)),
      duration(std::move(duration_in)),
      description(std::move(description_in)) {}

ServerTimingInfo::~ServerTimingInfo() = default;
size_t ServerTimingInfo::Hash(size_t seed) const {
  seed = mojo::internal::WTFHash(seed, this->name);
  seed = mojo::internal::WTFHash(seed, this->duration);
  seed = mojo::internal::WTFHash(seed, this->description);
  return seed;
}

void ServerTimingInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "name"), this->name,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "duration"), this->duration,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type double>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "description"), this->description,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ServerTimingInfo::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
ResourceTimingInfo::ResourceTimingInfo()
    : name(),
      start_time(),
      alpn_negotiated_protocol(),
      connection_info(),
      timing(),
      last_redirect_end_time(),
      response_end(),
      cache_state(),
      encoded_body_size(),
      decoded_body_size(),
      did_reuse_connection(),
      is_secure_transport(),
      allow_timing_details(),
      allow_negative_values(),
      server_timing(),
      render_blocking_status(),
      response_status(),
      content_type(),
      content_encoding(),
      initiator_url(),
      service_worker_router_info(),
      service_worker_response_source() {}

ResourceTimingInfo::ResourceTimingInfo(
    const ::blink::String& name_in,
    ::base::TimeTicks start_time_in,
    const ::blink::String& alpn_negotiated_protocol_in,
    const ::blink::String& connection_info_in,
    ::network::mojom::blink::LoadTimingInfoPtr timing_in,
    ::base::TimeTicks last_redirect_end_time_in,
    ::base::TimeTicks response_end_in,
    CacheState cache_state_in,
    uint64_t encoded_body_size_in,
    uint64_t decoded_body_size_in,
    bool did_reuse_connection_in,
    bool is_secure_transport_in,
    bool allow_timing_details_in,
    bool allow_negative_values_in,
    ::blink::Vector<ServerTimingInfoPtr> server_timing_in,
    bool render_blocking_status_in,
    uint16_t response_status_in,
    const ::blink::String& content_type_in,
    const ::blink::String& content_encoding_in,
    const ::blink::KURL& initiator_url_in,
    ::network::mojom::blink::ServiceWorkerRouterInfoPtr service_worker_router_info_in,
    ::network::mojom::blink::FetchResponseSource service_worker_response_source_in)
    : name(std::move(name_in)),
      start_time(std::move(start_time_in)),
      alpn_negotiated_protocol(std::move(alpn_negotiated_protocol_in)),
      connection_info(std::move(connection_info_in)),
      timing(std::move(timing_in)),
      last_redirect_end_time(std::move(last_redirect_end_time_in)),
      response_end(std::move(response_end_in)),
      cache_state(std::move(cache_state_in)),
      encoded_body_size(std::move(encoded_body_size_in)),
      decoded_body_size(std::move(decoded_body_size_in)),
      did_reuse_connection(std::move(did_reuse_connection_in)),
      is_secure_transport(std::move(is_secure_transport_in)),
      allow_timing_details(std::move(allow_timing_details_in)),
      allow_negative_values(std::move(allow_negative_values_in)),
      server_timing(std::move(server_timing_in)),
      render_blocking_status(std::move(render_blocking_status_in)),
      response_status(std::move(response_status_in)),
      content_type(std::move(content_type_in)),
      content_encoding(std::move(content_encoding_in)),
      initiator_url(std::move(initiator_url_in)),
      service_worker_router_info(std::move(service_worker_router_info_in)),
      service_worker_response_source(std::move(service_worker_response_source_in)) {}

ResourceTimingInfo::~ResourceTimingInfo() = default;

void ResourceTimingInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "name"), this->name,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "start_time"), this->start_time,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeTicks>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "alpn_negotiated_protocol"), this->alpn_negotiated_protocol,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "connection_info"), this->connection_info,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "timing"), this->timing,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::network::mojom::blink::LoadTimingInfoPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "last_redirect_end_time"), this->last_redirect_end_time,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeTicks>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "response_end"), this->response_end,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::TimeTicks>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "cache_state"), this->cache_state,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CacheState>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "encoded_body_size"), this->encoded_body_size,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "decoded_body_size"), this->decoded_body_size,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "did_reuse_connection"), this->did_reuse_connection,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_secure_transport"), this->is_secure_transport,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "allow_timing_details"), this->allow_timing_details,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "allow_negative_values"), this->allow_negative_values,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "server_timing"), this->server_timing,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::blink::Vector<ServerTimingInfoPtr>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "render_blocking_status"), this->render_blocking_status,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "response_status"), this->response_status,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint16_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "content_type"), this->content_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "content_encoding"), this->content_encoding,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "initiator_url"), this->initiator_url,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::KURL&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "service_worker_router_info"), this->service_worker_router_info,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::network::mojom::blink::ServiceWorkerRouterInfoPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "service_worker_response_source"), this->service_worker_response_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::network::mojom::blink::FetchResponseSource>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // blink::mojom::blink


namespace mojo {


// static
bool StructTraits<::blink::mojom::blink::ServerTimingInfo::DataView, ::blink::mojom::blink::ServerTimingInfoPtr>::Read(
    ::blink::mojom::blink::ServerTimingInfo::DataView input,
    ::blink::mojom::blink::ServerTimingInfoPtr* output) {
  bool success = true;
  ::blink::mojom::blink::ServerTimingInfoPtr result(::blink::mojom::blink::ServerTimingInfo::New());
  
      if (success && !input.ReadName(&result->name))
        success = false;
      if (success)
        result->duration = input.duration();
      if (success && !input.ReadDescription(&result->description))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::blink::ResourceTimingInfo::DataView, ::blink::mojom::blink::ResourceTimingInfoPtr>::Read(
    ::blink::mojom::blink::ResourceTimingInfo::DataView input,
    ::blink::mojom::blink::ResourceTimingInfoPtr* output) {
  bool success = true;
  ::blink::mojom::blink::ResourceTimingInfoPtr result(::blink::mojom::blink::ResourceTimingInfo::New());
  
      if (success && !input.ReadName(&result->name))
        success = false;
      if (success && !input.ReadStartTime(&result->start_time))
        success = false;
      if (success && !input.ReadAlpnNegotiatedProtocol(&result->alpn_negotiated_protocol))
        success = false;
      if (success && !input.ReadConnectionInfo(&result->connection_info))
        success = false;
      if (success && !input.ReadTiming(&result->timing))
        success = false;
      if (success && !input.ReadLastRedirectEndTime(&result->last_redirect_end_time))
        success = false;
      if (success && !input.ReadResponseEnd(&result->response_end))
        success = false;
      if (success && !input.ReadCacheState(&result->cache_state))
        success = false;
      if (success)
        result->encoded_body_size = input.encoded_body_size();
      if (success)
        result->decoded_body_size = input.decoded_body_size();
      if (success)
        result->did_reuse_connection = input.did_reuse_connection();
      if (success)
        result->is_secure_transport = input.is_secure_transport();
      if (success)
        result->allow_timing_details = input.allow_timing_details();
      if (success)
        result->allow_negative_values = input.allow_negative_values();
      if (success && !input.ReadServerTiming(&result->server_timing))
        success = false;
      if (success)
        result->render_blocking_status = input.render_blocking_status();
      if (success)
        result->response_status = input.response_status();
      if (success && !input.ReadContentType(&result->content_type))
        success = false;
      if (success && !input.ReadContentEncoding(&result->content_encoding))
        success = false;
      if (success && !input.ReadInitiatorUrl(&result->initiator_url))
        success = false;
      if (success && !input.ReadServiceWorkerRouterInfo(&result->service_worker_router_info))
        success = false;
      if (success && !input.ReadServiceWorkerResponseSource(&result->service_worker_response_source))
        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 blink::mojom::blink {




}  // blink::mojom::blink


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