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

// Copyright 2016 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_SHARED_H_
#define COMPONENTS_METRICS_PUBLIC_MOJOM_CALL_STACK_PROFILE_COLLECTOR_MOJOM_SHARED_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/system/message_pipe.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.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 "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/system/data_pipe.h"



#include "components/metrics/public/mojom/call_stack_profile_collector.mojom-data-view.h"  // IWYU pragma: export




namespace std {

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::metrics::mojom::SampledProfileDataView, MaybeConstUserType> {
  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>(
      in_contents,
      contents_fragment);

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

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

  static bool Deserialize(::metrics::mojom::internal::SampledProfile_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::metrics::mojom::SampledProfileDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal

}  // namespace mojo


namespace metrics::mojom {

inline void SampledProfileDataView::GetContentsDataView(
    ::mojo_base::mojom::ProtoWrapperDataView* output) {
  auto pointer = data_->contents.Get();
  *output = ::mojo_base::mojom::ProtoWrapperDataView(pointer, message_);
}



}  // metrics::mojom

// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.

#endif  // COMPONENTS_METRICS_PUBLIC_MOJOM_CALL_STACK_PROFILE_COLLECTOR_MOJOM_SHARED_H_