// components/browser_apis/tab_drag/tab_drag_api.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_BROWSER_APIS_TAB_DRAG_TAB_DRAG_API_MOJOM_SHARED_H_
#define COMPONENTS_BROWSER_APIS_TAB_DRAG_TAB_DRAG_API_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/browser_apis/tab_drag/tab_drag_api.mojom-shared-internal.h"
#include "components/browser_apis/tab_strip/tab_strip_api_types.mojom-shared.h"
#include "mojo/public/mojom/base/empty.mojom-shared.h"
#include "mojo/public/mojom/base/error.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/system/data_pipe.h"



#include "components/browser_apis/tab_drag/tab_drag_api.mojom-data-view.h"  // IWYU pragma: export




namespace std {

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::tabs_api::mojom::TabDragService_StartDrag_ResponseParam_ResultDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = UnionTraits<::tabs_api::mojom::TabDragService_StartDrag_ResponseParam_ResultDataView, UserType>;

  static void Serialize(MaybeConstUserType& input,
                        MessageFragment<::tabs_api::mojom::internal::TabDragService_StartDrag_ResponseParam_Result_Data>& fragment,
                        bool inlined) {
    
    if (CallIsNullIfExists<Traits>(input)) {
       if (inlined)
        fragment->set_null();
      return;
    }

if (!inlined)
  fragment.Allocate();

    // TODO(azani): Handle unknown and objects.
    // Set the not-null flag.
fragment->size = kUnionDataSize;
fragment->tag = Traits::GetTag(input);
switch (fragment->tag) {
  case ::tabs_api::mojom::TabDragService_StartDrag_ResponseParam_ResultDataView::Tag::kSuccess: {
    decltype(Traits::success(input))
    in_success = Traits::success(input);
    mojo::internal::MessageFragment<
      typename decltype(fragment->data.f_success)::BaseType>
    value_fragment(fragment.message());
        
mojo::internal::Serialize<::mojo_base::mojom::EmptyDataView>(
  in_success,
  value_fragment);
  
MOJO_INTERNAL_CHECK_SERIALIZATION(
  mojo::internal::SendValidation::kDefault,
  !(value_fragment.is_null()),
  mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
  "null success in TabDragService_StartDrag_ResponseParam_Result union");
    fragment->data.f_success.Set(
      value_fragment.is_null() ? nullptr : value_fragment.data());
    break;
  }
  case ::tabs_api::mojom::TabDragService_StartDrag_ResponseParam_ResultDataView::Tag::kFailure: {
    decltype(Traits::failure(input))
    in_failure = Traits::failure(input);
    mojo::internal::MessageFragment<
      typename decltype(fragment->data.f_failure)::BaseType>
    value_fragment(fragment.message());
        
mojo::internal::Serialize<::mojo_base::mojom::ErrorDataView>(
  in_failure,
  value_fragment);
  
MOJO_INTERNAL_CHECK_SERIALIZATION(
  mojo::internal::SendValidation::kDefault,
  !(value_fragment.is_null()),
  mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
  "null failure in TabDragService_StartDrag_ResponseParam_Result union");
    fragment->data.f_failure.Set(
      value_fragment.is_null() ? nullptr : value_fragment.data());
    break;
  }
}
  }

  static bool Deserialize(::tabs_api::mojom::internal::TabDragService_StartDrag_ResponseParam_Result_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input || input->is_null())
      return CallSetToNullIfExists<Traits>(output);

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

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::tabs_api::mojom::TabDragService_RegisterDropTarget_ResponseParam_ResultDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = UnionTraits<::tabs_api::mojom::TabDragService_RegisterDropTarget_ResponseParam_ResultDataView, UserType>;

  static void Serialize(MaybeConstUserType& input,
                        MessageFragment<::tabs_api::mojom::internal::TabDragService_RegisterDropTarget_ResponseParam_Result_Data>& fragment,
                        bool inlined) {
    
    if (CallIsNullIfExists<Traits>(input)) {
       if (inlined)
        fragment->set_null();
      return;
    }

if (!inlined)
  fragment.Allocate();

    // TODO(azani): Handle unknown and objects.
    // Set the not-null flag.
fragment->size = kUnionDataSize;
fragment->tag = Traits::GetTag(input);
switch (fragment->tag) {
  case ::tabs_api::mojom::TabDragService_RegisterDropTarget_ResponseParam_ResultDataView::Tag::kSuccess: {
    decltype(Traits::success(input))
    in_success = Traits::success(input);
    mojo::internal::MessageFragment<
      typename decltype(fragment->data.f_success)::BaseType>
    value_fragment(fragment.message());
        
mojo::internal::Serialize<::mojo_base::mojom::EmptyDataView>(
  in_success,
  value_fragment);
  
MOJO_INTERNAL_CHECK_SERIALIZATION(
  mojo::internal::SendValidation::kDefault,
  !(value_fragment.is_null()),
  mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
  "null success in TabDragService_RegisterDropTarget_ResponseParam_Result union");
    fragment->data.f_success.Set(
      value_fragment.is_null() ? nullptr : value_fragment.data());
    break;
  }
  case ::tabs_api::mojom::TabDragService_RegisterDropTarget_ResponseParam_ResultDataView::Tag::kFailure: {
    decltype(Traits::failure(input))
    in_failure = Traits::failure(input);
    mojo::internal::MessageFragment<
      typename decltype(fragment->data.f_failure)::BaseType>
    value_fragment(fragment.message());
        
mojo::internal::Serialize<::mojo_base::mojom::ErrorDataView>(
  in_failure,
  value_fragment);
  
MOJO_INTERNAL_CHECK_SERIALIZATION(
  mojo::internal::SendValidation::kDefault,
  !(value_fragment.is_null()),
  mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
  "null failure in TabDragService_RegisterDropTarget_ResponseParam_Result union");
    fragment->data.f_failure.Set(
      value_fragment.is_null() ? nullptr : value_fragment.data());
    break;
  }
}
  }

  static bool Deserialize(::tabs_api::mojom::internal::TabDragService_RegisterDropTarget_ResponseParam_Result_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input || input->is_null())
      return CallSetToNullIfExists<Traits>(output);

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

}  // namespace internal

}  // namespace mojo


namespace tabs_api::mojom {

inline void TabDragService_StartDrag_ResponseParam_ResultDataView::GetSuccessDataView(
    ::mojo_base::mojom::EmptyDataView* output) const {
  CHECK(is_success());
  *output = ::mojo_base::mojom::EmptyDataView(data_->data.f_success.Get(), message_);
}
inline void TabDragService_StartDrag_ResponseParam_ResultDataView::GetFailureDataView(
    ::mojo_base::mojom::ErrorDataView* output) const {
  CHECK(is_failure());
  *output = ::mojo_base::mojom::ErrorDataView(data_->data.f_failure.Get(), message_);
}

inline void TabDragService_RegisterDropTarget_ResponseParam_ResultDataView::GetSuccessDataView(
    ::mojo_base::mojom::EmptyDataView* output) const {
  CHECK(is_success());
  *output = ::mojo_base::mojom::EmptyDataView(data_->data.f_success.Get(), message_);
}
inline void TabDragService_RegisterDropTarget_ResponseParam_ResultDataView::GetFailureDataView(
    ::mojo_base::mojom::ErrorDataView* output) const {
  CHECK(is_failure());
  *output = ::mojo_base::mojom::ErrorDataView(data_->data.f_failure.Get(), message_);
}


}  // tabs_api::mojom

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

#endif  // COMPONENTS_BROWSER_APIS_TAB_DRAG_TAB_DRAG_API_MOJOM_SHARED_H_