// components/surface_embed/common/surface_embed.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 COMPONENTS_SURFACE_EMBED_COMMON_SURFACE_EMBED_MOJOM_H_
#define COMPONENTS_SURFACE_EMBED_COMMON_SURFACE_EMBED_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 "components/surface_embed/common/surface_embed.mojom-features.h"  // IWYU pragma: export
#include "components/surface_embed/common/surface_embed.mojom-shared.h"  // IWYU pragma: export
#include "components/surface_embed/common/surface_embed.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/unguessable_token.mojom.h"
#include "services/viz/public/mojom/compositing/frame_sink_id.mojom.h"
#include "services/viz/public/mojom/compositing/local_surface_id.mojom.h"
#include "third_party/blink/public/mojom/frame/frame_visual_properties.mojom.h"
#include "third_party/blink/public/mojom/input/focus_type.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"






namespace surface_embed::mojom {

class SurfaceEmbedProxy;

template <typename ImplRefTraits>
class SurfaceEmbedStub;

class SurfaceEmbedRequestValidator;
class SurfaceEmbedResponseValidator;


class SurfaceEmbed
    : public SurfaceEmbedInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "surface_embed.mojom.SurfaceEmbed";
  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_ = SurfaceEmbedInterfaceBase;
  using Proxy_ = SurfaceEmbedProxy;

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

  using RequestValidator_ = SurfaceEmbedRequestValidator;
  using ResponseValidator_ = SurfaceEmbedResponseValidator;
  enum MethodMinVersions : uint32_t {
    kSetFrameSinkIdMinVersion = 0,
    kUpdateLocalSurfaceIdFromChildMinVersion = 0,
    kChildProcessGoneMinVersion = 0,
    kRequestFocusOnEmbedElementMinVersion = 0,
    kAdvanceFocusFromEmbedElementMinVersion = 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 SetFrameSinkId_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct UpdateLocalSurfaceIdFromChild_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct ChildProcessGone_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct RequestFocusOnEmbedElement_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct AdvanceFocusFromEmbedElement_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~SurfaceEmbed() = default;

  virtual void SetFrameSinkId(const ::viz::FrameSinkId& frame_sink_id, bool allow_paint_holding) = 0;

  virtual void UpdateLocalSurfaceIdFromChild(const ::viz::LocalSurfaceId& local_surface_id) = 0;

  virtual void ChildProcessGone() = 0;

  using RequestFocusOnEmbedElementCallback = base::OnceCallback<void()>;
  using RequestFocusOnEmbedElementMojoCallback = base::OnceCallback<void()>;

  virtual void RequestFocusOnEmbedElement(RequestFocusOnEmbedElementCallback callback) = 0;

  virtual void AdvanceFocusFromEmbedElement(bool reverse) = 0;
};

class SurfaceEmbedHostProxy;

template <typename ImplRefTraits>
class SurfaceEmbedHostStub;

class SurfaceEmbedHostRequestValidator;


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

  using Base_ = SurfaceEmbedHostInterfaceBase;
  using Proxy_ = SurfaceEmbedHostProxy;

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

  using RequestValidator_ = SurfaceEmbedHostRequestValidator;
  using ResponseValidator_ = mojo::PassThroughFilter;
  enum MethodMinVersions : uint32_t {
    kSetSurfaceEmbedMinVersion = 0,
    kAttachConnectorMinVersion = 0,
    kSynchronizeVisualPropertiesMinVersion = 0,
    kOnEmbedElementFocusedMinVersion = 0,
    kOnEmbedElementThrottlingStatusChangedMinVersion = 0,
    kSetParentAccessibilityInfoMinVersion = 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 SetSurfaceEmbed_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct AttachConnector_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct SynchronizeVisualProperties_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct OnEmbedElementFocused_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct OnEmbedElementThrottlingStatusChanged_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct SetParentAccessibilityInfo_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~SurfaceEmbedHost() = default;

  virtual void SetSurfaceEmbed(::mojo::PendingAssociatedRemote<SurfaceEmbed> surface_embed) = 0;

  virtual void AttachConnector(const ::base::UnguessableToken& content_id) = 0;

  virtual void SynchronizeVisualProperties(const ::blink::FrameVisualProperties& visual_properties, bool is_visible) = 0;

  virtual void OnEmbedElementFocused(bool focused, ::blink::mojom::FocusType focus_type) = 0;

  virtual void OnEmbedElementThrottlingStatusChanged(RenderThrottlingStatusPtr status) = 0;

