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

#include "third_party/blink/public/mojom/parakeet/ad_request.mojom-import-headers.h"
#include "third_party/blink/public/mojom/parakeet/ad_request.mojom-test-utils.h"


namespace blink::mojom {
AdProperties::AdProperties()
    : width(),
      height(),
      slot(),
      lang(),
      ad_type(),
      bid_floor() {}

AdProperties::AdProperties(
    const std::string& width_in,
    const std::string& height_in,
    const std::string& slot_in,
    const std::string& lang_in,
    const std::string& ad_type_in,
    double bid_floor_in)
    : width(std::move(width_in)),
      height(std::move(height_in)),
      slot(std::move(slot_in)),
      lang(std::move(lang_in)),
      ad_type(std::move(ad_type_in)),
      bid_floor(std::move(bid_floor_in)) {}

AdProperties::~AdProperties() = default;
size_t AdProperties::Hash(size_t seed) const {
  seed = mojo::internal::Hash(seed, this->width);
  seed = mojo::internal::Hash(seed, this->height);
  seed = mojo::internal::Hash(seed, this->slot);
  seed = mojo::internal::Hash(seed, this->lang);
  seed = mojo::internal::Hash(seed, this->ad_type);
  seed = mojo::internal::Hash(seed, this->bid_floor);
  return seed;
}

void AdProperties::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "width"), this->width,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "height"), this->height,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "slot"), this->slot,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "lang"), this->lang,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ad_type"), this->ad_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "bid_floor"), this->bid_floor,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type double>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool AdProperties::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
AdGeolocation::AdGeolocation()
    : latitude(),
      longitude() {}

AdGeolocation::AdGeolocation(
    double latitude_in,
    double longitude_in)
    : latitude(std::move(latitude_in)),
      longitude(std::move(longitude_in)) {}

AdGeolocation::~AdGeolocation() = default;
size_t AdGeolocation::Hash(size_t seed) const {
  seed = mojo::internal::Hash(seed, this->latitude);
  seed = mojo::internal::Hash(seed, this->longitude);
  return seed;
}

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

bool AdGeolocation::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
AdTargeting::AdTargeting()
    : interests(),
      geolocation() {}

AdTargeting::AdTargeting(
    std::optional<std::vector<std::string>> interests_in,
    AdGeolocationPtr geolocation_in)
    : interests(std::move(interests_in)),
      geolocation(std::move(geolocation_in)) {}

AdTargeting::~AdTargeting() = default;

void AdTargeting::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "interests"), this->interests,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::vector<std::string>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "geolocation"), this->geolocation,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type AdGeolocationPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool AdTargeting::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
AdRequestConfig::AdRequestConfig()
    : ad_request_url(),
      ad_properties(),
      publisher_code(),
      targeting(),
      anonymized_proxied_signals(),
      fallback_source() {}

AdRequestConfig::AdRequestConfig(
    const ::GURL& ad_request_url_in,
    std::vector<AdPropertiesPtr> ad_properties_in,
    const std::optional<std::string>& publisher_code_in,
    AdTargetingPtr targeting_in,
    std::optional<std::vector<AdSignals>> anonymized_proxied_signals_in,
    const std::optional<::GURL>& fallback_source_in)
    : ad_request_url(std::move(ad_request_url_in)),
      ad_properties(std::move(ad_properties_in)),
      publisher_code(std::move(publisher_code_in)),
      targeting(std::move(targeting_in)),
      anonymized_proxied_signals(std::move(anonymized_proxied_signals_in)),
      fallback_source(std::move(fallback_source_in)) {}

AdRequestConfig::~AdRequestConfig() = default;

void AdRequestConfig::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ad_request_url"), this->ad_request_url,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::GURL&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ad_properties"), this->ad_properties,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::vector<AdPropertiesPtr>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "publisher_code"), this->publisher_code,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::string>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "targeting"), this->targeting,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type AdTargetingPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "anonymized_proxied_signals"), this->anonymized_proxied_signals,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::vector<AdSignals>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "fallback_source"), this->fallback_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::GURL>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // blink::mojom


namespace mojo {


// static
bool StructTraits<::blink::mojom::AdProperties::DataView, ::blink::mojom::AdPropertiesPtr>::Read(
    ::blink::mojom::AdProperties::DataView input,
    ::blink::mojom::AdPropertiesPtr* output) {
  bool success = true;
  ::blink::mojom::AdPropertiesPtr result(::blink::mojom::AdProperties::New());
  
      if (success && !input.ReadWidth(&result->width))
        success = false;
      if (success && !input.ReadHeight(&result->height))
        success = false;
      if (success && !input.ReadSlot(&result->slot))
        success = false;
      if (success && !input.ReadLang(&result->lang))
        success = false;
      if (success && !input.ReadAdType(&result->ad_type))
        success = false;
      if (success)
        result->bid_floor = input.bid_floor();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::AdGeolocation::DataView, ::blink::mojom::AdGeolocationPtr>::Read(
    ::blink::mojom::AdGeolocation::DataView input,
    ::blink::mojom::AdGeolocationPtr* output) {
  bool success = true;
  ::blink::mojom::AdGeolocationPtr result(::blink::mojom::AdGeolocation::New());
  
      if (success)
        result->latitude = input.latitude();
      if (success)
        result->longitude = input.longitude();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::AdTargeting::DataView, ::blink::mojom::AdTargetingPtr>::Read(
    ::blink::mojom::AdTargeting::DataView input,
    ::blink::mojom::AdTargetingPtr* output) {
  bool success = true;
  ::blink::mojom::AdTargetingPtr result(::blink::mojom::AdTargeting::New());
  
      if (success && !input.ReadInterests(&result->interests))
        success = false;
      if (success && !input.ReadGeolocation(&result->geolocation))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::AdRequestConfig::DataView, ::blink::mojom::AdRequestConfigPtr>::Read(
    ::blink::mojom::AdRequestConfig::DataView input,
    ::blink::mojom::AdRequestConfigPtr* output) {
  bool success = true;
  ::blink::mojom::AdRequestConfigPtr result(::blink::mojom::AdRequestConfig::New());
  
      if (success && !input.ReadAdRequestUrl(&result->ad_request_url))
        success = false;
      if (success && !input.ReadAdProperties(&result->ad_properties))
        success = false;
      if (success && !input.ReadPublisherCode(&result->publisher_code))
        success = false;
      if (success && !input.ReadTargeting(&result->targeting))
        success = false;
      if (success && !input.ReadAnonymizedProxiedSignals(&result->anonymized_proxied_signals))
        success = false;
      if (success && !input.ReadFallbackSource(&result->fallback_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::mojom


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