// media/mojo/mojom/android_overlay.mojom-blink.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 MEDIA_MOJO_MOJOM_ANDROID_OVERLAY_MOJOM_BLINK_H_
#define MEDIA_MOJO_MOJOM_ANDROID_OVERLAY_MOJOM_BLINK_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 "media/mojo/mojom/android_overlay.mojom-features.h"  // IWYU pragma: export
#include "media/mojo/mojom/android_overlay.mojom-shared.h"  // IWYU pragma: export
#include "media/mojo/mojom/android_overlay.mojom-blink-forward.h"  // IWYU pragma: export
#include "media/mojo/mojom/media_types.mojom-blink-forward.h"
#include "mojo/public/mojom/base/unguessable_token.mojom-blink.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-blink.h"

#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

#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/platform/web_common.h"
#if !BLINK_MOJO_IMPL && !INSIDE_BLINK
#error "File must only be imported inside blink"
#endif




namespace media::mojom::blink {

class AndroidOverlayProviderProxy;

template <typename ImplRefTraits>
class AndroidOverlayProviderStub;

class AndroidOverlayProviderRequestValidator;


class BLINK_PLATFORM_EXPORT AndroidOverlayProvider
    : public AndroidOverlayProviderInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "media.mojom.AndroidOverlayProvider";
  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_ = AndroidOverlayProviderInterfaceBase;
  using Proxy_ = AndroidOverlayProviderProxy;

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

  using RequestValidator_ = AndroidOverlayProviderRequestValidator;
  using ResponseValidator_ = mojo::PassThroughFilter;
  enum MethodMinVersions : uint32_t {
    kCreateOverlayMinVersion = 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 CreateOverlay_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~AndroidOverlayProvider() = default;

  virtual void CreateOverlay(::mojo::PendingReceiver<AndroidOverlay> overlay, ::mojo::PendingRemote<AndroidOverlayClient> client, AndroidOverlayConfigPtr config) = 0;
};

class AndroidOverlayProxy;

template <typename ImplRefTraits>
class AndroidOverlayStub;

class AndroidOverlayRequestValidator;


class BLINK_PLATFORM_EXPORT AndroidOverlay
    : public AndroidOverlayInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "media.mojom.AndroidOverlay";
  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_ = AndroidOverlayInterfaceBase;
  using Proxy_ = AndroidOverlayProxy;

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

  using RequestValidator_ = AndroidOverlayRequestValidator;
  using ResponseValidator_ = mojo::PassThroughFilter;
  enum MethodMinVersions : uint32_t {
    kScheduleLayoutMinVersion = 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 ScheduleLayout_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~AndroidOverlay() = default;

  virtual void ScheduleLayout(const ::gfx::Rect& rect) = 0;
};

class AndroidOverlayClientProxy;

template <typename ImplRefTraits>
class AndroidOverlayClientStub;

class AndroidOverlayClientRequestValidator;
class AndroidOverlayClientResponseValidator;


class BLINK_PLATFORM_EXPORT AndroidOverlayClient
    : public AndroidOverlayClientInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "media.mojom.AndroidOverlayClient";
  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 inline constexpr uint32_t kSyncMethodOrdinals[] = {
    2
  };
  static constexpr bool HasUninterruptableMethods_ = false;

  using Base_ = AndroidOverlayClientInterfaceBase;
  using Proxy_ = AndroidOverlayClientProxy;

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

  using RequestValidator_ = AndroidOverlayClientRequestValidator;
  using ResponseValidator_ = AndroidOverlayClientResponseValidator;
  enum MethodMinVersions : uint32_t {
    kOnSurfaceReadyMinVersion = 0,
    kOnDestroyedMinVersion = 0,
    kOnSynchronouslyDestroyedMinVersion = 0,
    kOnPowerEfficientStateMinVersion = 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 OnSurfaceReady_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct OnDestroyed_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct OnSynchronouslyDestroyed_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct OnPowerEfficientState_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~AndroidOverlayClient() = default;

  virtual void OnSurfaceReady(uint64_t surface_key) = 0;

  virtual void OnDestroyed() = 0;

  // Sync method. This signature is used by the client side; the service side
  // should implement the signature with callback below.
  
  virtual bool OnSynchronouslyDestroyed();
  using OnSynchronouslyDestroyedCallback = base::OnceCallback<void()>;
  using OnSynchronouslyDestroyedMojoCallback = base::OnceCallback<void()>;

  virtual void OnSynchronouslyDestroyed(OnSynchronouslyDestroyedCallback callback) = 0;

