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

#include "components/performance_manager/public/mojom/v8_contexts.mojom-import-headers.h"
#include "components/performance_manager/public/mojom/v8_contexts.mojom-test-utils.h"


namespace performance_manager::mojom {
IframeAttributionData::IframeAttributionData()
    : id(),
      src() {}

IframeAttributionData::IframeAttributionData(
    const std::optional<std::string>& id_in,
    const std::optional<std::string>& src_in)
    : id(std::move(id_in)),
      src(std::move(src_in)) {}

IframeAttributionData::~IframeAttributionData() = default;

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

bool IframeAttributionData::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
V8ContextDescription::V8ContextDescription()
    : token(),
      world_type(),
      world_name(),
      execution_context_token() {}

V8ContextDescription::V8ContextDescription(
    const ::blink::V8ContextToken& token_in,
    V8ContextWorldType world_type_in,
    const std::optional<std::string>& world_name_in,
    const std::optional<::blink::ExecutionContextToken>& execution_context_token_in)
    : token(std::move(token_in)),
      world_type(std::move(world_type_in)),
      world_name(std::move(world_name_in)),
      execution_context_token(std::move(execution_context_token_in)) {}

V8ContextDescription::~V8ContextDescription() = default;

void V8ContextDescription::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "token"), this->token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::V8ContextToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "world_type"), this->world_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type V8ContextWorldType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "world_name"), this->world_name,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::string>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "execution_context_token"), this->execution_context_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::ExecutionContextToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // performance_manager::mojom


namespace mojo {


// static
bool StructTraits<::performance_manager::mojom::IframeAttributionData::DataView, ::performance_manager::mojom::IframeAttributionDataPtr>::Read(
    ::performance_manager::mojom::IframeAttributionData::DataView input,
    ::performance_manager::mojom::IframeAttributionDataPtr* output) {
  bool success = true;
  ::performance_manager::mojom::IframeAttributionDataPtr result(::performance_manager::mojom::IframeAttributionData::New());
  
      if (success && !input.ReadId(&result->id))
        success = false;
      if (success && !input.ReadSrc(&result->src))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::performance_manager::mojom::V8ContextDescription::DataView, ::performance_manager::mojom::V8ContextDescriptionPtr>::Read(
    ::performance_manager::mojom::V8ContextDescription::DataView input,
    ::performance_manager::mojom::V8ContextDescriptionPtr* output) {
  bool success = true;
  ::performance_manager::mojom::V8ContextDescriptionPtr result(::performance_manager::mojom::V8ContextDescription::New());
  
      if (success && !input.ReadToken(&result->token))
        success = false;
      if (success && !input.ReadWorldType(&result->world_type))
        success = false;
      if (success && !input.ReadWorldName(&result->world_name))
        success = false;
      if (success && !input.ReadExecutionContextToken(&result->execution_context_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 performance_manager::mojom {




}  // performance_manager::mojom


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