  virtual void SetParentAccessibilityInfo(int32_t ax_node_id) = 0;
};



class  SurfaceEmbedProxy
    : public SurfaceEmbed {
 public:
  using InterfaceType = SurfaceEmbed;

  explicit SurfaceEmbedProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void SetFrameSinkId(const ::viz::FrameSinkId& frame_sink_id, bool allow_paint_holding) final;
  
  void UpdateLocalSurfaceIdFromChild(const ::viz::LocalSurfaceId& local_surface_id) final;
  
  void ChildProcessGone() final;
  
  void RequestFocusOnEmbedElement(RequestFocusOnEmbedElementCallback callback) final;
  
  void AdvanceFocusFromEmbedElement(bool reverse) final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};



class  SurfaceEmbedHostProxy
    : public SurfaceEmbedHost {
 public:
  using InterfaceType = SurfaceEmbedHost;

  explicit SurfaceEmbedHostProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void SetSurfaceEmbed(::mojo::PendingAssociatedRemote<SurfaceEmbed> surface_embed) final;
  
  void AttachConnector(const ::base::UnguessableToken& content_id) final;
  
  void SynchronizeVisualProperties(const ::blink::FrameVisualProperties& visual_properties, bool is_visible) final;
  
  void OnEmbedElementFocused(bool focused, ::blink::mojom::FocusType focus_type) final;
  
  void OnEmbedElementThrottlingStatusChanged(RenderThrottlingStatusPtr status) final;
  
  void SetParentAccessibilityInfo(int32_t ax_node_id) final;

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

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

  SurfaceEmbedStub() = default;
  ~SurfaceEmbedStub() 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 SurfaceEmbedStubDispatch::Accept(
        ImplRefTraits::GetRawPointer(&sink_), message);
  }

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

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

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

  SurfaceEmbedHostStub() = default;
  ~SurfaceEmbedHostStub() 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 SurfaceEmbedHostStubDispatch::Accept(
        ImplRefTraits::GetRawPointer(&sink_), message);
  }

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

 private:
  ImplPointerType sink_;
};
class  SurfaceEmbedRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class  SurfaceEmbedHostRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class  SurfaceEmbedResponseValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};





class  RenderThrottlingStatus {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<RenderThrottlingStatus, T>::value>;
  using DataView = RenderThrottlingStatusDataView;
  using Data_ = internal::RenderThrottlingStatus_Data;

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

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

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


  RenderThrottlingStatus();

  RenderThrottlingStatus(
      bool is_throttled,
      bool subtree_throttled,
      bool display_locked);


  ~RenderThrottlingStatus();

  // 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 = RenderThrottlingStatusPtr>
  RenderThrottlingStatusPtr 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, RenderThrottlingStatus::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

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

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        RenderThrottlingStatus::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        RenderThrottlingStatus::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        RenderThrottlingStatus::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::RenderThrottlingStatus_UnserializedMessageContext<
            UserType, RenderThrottlingStatus::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<RenderThrottlingStatus::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return RenderThrottlingStatus::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::RenderThrottlingStatus_UnserializedMessageContext<
            UserType, RenderThrottlingStatus::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<RenderThrottlingStatus::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  bool is_throttled;
  
  bool subtree_throttled;
  
  bool display_locked;

  // 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, RenderThrottlingStatus::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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




template <typename StructPtrType>
RenderThrottlingStatusPtr RenderThrottlingStatus::Clone() const {
  return New(
      mojo::Clone(is_throttled),
      mojo::Clone(subtree_throttled),
      mojo::Clone(display_locked)
  );
}

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

template <typename T, RenderThrottlingStatus::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.is_throttled < rhs.is_throttled)
    return true;
  if (rhs.is_throttled < lhs.is_throttled)
    return false;
  if (lhs.subtree_throttled < rhs.subtree_throttled)
    return true;
  if (rhs.subtree_throttled < lhs.subtree_throttled)
    return false;
  if (lhs.display_locked < rhs.display_locked)
    return true;
  if (rhs.display_locked < lhs.display_locked)
    return false;
  return false;
}


}  // surface_embed::mojom

namespace mojo {


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

  static decltype(::surface_embed::mojom::RenderThrottlingStatus::is_throttled) is_throttled(
      const ::surface_embed::mojom::RenderThrottlingStatusPtr& input) {
    return input->is_throttled;
  }

  static decltype(::surface_embed::mojom::RenderThrottlingStatus::subtree_throttled) subtree_throttled(
      const ::surface_embed::mojom::RenderThrottlingStatusPtr& input) {
    return input->subtree_throttled;
  }

  static decltype(::surface_embed::mojom::RenderThrottlingStatus::display_locked) display_locked(
      const ::surface_embed::mojom::RenderThrottlingStatusPtr& input) {
    return input->display_locked;
  }

  static bool Read(::surface_embed::mojom::RenderThrottlingStatus::DataView input, ::surface_embed::mojom::RenderThrottlingStatusPtr* output);
};

}  // namespace mojo

#endif  // COMPONENTS_SURFACE_EMBED_COMMON_SURFACE_EMBED_MOJOM_H_