// components/metrics/public/mojom/call_stack_profile_collector.mojom-send-validation.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_METRICS_PUBLIC_MOJOM_CALL_STACK_PROFILE_COLLECTOR_MOJOM_SEND_VALIDATION_H_
#define COMPONENTS_METRICS_PUBLIC_MOJOM_CALL_STACK_PROFILE_COLLECTOR_MOJOM_SEND_VALIDATION_H_

#include "components/metrics/public/mojom/call_stack_profile_collector.mojom-shared-internal.h"
#include "components/metrics/public/mojom/profile_params.mojom-shared.h"
#include "mojo/public/mojom/base/proto_wrapper.mojom-shared.h"
#include "mojo/public/mojom/base/time.mojom-shared.h"

#include "components/metrics/public/mojom/call_stack_profile_collector.mojom-data-view.h"

#include "mojo/public/cpp/bindings/lib/send_validation_type.h"
#include "mojo/public/cpp/bindings/lib/send_validation.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization_send_validation.h"

namespace mojo::internal {

template <typename MaybeConstUserType, mojo::internal::SendValidation send_validation>
struct SendValidationSerializer<::metrics::mojom::SampledProfileDataView, MaybeConstUserType, send_validation> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::metrics::mojom::SampledProfileDataView, UserType>;
  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::metrics::mojom::internal::SampledProfile_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

      decltype(Traits::contents(input)) in_contents = Traits::contents(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->contents)::BaseType> contents_fragment(
              fragment.message());
      
      mojo::internal::Serialize<::mojo_base::mojom::ProtoWrapperDataView, send_validation>(
        in_contents,
        contents_fragment);

      fragment->contents.Set(
          contents_fragment.is_null() ? nullptr : contents_fragment.data());

      
      MOJO_INTERNAL_CHECK_SERIALIZATION(
        send_validation,
        !(fragment->contents.is_null()),
        mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
        "null contents in SampledProfile struct");
  }
};

}  // namespace mojo::internal

#endif  // COMPONENTS_METRICS_PUBLIC_MOJOM_CALL_STACK_PROFILE_COLLECTOR_MOJOM_SEND_VALIDATION_H_