// ui/gfx/mojom/gpu_fence_handle.mojom-data-view.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.

// This file defines XDataView for type traits and can be included in
// _mojom_traits.h definitions but otherwise please use .mojom-forward.h,
// .mojom-shared.h or .mojom.h.

// IWYU pragma: private
// IWYU pragma: friend "traits"

#ifndef UI_GFX_MOJOM_GPU_FENCE_HANDLE_MOJOM_DATA_VIEW_H_
#define UI_GFX_MOJOM_GPU_FENCE_HANDLE_MOJOM_DATA_VIEW_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/string_data_view.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "ui/gfx/mojom/gpu_fence_handle.mojom-shared-internal.h"


namespace gfx::mojom {
class GpuFenceHandleDataView;



}  // gfx::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::gfx::mojom::GpuFenceHandleDataView> {
  using Data = ::gfx::mojom::internal::GpuFenceHandle_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace gfx::mojom {


class GpuFenceHandleDataView {
 public:
  GpuFenceHandleDataView() = default;

  GpuFenceHandleDataView(
      internal::GpuFenceHandle_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  mojo::PlatformHandle TakeNativeFd() {
    mojo::PlatformHandle result;
    bool ret =
        mojo::internal::Deserialize<mojo::PlatformHandle>(
            &data_->native_fd, &result, message_);
    DCHECK(ret);
    return result;
  }
 private:
  internal::GpuFenceHandle_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // gfx::mojom

#endif  // UI_GFX_MOJOM_GPU_FENCE_HANDLE_MOJOM_DATA_VIEW_H_