  virtual void OnPowerEfficientState(bool is_power_efficient) = 0;
};



class BLINK_PLATFORM_EXPORT AndroidOverlayProviderProxy
    : public AndroidOverlayProvider {
 public:
  using InterfaceType = AndroidOverlayProvider;

  explicit AndroidOverlayProviderProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void CreateOverlay(::mojo::PendingReceiver<AndroidOverlay> overlay, ::mojo::PendingRemote<AndroidOverlayClient> client, AndroidOverlayConfigPtr config) final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};



class BLINK_PLATFORM_EXPORT AndroidOverlayProxy
    : public AndroidOverlay {
 public:
  using InterfaceType = AndroidOverlay;

  explicit AndroidOverlayProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void ScheduleLayout(const ::gfx::Rect& rect) final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};



class BLINK_PLATFORM_EXPORT AndroidOverlayClientProxy
    : public AndroidOverlayClient {
 public:
  using InterfaceType = AndroidOverlayClient;

  explicit AndroidOverlayClientProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void OnSurfaceReady(uint64_t surface_key) final;
  
  void OnDestroyed() final;
  
  bool OnSynchronouslyDestroyed() final;
  
  void OnSynchronouslyDestroyed(OnSynchronouslyDestroyedCallback callback) final;
  
  void OnPowerEfficientState(bool is_power_efficient) final;

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

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

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

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

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

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

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

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

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

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

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

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

 private:
  ImplPointerType sink_;
};
class BLINK_PLATFORM_EXPORT AndroidOverlayProviderRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class BLINK_PLATFORM_EXPORT AndroidOverlayRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class BLINK_PLATFORM_EXPORT AndroidOverlayClientRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class BLINK_PLATFORM_EXPORT AndroidOverlayClientResponseValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};








class BLINK_PLATFORM_EXPORT AndroidOverlayConfig {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<AndroidOverlayConfig, T>::value>;
  using DataView = AndroidOverlayConfigDataView;
  using Data_ = internal::AndroidOverlayConfig_Data;

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

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

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


  AndroidOverlayConfig();

  AndroidOverlayConfig(
      const ::base::UnguessableToken& routing_token,
      const ::gfx::Rect& rect,
      bool secure,
      bool power_efficient);


  ~AndroidOverlayConfig();

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

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

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

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

  template <typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        AndroidOverlayConfig::DataView, ::blink::Vector<uint8_t>>(input);
  }

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

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

  
  ::base::UnguessableToken routing_token;
  
  ::gfx::Rect rect;
  
  bool secure;
  
  bool power_efficient;

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

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

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

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

template <typename StructPtrType>
AndroidOverlayConfigPtr AndroidOverlayConfig::Clone() const {
  return New(
      mojo::Clone(routing_token),
      mojo::Clone(rect),
      mojo::Clone(secure),
      mojo::Clone(power_efficient)
  );
}

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

template <typename T, AndroidOverlayConfig::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.routing_token < rhs.routing_token)
    return true;
  if (rhs.routing_token < lhs.routing_token)
    return false;
  if (lhs.rect < rhs.rect)
    return true;
  if (rhs.rect < lhs.rect)
    return false;
  if (lhs.secure < rhs.secure)
    return true;
  if (rhs.secure < lhs.secure)
    return false;
  if (lhs.power_efficient < rhs.power_efficient)
    return true;
  if (rhs.power_efficient < lhs.power_efficient)
    return false;
  return false;
}


}  // media::mojom::blink

namespace mojo {


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

  static const decltype(::media::mojom::blink::AndroidOverlayConfig::routing_token)& routing_token(
      const ::media::mojom::blink::AndroidOverlayConfigPtr& input) {
    return input->routing_token;
  }

  static const decltype(::media::mojom::blink::AndroidOverlayConfig::rect)& rect(
      const ::media::mojom::blink::AndroidOverlayConfigPtr& input) {
    return input->rect;
  }

  static decltype(::media::mojom::blink::AndroidOverlayConfig::secure) secure(
      const ::media::mojom::blink::AndroidOverlayConfigPtr& input) {
    return input->secure;
  }

  static decltype(::media::mojom::blink::AndroidOverlayConfig::power_efficient) power_efficient(
      const ::media::mojom::blink::AndroidOverlayConfigPtr& input) {
    return input->power_efficient;
  }

  static bool Read(::media::mojom::blink::AndroidOverlayConfig::DataView input, ::media::mojom::blink::AndroidOverlayConfigPtr* output);
};

}  // namespace mojo

#endif  // MEDIA_MOJO_MOJOM_ANDROID_OVERLAY_MOJOM_BLINK_H_