// third_party/blink/public/mojom/image_replacement/image_replacement.mojom.h 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.

#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_IMAGE_REPLACEMENT_IMAGE_REPLACEMENT_MOJOM_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_IMAGE_REPLACEMENT_IMAGE_REPLACEMENT_MOJOM_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "third_party/blink/public/mojom/image_replacement/image_replacement.mojom-features.h"  // IWYU pragma: export
#include "third_party/blink/public/mojom/image_replacement/image_replacement.mojom-shared.h"  // IWYU pragma: export
#include "third_party/blink/public/mojom/image_replacement/image_replacement.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/big_buffer.mojom.h"
#include "mojo/public/mojom/base/token.mojom.h"
#include "third_party/blink/public/mojom/tokens/tokens.mojom.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-forward.h"
#include <string>
#include <vector>

#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"


#include "third_party/blink/public/common/common_export.h"




namespace blink::mojom {

class ImageReplacementProxy;

template <typename ImplRefTraits>
class ImageReplacementStub;

class ImageReplacementRequestValidator;


class BLINK_COMMON_EXPORT ImageReplacement
    : public ImageReplacementInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "blink.mojom.ImageReplacement";
  static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
  static const char* MessageToMethodName_(mojo::Message& message);
  static constexpr uint32_t Version_ = 0;
  static constexpr bool PassesAssociatedKinds_ = false;
  static constexpr bool HasUninterruptableMethods_ = false;

  using Base_ = ImageReplacementInterfaceBase;
  using Proxy_ = ImageReplacementProxy;

  template <typename ImplRefTraits>
  using Stub_ = ImageReplacementStub<ImplRefTraits>;

  using RequestValidator_ = ImageReplacementRequestValidator;
  using ResponseValidator_ = mojo::PassThroughFilter;
  enum MethodMinVersions : uint32_t {
    kStartReplacementMinVersion = 0,
    kRenderReplacementMinVersion = 0,
  };

// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
  struct StartReplacement_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct RenderReplacement_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~ImageReplacement() = default;

  virtual void StartReplacement(::mojo::PendingRemote<ImageReplacementHost> host_remote, std::optional<int32_t> tracked_element_feature_id) = 0;

  virtual void RenderReplacement() = 0;
};

class ImageReplacementHostProxy;

template <typename ImplRefTraits>
class ImageReplacementHostStub;

class ImageReplacementHostRequestValidator;


class BLINK_COMMON_EXPORT ImageReplacementHost
    : public ImageReplacementHostInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "blink.mojom.ImageReplacementHost";
  static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
  static const char* MessageToMethodName_(mojo::Message& message);
  static constexpr uint32_t Version_ = 0;
  static constexpr bool PassesAssociatedKinds_ = false;
  static constexpr bool HasUninterruptableMethods_ = false;

  using Base_ = ImageReplacementHostInterfaceBase;
  using Proxy_ = ImageReplacementHostProxy;

  template <typename ImplRefTraits>
  using Stub_ = ImageReplacementHostStub<ImplRefTraits>;

  using RequestValidator_ = ImageReplacementHostRequestValidator;
  using ResponseValidator_ = mojo::PassThroughFilter;
  enum MethodMinVersions : uint32_t {
    kReplacementFrameAttachedMinVersion = 0,
  };

// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
  struct ReplacementFrameAttached_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~ImageReplacementHost() = default;

  virtual void ReplacementFrameAttached(const ::blink::LocalFrameToken& replacement_frame_token, ReplacementDataPtr replacement_data) = 0;
};



class BLINK_COMMON_EXPORT ImageReplacementProxy
    : public ImageReplacement {
 public:
  using InterfaceType = ImageReplacement;

  explicit ImageReplacementProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void StartReplacement(::mojo::PendingRemote<ImageReplacementHost> host_remote, std::optional<int32_t> tracked_element_feature_id) final;
  
  void RenderReplacement() final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};



