// components/digital_goods/mojom/digital_goods.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 "components/digital_goods/mojom/digital_goods.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 "components/digital_goods/mojom/digital_goods.mojom-params-data.h"
#include "components/digital_goods/mojom/digital_goods.mojom-shared-message-ids.h"

#include "components/digital_goods/mojom/digital_goods.mojom-blink-import-headers.h"
#include "components/digital_goods/mojom/digital_goods.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace payments::mojom::blink {
ItemDetails::ItemDetails()
    : item_id(),
      title(),
      description(),
      price(),
      subscription_period(),
      free_trial_period(),
      introductory_price(),
      introductory_price_period(),
      introductory_price_cycles(),
      type(),
      icon_urls() {}

ItemDetails::ItemDetails(
    const ::blink::String& item_id_in,
    const ::blink::String& title_in,
    const ::blink::String& description_in,
    ::payments::mojom::blink::PaymentCurrencyAmountPtr price_in,
    const ::blink::String& subscription_period_in,
    const ::blink::String& free_trial_period_in,
    ::payments::mojom::blink::PaymentCurrencyAmountPtr introductory_price_in,
    const ::blink::String& introductory_price_period_in)
    : item_id(std::move(item_id_in)),
      title(std::move(title_in)),
      description(std::move(description_in)),
      price(std::move(price_in)),
      subscription_period(std::move(subscription_period_in)),
      free_trial_period(std::move(free_trial_period_in)),
      introductory_price(std::move(introductory_price_in)),
      introductory_price_period(std::move(introductory_price_period_in)),
      introductory_price_cycles(),
      type(),
      icon_urls() {}

ItemDetails::ItemDetails(
    const ::blink::String& item_id_in,
    const ::blink::String& title_in,
    const ::blink::String& description_in,
    ::payments::mojom::blink::PaymentCurrencyAmountPtr price_in,
    const ::blink::String& subscription_period_in,
    const ::blink::String& free_trial_period_in,
    ::payments::mojom::blink::PaymentCurrencyAmountPtr introductory_price_in,
    const ::blink::String& introductory_price_period_in,
    uint32_t introductory_price_cycles_in,
    ItemType type_in,
    std::optional<::blink::Vector<::blink::KURL>> icon_urls_in)
    : item_id(std::move(item_id_in)),
      title(std::move(title_in)),
      description(std::move(description_in)),
      price(std::move(price_in)),
      subscription_period(std::move(subscription_period_in)),
      free_trial_period(std::move(free_trial_period_in)),
      introductory_price(std::move(introductory_price_in)),
      introductory_price_period(std::move(introductory_price_period_in)),
      introductory_price_cycles(std::move(introductory_price_cycles_in)),
      type(std::move(type_in)),
      icon_urls(std::move(icon_urls_in)) {}

ItemDetails::~ItemDetails() = default;

void ItemDetails::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "item_id"), this->item_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "title"), this->title,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#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)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "price"), this->price,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::payments::mojom::blink::PaymentCurrencyAmountPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "subscription_period"), this->subscription_period,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "free_trial_period"), this->free_trial_period,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "introductory_price"), this->introductory_price,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::payments::mojom::blink::PaymentCurrencyAmountPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "introductory_price_period"), this->introductory_price_period,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "introductory_price_cycles"), this->introductory_price_cycles,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "type"), this->type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ItemType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "icon_urls"), this->icon_urls,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::Vector<::blink::KURL>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ItemDetails::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
PurchaseReference::PurchaseReference()
    : item_id(),
      purchase_token() {}

PurchaseReference::PurchaseReference(
    const ::blink::String& item_id_in,
    const ::blink::String& purchase_token_in)
    : item_id(std::move(item_id_in)),
      purchase_token(std::move(purchase_token_in)) {}

PurchaseReference::~PurchaseReference() = default;
size_t PurchaseReference::Hash(size_t seed) const {
  seed = mojo::internal::WTFHash(seed, this->item_id);
  seed = mojo::internal::WTFHash(seed, this->purchase_token);
  return seed;
}

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

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


}  // payments::mojom::blink


namespace mojo {


// static
bool StructTraits<::payments::mojom::blink::ItemDetails::DataView, ::payments::mojom::blink::ItemDetailsPtr>::Read(
    ::payments::mojom::blink::ItemDetails::DataView input,
    ::payments::mojom::blink::ItemDetailsPtr* output) {
  bool success = true;
  ::payments::mojom::blink::ItemDetailsPtr result(::payments::mojom::blink::ItemDetails::New());
  
      if (success && !input.ReadItemId(&result->item_id))
        success = false;
      if (success && !input.ReadTitle(&result->title))
        success = false;
      if (success && !input.ReadDescription(&result->description))
        success = false;
      if (success && !input.ReadPrice(&result->price))
        success = false;
      if (success && !input.ReadSubscriptionPeriod(&result->subscription_period))
        success = false;
      if (success && !input.ReadFreeTrialPeriod(&result->free_trial_period))
        success = false;
      if (success && !input.ReadIntroductoryPrice(&result->introductory_price))
        success = false;
      if (success && !input.ReadIntroductoryPricePeriod(&result->introductory_price_period))
        success = false;
      if (success)
        result->introductory_price_cycles = input.introductory_price_cycles();
      if (success && !input.ReadType(&result->type))
        success = false;
      if (success && !input.ReadIconUrls(&result->icon_urls))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::payments::mojom::blink::PurchaseReference::DataView, ::payments::mojom::blink::PurchaseReferencePtr>::Read(
    ::payments::mojom::blink::PurchaseReference::DataView input,
    ::payments::mojom::blink::PurchaseReferencePtr* output) {
  bool success = true;
  ::payments::mojom::blink::PurchaseReferencePtr result(::payments::mojom::blink::PurchaseReference::New());
  
      if (success && !input.ReadItemId(&result->item_id))
        success = false;
      if (success && !input.ReadPurchaseToken(&result->purchase_token))
        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 payments::mojom::blink {




}  // payments::mojom::blink


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