class BLINK_COMMON_EXPORT ImageReplacementHostProxy
    : public ImageReplacementHost {
 public:
  using InterfaceType = ImageReplacementHost;

  explicit ImageReplacementHostProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void ReplacementFrameAttached(const ::blink::LocalFrameToken& replacement_frame_token, ReplacementDataPtr replacement_data) final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};
class BLINK_COMMON_EXPORT ImageReplacementStubDispatch {
 public:
  static bool Accept(ImageReplacement* impl, mojo::Message* message);
  static bool AcceptWithResponder(
      ImageReplacement* impl,
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};

template <typename ImplRefTraits =
              mojo::RawPtrImplRefTraits<ImageReplacement>>
class ImageReplacementStub
    : public mojo::MessageReceiverWithResponderStatus {
 public:
  using ImplPointerType = typename ImplRefTraits::PointerType;

  ImageReplacementStub() = default;
  ~ImageReplacementStub() override = default;

  void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
  ImplPointerType& sink() { return sink_; }

  bool Accept(mojo::Message* message) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return ImageReplacementStubDispatch::Accept(
        ImplRefTraits::GetRawPointer(&sink_), message);
  }

  bool AcceptWithResponder(
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return ImageReplacementStubDispatch::AcceptWithResponder(
        ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
  }

 private:
  ImplPointerType sink_;
};
class BLINK_COMMON_EXPORT ImageReplacementHostStubDispatch {
 public:
  static bool Accept(ImageReplacementHost* impl, mojo::Message* message);
  static bool AcceptWithResponder(
      ImageReplacementHost* impl,
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};

template <typename ImplRefTraits =
              mojo::RawPtrImplRefTraits<ImageReplacementHost>>
class ImageReplacementHostStub
    : public mojo::MessageReceiverWithResponderStatus {
 public:
  using ImplPointerType = typename ImplRefTraits::PointerType;

  ImageReplacementHostStub() = default;
  ~ImageReplacementHostStub() override = default;

  void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
  ImplPointerType& sink() { return sink_; }

  bool Accept(mojo::Message* message) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return ImageReplacementHostStubDispatch::Accept(
        ImplRefTraits::GetRawPointer(&sink_), message);
  }

  bool AcceptWithResponder(
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return ImageReplacementHostStubDispatch::AcceptWithResponder(
        ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
  }

 private:
  ImplPointerType sink_;
};
class BLINK_COMMON_EXPORT ImageReplacementRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class BLINK_COMMON_EXPORT ImageReplacementHostRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};









class BLINK_COMMON_EXPORT ImageData {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<ImageData, T>::value>;
  using DataView = ImageDataDataView;
  using Data_ = internal::ImageData_Data;

  template <typename... Args>
  static ImageDataPtr New(Args&&... args) {
    return ImageDataPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static ImageDataPtr From(const U& u) {
    return mojo::TypeConverter<ImageDataPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, ImageData>::Convert(*this);
  }


  ImageData();

  explicit ImageData(
      ::mojo_base::BigBuffer webp_bytes);

ImageData(const ImageData&) = delete;
ImageData& operator=(const ImageData&) = delete;

  ~ImageData();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = ImageDataPtr>
  ImageDataPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, ImageData::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, ImageData::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, ImageData::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        ImageData::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::ImageData_UnserializedMessageContext<
            UserType, ImageData::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<ImageData::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return ImageData::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::ImageData_UnserializedMessageContext<
            UserType, ImageData::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<ImageData::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::mojo_base::BigBuffer webp_bytes;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, ImageData::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, ImageData::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, ImageData::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, ImageData::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}





class BLINK_COMMON_EXPORT ReplacementData {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<ReplacementData, T>::value>;
  using DataView = ReplacementDataDataView;
  using Data_ = internal::ReplacementData_Data;

  template <typename... Args>
  static ReplacementDataPtr New(Args&&... args) {
    return ReplacementDataPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static ReplacementDataPtr From(const U& u) {
    return mojo::TypeConverter<ReplacementDataPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, ReplacementData>::Convert(*this);
  }


  ReplacementData();

  ReplacementData(
      ImageDataPtr original_image,
      const std::optional<::base::Token>& tracked_element_id,
      ObjectFit object_fit);

ReplacementData(const ReplacementData&) = delete;
ReplacementData& operator=(const ReplacementData&) = delete;

  ~ReplacementData();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = ReplacementDataPtr>
  ReplacementDataPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        ReplacementData::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::ReplacementData_UnserializedMessageContext<
            UserType, ReplacementData::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<ReplacementData::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return ReplacementData::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::ReplacementData_UnserializedMessageContext<
            UserType, ReplacementData::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<ReplacementData::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ImageDataPtr original_image;
  
  std::optional<::base::Token> tracked_element_id;
  
  ObjectFit object_fit;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, ReplacementData::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
ImageDataPtr ImageData::Clone() const {
  return New(
      mojo::Clone(webp_bytes)
  );
}

template <typename T, ImageData::EnableIfSame<T>*>
bool ImageData::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->webp_bytes, other_struct.webp_bytes))
    return false;
  return true;
}

template <typename T, ImageData::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.webp_bytes < rhs.webp_bytes)
    return true;
  if (rhs.webp_bytes < lhs.webp_bytes)
    return false;
  return false;
}
template <typename StructPtrType>
ReplacementDataPtr ReplacementData::Clone() const {
  return New(
      mojo::Clone(original_image),
      mojo::Clone(tracked_element_id),
      mojo::Clone(object_fit)
  );
}

template <typename T, ReplacementData::EnableIfSame<T>*>
bool ReplacementData::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->original_image, other_struct.original_image))
    return false;
  if (!mojo::Equals(this->tracked_element_id, other_struct.tracked_element_id))
    return false;
  if (!mojo::Equals(this->object_fit, other_struct.object_fit))
    return false;
  return true;
}

template <typename T, ReplacementData::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.original_image < rhs.original_image)
    return true;
  if (rhs.original_image < lhs.original_image)
    return false;
  if (lhs.tracked_element_id < rhs.tracked_element_id)
    return true;
  if (rhs.tracked_element_id < lhs.tracked_element_id)
    return false;
  if (lhs.object_fit < rhs.object_fit)
    return true;
  if (rhs.object_fit < lhs.object_fit)
    return false;
  return false;
}


}  // blink::mojom

namespace mojo {


template <>
struct BLINK_COMMON_EXPORT StructTraits<::blink::mojom::ImageData::DataView,
                                         ::blink::mojom::ImageDataPtr> {
  static bool IsNull(const ::blink::mojom::ImageDataPtr& input) { return !input; }
  static void SetToNull(::blink::mojom::ImageDataPtr* output) { output->reset(); }

  static  decltype(::blink::mojom::ImageData::webp_bytes)& webp_bytes(
       ::blink::mojom::ImageDataPtr& input) {
    return input->webp_bytes;
  }

  static bool Read(::blink::mojom::ImageData::DataView input, ::blink::mojom::ImageDataPtr* output);
};


template <>
struct BLINK_COMMON_EXPORT StructTraits<::blink::mojom::ReplacementData::DataView,
                                         ::blink::mojom::ReplacementDataPtr> {
  static bool IsNull(const ::blink::mojom::ReplacementDataPtr& input) { return !input; }
  static void SetToNull(::blink::mojom::ReplacementDataPtr* output) { output->reset(); }

  static  decltype(::blink::mojom::ReplacementData::original_image)& original_image(
       ::blink::mojom::ReplacementDataPtr& input) {
    return input->original_image;
  }

  static const decltype(::blink::mojom::ReplacementData::tracked_element_id)& tracked_element_id(
      const ::blink::mojom::ReplacementDataPtr& input) {
    return input->tracked_element_id;
  }

  static decltype(::blink::mojom::ReplacementData::object_fit) object_fit(
      const ::blink::mojom::ReplacementDataPtr& input) {
    return input->object_fit;
  }

  static bool Read(::blink::mojom::ReplacementData::DataView input, ::blink::mojom::ReplacementDataPtr* output);
};

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_IMAGE_REPLACEMENT_IMAGE_REPLACEMENT_MOJOM_H_