// third_party/blink/public/mojom/remote_objects/remote_objects.mojom.cc 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.

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "third_party/blink/public/mojom/remote_objects/remote_objects.mojom.h"
#include <math.h>
#include <stdint.h>
#include <utility>
#include "base/debug/alias.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/proxy_to_responder.h"
#include "mojo/public/cpp/bindings/lib/send_message_helper.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/cpp/bindings/urgent_message_scope.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "third_party/blink/public/mojom/remote_objects/remote_objects.mojom-params-data.h"
#include "third_party/blink/public/mojom/remote_objects/remote_objects.mojom-shared-message-ids.h"

#include "third_party/blink/public/mojom/remote_objects/remote_objects.mojom-import-headers.h"
#include "third_party/blink/public/mojom/remote_objects/remote_objects.mojom-test-utils.h"


namespace blink::mojom {
RemoteTypedArray::RemoteTypedArray()
    : type(),
      buffer() {}

RemoteTypedArray::RemoteTypedArray(
    RemoteArrayType type_in,
    ::mojo_base::BigBuffer buffer_in)
    : type(std::move(type_in)),
      buffer(std::move(buffer_in)) {}

RemoteTypedArray::~RemoteTypedArray() = default;

void RemoteTypedArray::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "type"), this->type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type RemoteArrayType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "buffer"), this->buffer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo_base::BigBuffer>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool RemoteTypedArray::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
RemoteInvocationResult::RemoteInvocationResult()
    : error(RemoteInvocationError::OK),
      value() {}

RemoteInvocationResult::RemoteInvocationResult(
    RemoteInvocationError error_in,
    RemoteInvocationResultValuePtr value_in)
    : error(std::move(error_in)),
      value(std::move(value_in)) {}

RemoteInvocationResult::~RemoteInvocationResult() = default;

void RemoteInvocationResult::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "error"), this->error,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type RemoteInvocationError>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "value"), this->value,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type RemoteInvocationResultValuePtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool RemoteInvocationResult::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewNumberValue(
    double value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kNumberValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewBooleanValue(
    bool value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kBooleanValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewStringValue(
    const ::std::u16string& value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kStringValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewSingletonValue(
    SingletonJavaScriptValue value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kSingletonValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewArrayValue(
    std::vector<RemoteInvocationArgumentPtr> value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kArrayValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewTypedArrayValue(
    RemoteTypedArrayPtr value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kTypedArrayValue)>,
      std::move(value));
}

RemoteInvocationArgumentPtr
RemoteInvocationArgument::NewObjectIdValue(
    int32_t value) {
  return RemoteInvocationArgumentPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kObjectIdValue)>,
      std::move(value));
}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kNumberValue)>,
    double value)
    : tag_(Tag::kNumberValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kNumberValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kBooleanValue)>,
    bool value)
    : tag_(Tag::kBooleanValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kBooleanValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kStringValue)>,
    const ::std::u16string& value)
    : tag_(Tag::kStringValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kStringValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kSingletonValue)>,
    SingletonJavaScriptValue value)
    : tag_(Tag::kSingletonValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kSingletonValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kArrayValue)>,
    std::vector<RemoteInvocationArgumentPtr> value)
    : tag_(Tag::kArrayValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kArrayValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kTypedArrayValue)>,
    RemoteTypedArrayPtr value)
    : tag_(Tag::kTypedArrayValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kTypedArrayValue)>,
            std::move(value)) {}

RemoteInvocationArgument::RemoteInvocationArgument(
    std::in_place_index_t<static_cast<size_t>(Tag::kObjectIdValue)>,
    int32_t value)
    : tag_(Tag::kObjectIdValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kObjectIdValue)>,
            std::move(value)) {}
RemoteInvocationArgument::~RemoteInvocationArgument() {
  DestroyActive();
}

void RemoteInvocationArgument::set_number_value(double number_value) {
  if (tag_ != Tag::kNumberValue) {
    DestroyActive();
    tag_ = Tag::kNumberValue;
  }
  data_.number_value = number_value;
}

void RemoteInvocationArgument::set_boolean_value(bool boolean_value) {
  if (tag_ != Tag::kBooleanValue) {
    DestroyActive();
    tag_ = Tag::kBooleanValue;
  }
  data_.boolean_value = boolean_value;
}

void RemoteInvocationArgument::set_string_value(const ::std::u16string& string_value) {
  if (tag_ == Tag::kStringValue) {
    data_.string_value = std::move(string_value);
  } else {
    DestroyActive();
    tag_ = Tag::kStringValue;
    new (&data_.string_value) ::std::u16string(
        std::move(string_value));
  }
}

void RemoteInvocationArgument::set_singleton_value(SingletonJavaScriptValue singleton_value) {
  if (tag_ != Tag::kSingletonValue) {
    DestroyActive();
    tag_ = Tag::kSingletonValue;
  }
  data_.singleton_value = singleton_value;
}

void RemoteInvocationArgument::set_array_value(std::vector<RemoteInvocationArgumentPtr> array_value) {
  if (tag_ == Tag::kArrayValue) {
    data_.array_value = std::move(array_value);
  } else {
    DestroyActive();
    tag_ = Tag::kArrayValue;
    new (&data_.array_value) std::vector<RemoteInvocationArgumentPtr>(
        std::move(array_value));
  }
}

void RemoteInvocationArgument::set_typed_array_value(RemoteTypedArrayPtr typed_array_value) {
  if (tag_ == Tag::kTypedArrayValue) {
    data_.typed_array_value = std::move(typed_array_value);
  } else {
    DestroyActive();
    tag_ = Tag::kTypedArrayValue;
    new (&data_.typed_array_value) RemoteTypedArrayPtr(
        std::move(typed_array_value));
  }
}

void RemoteInvocationArgument::set_object_id_value(int32_t object_id_value) {
  if (tag_ != Tag::kObjectIdValue) {
    DestroyActive();
    tag_ = Tag::kObjectIdValue;
  }
  data_.object_id_value = object_id_value;
}


RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kNumberValue)>,
    double value)
    : number_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kBooleanValue)>,
    bool value)
    : boolean_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kStringValue)>,
    const ::std::u16string& value)
    : string_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kSingletonValue)>,
    SingletonJavaScriptValue value)
    : singleton_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kArrayValue)>,
    std::vector<RemoteInvocationArgumentPtr> value)
    : array_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kTypedArrayValue)>,
    RemoteTypedArrayPtr value)
    : typed_array_value(std::move(value)) {}

RemoteInvocationArgument::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kObjectIdValue)>,
    int32_t value)
    : object_id_value(std::move(value)) {}

void RemoteInvocationArgument::DestroyActive() {
  switch (tag_) {

    case Tag::kNumberValue:
      std::destroy_at(&data_.number_value);
      break;
    case Tag::kBooleanValue:
      std::destroy_at(&data_.boolean_value);
      break;
    case Tag::kStringValue:
      std::destroy_at(&data_.string_value);
      break;
    case Tag::kSingletonValue:
      std::destroy_at(&data_.singleton_value);
      break;
    case Tag::kArrayValue:
      std::destroy_at(&data_.array_value);
      break;
    case Tag::kTypedArrayValue:
      std::destroy_at(&data_.typed_array_value);
      break;
    case Tag::kObjectIdValue:
      std::destroy_at(&data_.object_id_value);
      break;
  }
}

bool RemoteInvocationArgument::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context, false);
}
RemoteInvocationResultValuePtr
RemoteInvocationResultValue::NewNumberValue(
    double value) {
  return RemoteInvocationResultValuePtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kNumberValue)>,
      std::move(value));
}

RemoteInvocationResultValuePtr
RemoteInvocationResultValue::NewBooleanValue(
    bool value) {
  return RemoteInvocationResultValuePtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kBooleanValue)>,
      std::move(value));
}

RemoteInvocationResultValuePtr
RemoteInvocationResultValue::NewStringValue(
    const ::std::u16string& value) {
  return RemoteInvocationResultValuePtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kStringValue)>,
      std::move(value));
}

RemoteInvocationResultValuePtr
RemoteInvocationResultValue::NewSingletonValue(
    SingletonJavaScriptValue value) {
  return RemoteInvocationResultValuePtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kSingletonValue)>,
      std::move(value));
}

RemoteInvocationResultValuePtr
RemoteInvocationResultValue::NewObjectId(
    int32_t value) {
  return RemoteInvocationResultValuePtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kObjectId)>,
      std::move(value));
}

RemoteInvocationResultValue::RemoteInvocationResultValue(
    std::in_place_index_t<static_cast<size_t>(Tag::kNumberValue)>,
    double value)
    : tag_(Tag::kNumberValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kNumberValue)>,
            std::move(value)) {}

RemoteInvocationResultValue::RemoteInvocationResultValue(
    std::in_place_index_t<static_cast<size_t>(Tag::kBooleanValue)>,
    bool value)
    : tag_(Tag::kBooleanValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kBooleanValue)>,
            std::move(value)) {}

RemoteInvocationResultValue::RemoteInvocationResultValue(
    std::in_place_index_t<static_cast<size_t>(Tag::kStringValue)>,
    const ::std::u16string& value)
    : tag_(Tag::kStringValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kStringValue)>,
            std::move(value)) {}

RemoteInvocationResultValue::RemoteInvocationResultValue(
    std::in_place_index_t<static_cast<size_t>(Tag::kSingletonValue)>,
    SingletonJavaScriptValue value)
    : tag_(Tag::kSingletonValue),
      data_(std::in_place_index<static_cast<size_t>(Tag::kSingletonValue)>,
            std::move(value)) {}

RemoteInvocationResultValue::RemoteInvocationResultValue(
    std::in_place_index_t<static_cast<size_t>(Tag::kObjectId)>,
    int32_t value)
    : tag_(Tag::kObjectId),
      data_(std::in_place_index<static_cast<size_t>(Tag::kObjectId)>,
            std::move(value)) {}
RemoteInvocationResultValue::~RemoteInvocationResultValue() {
  DestroyActive();
}

void RemoteInvocationResultValue::set_number_value(double number_value) {
  if (tag_ != Tag::kNumberValue) {
    DestroyActive();
    tag_ = Tag::kNumberValue;
  }
  data_.number_value = number_value;
}

void RemoteInvocationResultValue::set_boolean_value(bool boolean_value) {
  if (tag_ != Tag::kBooleanValue) {
    DestroyActive();
    tag_ = Tag::kBooleanValue;
  }
  data_.boolean_value = boolean_value;
}

void RemoteInvocationResultValue::set_string_value(const ::std::u16string& string_value) {
  if (tag_ == Tag::kStringValue) {
    data_.string_value = std::move(string_value);
  } else {
    DestroyActive();
    tag_ = Tag::kStringValue;
    new (&data_.string_value) ::std::u16string(
        std::move(string_value));
  }
}

void RemoteInvocationResultValue::set_singleton_value(SingletonJavaScriptValue singleton_value) {
  if (tag_ != Tag::kSingletonValue) {
    DestroyActive();
    tag_ = Tag::kSingletonValue;
  }
  data_.singleton_value = singleton_value;
}

void RemoteInvocationResultValue::set_object_id(int32_t object_id) {
  if (tag_ != Tag::kObjectId) {
    DestroyActive();
    tag_ = Tag::kObjectId;
  }
  data_.object_id = object_id;
}


RemoteInvocationResultValue::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kNumberValue)>,
    double value)
    : number_value(std::move(value)) {}

RemoteInvocationResultValue::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kBooleanValue)>,
    bool value)
    : boolean_value(std::move(value)) {}

RemoteInvocationResultValue::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kStringValue)>,
    const ::std::u16string& value)
    : string_value(std::move(value)) {}

RemoteInvocationResultValue::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kSingletonValue)>,
    SingletonJavaScriptValue value)
    : singleton_value(std::move(value)) {}

RemoteInvocationResultValue::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kObjectId)>,
    int32_t value)
    : object_id(std::move(value)) {}

void RemoteInvocationResultValue::DestroyActive() {
  switch (tag_) {

    case Tag::kNumberValue:
      std::destroy_at(&data_.number_value);
      break;
    case Tag::kBooleanValue:
      std::destroy_at(&data_.boolean_value);
      break;
    case Tag::kStringValue:
      std::destroy_at(&data_.string_value);
      break;
    case Tag::kSingletonValue:
      std::destroy_at(&data_.singleton_value);
      break;
    case Tag::kObjectId:
      std::destroy_at(&data_.object_id);
      break;
  }
}

bool RemoteInvocationResultValue::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context, false);
}
// The declaration includes the definition on other builds.

RemoteObjectHost::IPCStableHashFunction RemoteObjectHost::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::RemoteObjectHost>(message.name())) {
    case messages::RemoteObjectHost::kGetObject: {
      return &RemoteObjectHost::GetObject_Sym::IPCStableHash;
    }
    case messages::RemoteObjectHost::kAcquireObject: {
      return &RemoteObjectHost::AcquireObject_Sym::IPCStableHash;
    }
    case messages::RemoteObjectHost::kReleaseObject: {
      return &RemoteObjectHost::ReleaseObject_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* RemoteObjectHost::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (!is_response) {
    switch (static_cast<messages::RemoteObjectHost>(message.name())) {
      case messages::RemoteObjectHost::kGetObject:
            return "Receive blink::mojom::RemoteObjectHost::GetObject";
      case messages::RemoteObjectHost::kAcquireObject:
            return "Receive blink::mojom::RemoteObjectHost::AcquireObject";
      case messages::RemoteObjectHost::kReleaseObject:
            return "Receive blink::mojom::RemoteObjectHost::ReleaseObject";
    }
  } else {
    switch (static_cast<messages::RemoteObjectHost>(message.name())) {
      case messages::RemoteObjectHost::kGetObject:
            return "Receive reply blink::mojom::RemoteObjectHost::GetObject";
      case messages::RemoteObjectHost::kAcquireObject:
            return "Receive reply blink::mojom::RemoteObjectHost::AcquireObject";
      case messages::RemoteObjectHost::kReleaseObject:
            return "Receive reply blink::mojom::RemoteObjectHost::ReleaseObject";
    }
  }
  return "Receive unknown mojo message";
#else
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (is_response) {
    return "Receive mojo reply";
  } else {
    return "Receive mojo message";
  }
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}

#if !BUILDFLAG(IS_FUCHSIA)
uint32_t RemoteObjectHost::GetObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0xaf4a2ac7;  // IPCStableHash for blink::mojom::RemoteObjectHost::GetObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObjectHost::AcquireObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0x18d4fce5;  // IPCStableHash for blink::mojom::RemoteObjectHost::AcquireObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObjectHost::ReleaseObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0x86742ad4;  // IPCStableHash for blink::mojom::RemoteObjectHost::ReleaseObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

RemoteObjectHostProxy::RemoteObjectHostProxy(mojo::MessageReceiverWithResponder* receiver)
    : receiver_(receiver) {
}

void RemoteObjectHostProxy::GetObject(
    int32_t in_object_id, ::mojo::PendingReceiver<RemoteObject> in_receiver) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectHost::GetObject", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("object_id"), in_object_id,
                        "<value of type int32_t>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("receiver"), in_receiver,
                        "<value of type ::mojo::PendingReceiver<RemoteObject>>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectHost::kGetObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectHost_GetObject_Params_Data> params(
          message);
  params.Allocate();

  params->object_id = in_object_id;

  
  mojo::internal::Serialize<mojo::InterfaceRequestDataView<::blink::mojom::RemoteObjectInterfaceBase>>(
    in_receiver,
    &params->receiver,
    &params.message());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(!mojo::internal::IsHandleOrInterfaceValid(params->receiver)),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
    "invalid receiver in RemoteObjectHost.GetObject request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectHost::Name_);
  message.set_method_name("GetObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

void RemoteObjectHostProxy::AcquireObject(
    int32_t in_object_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectHost::AcquireObject", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("object_id"), in_object_id,
                        "<value of type int32_t>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectHost::kAcquireObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectHost_AcquireObject_Params_Data> params(
          message);
  params.Allocate();

  params->object_id = in_object_id;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectHost::Name_);
  message.set_method_name("AcquireObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

void RemoteObjectHostProxy::ReleaseObject(
    int32_t in_object_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectHost::ReleaseObject", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("object_id"), in_object_id,
                        "<value of type int32_t>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectHost::kReleaseObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectHost_ReleaseObject_Params_Data> params(
          message);
  params.Allocate();

  params->object_id = in_object_id;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectHost::Name_);
  message.set_method_name("ReleaseObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

// static
bool RemoteObjectHostStubDispatch::Accept(
    RemoteObjectHost* impl,
    mojo::Message* message) {
  switch (static_cast<messages::RemoteObjectHost>(message->header()->name)) {
    case messages::RemoteObjectHost::kGetObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectHost_GetObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectHost_GetObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectHost.0
      bool success = true;
      int32_t p_object_id{};
      ::mojo::PendingReceiver<RemoteObject> p_receiver{};
      RemoteObjectHost_GetObject_ParamsDataView input_data_view(params, message);
      
      if (success)
        p_object_id = input_data_view.object_id();
      if (success) {
        p_receiver =
            input_data_view.TakeReceiver<decltype(p_receiver)>();
      }
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectHost::Name_, 0, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->GetObject(        
        std::move(p_object_id), 
        std::move(p_receiver));
      return true;
    }
    case messages::RemoteObjectHost::kAcquireObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectHost_AcquireObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectHost_AcquireObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectHost.1
      bool success = true;
      int32_t p_object_id{};
      RemoteObjectHost_AcquireObject_ParamsDataView input_data_view(params, message);
      
      if (success)
        p_object_id = input_data_view.object_id();
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectHost::Name_, 1, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->AcquireObject(        
        std::move(p_object_id));
      return true;
    }
    case messages::RemoteObjectHost::kReleaseObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectHost_ReleaseObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectHost_ReleaseObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectHost.2
      bool success = true;
      int32_t p_object_id{};
      RemoteObjectHost_ReleaseObject_ParamsDataView input_data_view(params, message);
      
      if (success)
        p_object_id = input_data_view.object_id();
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectHost::Name_, 2, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->ReleaseObject(        
        std::move(p_object_id));
      return true;
    }
  }
  return false;
}

// static
bool RemoteObjectHostStubDispatch::AcceptWithResponder(
    RemoteObjectHost* impl,
    mojo::Message* message,
    std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
  [[maybe_unused]] const bool message_is_sync =
      message->has_flag(mojo::Message::kFlagIsSync);
  [[maybe_unused]] const uint64_t request_id = message->request_id();
  switch (static_cast<messages::RemoteObjectHost>(message->header()->name)) {
    case messages::RemoteObjectHost::kGetObject: {
      break;
    }
    case messages::RemoteObjectHost::kAcquireObject: {
      break;
    }
    case messages::RemoteObjectHost::kReleaseObject: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kRemoteObjectHostValidationInfo[] = {
    { &internal::RemoteObjectHost_GetObject_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::RemoteObjectHost_AcquireObject_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::RemoteObjectHost_ReleaseObject_Params_Data::Validate,
     nullptr /* no response */},
};

bool RemoteObjectHostRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::RemoteObjectHost::Name_,
    kRemoteObjectHostValidationInfo);
}

// The declaration includes the definition on other builds.

RemoteObject::IPCStableHashFunction RemoteObject::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::RemoteObject>(message.name())) {
    case messages::RemoteObject::kHasMethod: {
      return &RemoteObject::HasMethod_Sym::IPCStableHash;
    }
    case messages::RemoteObject::kGetMethods: {
      return &RemoteObject::GetMethods_Sym::IPCStableHash;
    }
    case messages::RemoteObject::kInvokeMethod: {
      return &RemoteObject::InvokeMethod_Sym::IPCStableHash;
    }
    case messages::RemoteObject::kNotifyReleasedObject: {
      return &RemoteObject::NotifyReleasedObject_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* RemoteObject::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (!is_response) {
    switch (static_cast<messages::RemoteObject>(message.name())) {
      case messages::RemoteObject::kHasMethod:
            return "Receive blink::mojom::RemoteObject::HasMethod";
      case messages::RemoteObject::kGetMethods:
            return "Receive blink::mojom::RemoteObject::GetMethods";
      case messages::RemoteObject::kInvokeMethod:
            return "Receive blink::mojom::RemoteObject::InvokeMethod";
      case messages::RemoteObject::kNotifyReleasedObject:
            return "Receive blink::mojom::RemoteObject::NotifyReleasedObject";
    }
  } else {
    switch (static_cast<messages::RemoteObject>(message.name())) {
      case messages::RemoteObject::kHasMethod:
            return "Receive reply blink::mojom::RemoteObject::HasMethod";
      case messages::RemoteObject::kGetMethods:
            return "Receive reply blink::mojom::RemoteObject::GetMethods";
      case messages::RemoteObject::kInvokeMethod:
            return "Receive reply blink::mojom::RemoteObject::InvokeMethod";
      case messages::RemoteObject::kNotifyReleasedObject:
            return "Receive reply blink::mojom::RemoteObject::NotifyReleasedObject";
    }
  }
  return "Receive unknown mojo message";
#else
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (is_response) {
    return "Receive mojo reply";
  } else {
    return "Receive mojo message";
  }
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}

#if !BUILDFLAG(IS_FUCHSIA)
uint32_t RemoteObject::HasMethod_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0xc206b812;  // IPCStableHash for blink::mojom::RemoteObject::HasMethod
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObject::GetMethods_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0x1af9e494;  // IPCStableHash for blink::mojom::RemoteObject::GetMethods
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObject::InvokeMethod_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0x1efbabaa;  // IPCStableHash for blink::mojom::RemoteObject::InvokeMethod
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObject::NotifyReleasedObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0xa971932a;  // IPCStableHash for blink::mojom::RemoteObject::NotifyReleasedObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
bool RemoteObject::HasMethod(const std::string& name, bool* out_method_exists) {
  NOTREACHED();
}
bool RemoteObject::GetMethods(std::vector<std::string>* out_method_names) {
  NOTREACHED();
}
bool RemoteObject::InvokeMethod(const std::string& name, std::vector<RemoteInvocationArgumentPtr> arguments, RemoteInvocationResultPtr* out_result) {
  NOTREACHED();
}
class RemoteObject_HasMethod_HandleSyncResponse
    : public mojo::MessageReceiver {
 public:
  RemoteObject_HasMethod_HandleSyncResponse(
      bool* result, bool* out_method_exists)
      : result_(result), out_method_exists_(out_method_exists) {
    DCHECK(!*result_);
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  bool* result_;
  bool* out_method_exists_;};

class RemoteObject_HasMethod_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RemoteObject_HasMethod_ForwardToCallback(
      RemoteObject::HasMethodCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RemoteObject::HasMethodCallback callback_;
};
class RemoteObject_GetMethods_HandleSyncResponse
    : public mojo::MessageReceiver {
 public:
  RemoteObject_GetMethods_HandleSyncResponse(
      bool* result, std::vector<std::string>* out_method_names)
      : result_(result), out_method_names_(out_method_names) {
    DCHECK(!*result_);
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  bool* result_;
  std::vector<std::string>* out_method_names_;};

class RemoteObject_GetMethods_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RemoteObject_GetMethods_ForwardToCallback(
      RemoteObject::GetMethodsCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RemoteObject::GetMethodsCallback callback_;
};
class RemoteObject_InvokeMethod_HandleSyncResponse
    : public mojo::MessageReceiver {
 public:
  RemoteObject_InvokeMethod_HandleSyncResponse(
      bool* result, RemoteInvocationResultPtr* out_result)
      : result_(result), out_result_(out_result) {
    DCHECK(!*result_);
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  bool* result_;
  RemoteInvocationResultPtr* out_result_;};

class RemoteObject_InvokeMethod_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RemoteObject_InvokeMethod_ForwardToCallback(
      RemoteObject::InvokeMethodCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RemoteObject::InvokeMethodCallback callback_;
};

RemoteObjectProxy::RemoteObjectProxy(mojo::MessageReceiverWithResponder* receiver)
    : receiver_(receiver) {
}
bool RemoteObjectProxy::HasMethod(
    const std::string& param_name, bool* out_param_method_exists) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_BEGIN1(
    "mojom", "Call blink::mojom::RemoteObject::HasMethod (sync)", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), param_name,
                        "<value of type const std::string&>");
   });
#else
  TRACE_EVENT0("mojom", "RemoteObject::HasMethod");
#endif
  
  const bool kExpectsResponse = true;
  const bool kIsSync = true;
  const bool kAllowInterrupt =
      true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kHasMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_HasMethod_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    param_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObject.HasMethod request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("HasMethod");
#endif

  bool result = false;
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_HasMethod_HandleSyncResponse(
          &result, out_param_method_exists));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_END1(
    "mojom", "Call blink::mojom::RemoteObject::HasMethod (sync)", "sync_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("method_exists"), out_param_method_exists,
                        "<value of type bool>");
   });
#endif
  return result;
}

void RemoteObjectProxy::HasMethod(
    const std::string& in_name, HasMethodCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObject::HasMethod", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
   });
#endif

  const bool kExpectsResponse = true;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kHasMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_HasMethod_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObject.HasMethod request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("HasMethod");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_HasMethod_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
bool RemoteObjectProxy::GetMethods(
    std::vector<std::string>* out_param_method_names) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_BEGIN0("mojom", "Call blink::mojom::RemoteObject::GetMethods (sync)");
#else
  TRACE_EVENT0("mojom", "RemoteObject::GetMethods");
#endif
  
  const bool kExpectsResponse = true;
  const bool kIsSync = true;
  const bool kAllowInterrupt =
      true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kGetMethods), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_GetMethods_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("GetMethods");
#endif

  bool result = false;
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_GetMethods_HandleSyncResponse(
          &result, out_param_method_names));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_END1(
    "mojom", "Call blink::mojom::RemoteObject::GetMethods (sync)", "sync_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("method_names"), out_param_method_names,
                        "<value of type const std::vector<std::string>&>");
   });
#endif
  return result;
}

void RemoteObjectProxy::GetMethods(
    GetMethodsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send blink::mojom::RemoteObject::GetMethods");
#endif

  const bool kExpectsResponse = true;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kGetMethods), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_GetMethods_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("GetMethods");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_GetMethods_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
bool RemoteObjectProxy::InvokeMethod(
    const std::string& param_name, std::vector<RemoteInvocationArgumentPtr> param_arguments, RemoteInvocationResultPtr* out_param_result) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_BEGIN1(
    "mojom", "Call blink::mojom::RemoteObject::InvokeMethod (sync)", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), param_name,
                        "<value of type const std::string&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("arguments"), param_arguments,
                        "<value of type std::vector<RemoteInvocationArgumentPtr>>");
   });
#else
  TRACE_EVENT0("mojom", "RemoteObject::InvokeMethod");
#endif
  
  const bool kExpectsResponse = true;
  const bool kIsSync = true;
  const bool kAllowInterrupt =
      true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kInvokeMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_InvokeMethod_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    param_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObject.InvokeMethod request");
  mojo::internal::MessageFragment<
      typename decltype(params->arguments)::BaseType>
      arguments_fragment(params.message());
  constexpr const mojo::internal::ContainerValidateParams& arguments_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  
  mojo::internal::Serialize<mojo::ArrayDataView<::blink::mojom::RemoteInvocationArgumentDataView>>(
    param_arguments,
    arguments_fragment,
    &arguments_validate_params);

  params->arguments.Set(
      arguments_fragment.is_null() ? nullptr : arguments_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->arguments.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null arguments in RemoteObject.InvokeMethod request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("InvokeMethod");
#endif

  bool result = false;
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_InvokeMethod_HandleSyncResponse(
          &result, out_param_result));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_END1(
    "mojom", "Call blink::mojom::RemoteObject::InvokeMethod (sync)", "sync_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("result"), out_param_result,
                        "<value of type RemoteInvocationResultPtr>");
   });
#endif
  return result;
}

void RemoteObjectProxy::InvokeMethod(
    const std::string& in_name, std::vector<RemoteInvocationArgumentPtr> in_arguments, InvokeMethodCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObject::InvokeMethod", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("arguments"), in_arguments,
                        "<value of type std::vector<RemoteInvocationArgumentPtr>>");
   });
#endif

  const bool kExpectsResponse = true;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kInvokeMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_InvokeMethod_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObject.InvokeMethod request");
  mojo::internal::MessageFragment<
      typename decltype(params->arguments)::BaseType>
      arguments_fragment(params.message());
  constexpr const mojo::internal::ContainerValidateParams& arguments_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  
  mojo::internal::Serialize<mojo::ArrayDataView<::blink::mojom::RemoteInvocationArgumentDataView>>(
    in_arguments,
    arguments_fragment,
    &arguments_validate_params);

  params->arguments.Set(
      arguments_fragment.is_null() ? nullptr : arguments_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->arguments.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null arguments in RemoteObject.InvokeMethod request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("InvokeMethod");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new RemoteObject_InvokeMethod_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}

void RemoteObjectProxy::NotifyReleasedObject(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send blink::mojom::RemoteObject::NotifyReleasedObject");
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kNotifyReleasedObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_NotifyReleasedObject_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("NotifyReleasedObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}
class RemoteObject_HasMethod_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static RemoteObject::HasMethodCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<RemoteObject_HasMethod_ProxyToResponder> proxy(
        new RemoteObject_HasMethod_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&RemoteObject_HasMethod_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~RemoteObject_HasMethod_ProxyToResponder() {
#if DCHECK_IS_ON()
    if (responder_) {
      // If we're being destroyed without being run, we want to ensure the
      // binding endpoint has been closed. This checks for that asynchronously.
      // We pass a bound generated callback to handle the response so that any
      // resulting DCHECK stack will have useful interface type information.
      // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to
      // fizzle if this happens after shutdown and the endpoint is bound to a
      // BLOCK_SHUTDOWN sequence.
      base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler;
      responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
    }
#endif
  }

 private:
  RemoteObject_HasMethod_ProxyToResponder(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
      : ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
  }

#if DCHECK_IS_ON()
  static void OnIsConnectedComplete(bool connected) {
    DCHECK(!connected)
        << "RemoteObject::HasMethodCallback was destroyed without "
        << "first either being run or its corresponding binding being closed. "
        << "It is an error to drop response callbacks which still correspond "
        << "to an open interface pipe.";
  }
#endif

  void Run(
      bool in_method_exists);
};

bool RemoteObject_HasMethod_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_HasMethod_ResponseParams_Data* params =
      reinterpret_cast<
          internal::RemoteObject_HasMethod_ResponseParams_Data*>(
              message->mutable_payload());
  

  // Validation for RemoteObject.0
  bool success = true;
  bool p_method_exists{};
  RemoteObject_HasMethod_ResponseParamsDataView input_data_view(params, message);
  
  if (success)
    p_method_exists = input_data_view.method_exists();
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 0, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_method_exists));
  }
  return true;
}

void RemoteObject_HasMethod_ProxyToResponder::Run(
    bool in_method_exists) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::RemoteObject::HasMethod", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("method_exists"), in_method_exists,
                        "<value of type bool>");
   });
#endif

  const uint32_t kFlags = mojo::Message::kFlagIsResponse |
      ((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
      ((true) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((false) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kHasMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_HasMethod_ResponseParams_Data> params(
          message);
  params.Allocate();

  params->method_exists = in_method_exists;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("HasMethod");
#endif

  message.set_request_id(request_id_);
  message.set_trace_nonce(trace_nonce_);
  ::mojo::internal::SendMojoMessage(*responder_, message);
  // SendMojoMessage() fails silently if the responder connection is closed,
  // or if the message is malformed.
  //
  // TODO(darin): If Accept() returns false due to a malformed message, that
  // may be good reason to close the connection. However, we don't have a
  // way to do that from here. We should add a way.
  responder_ = nullptr;
}
bool RemoteObject_HasMethod_HandleSyncResponse::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_HasMethod_ResponseParams_Data* params =
      reinterpret_cast<internal::RemoteObject_HasMethod_ResponseParams_Data*>(
          message->mutable_payload());
  

  // Validation for RemoteObject.0
  bool success = true;
  bool p_method_exists{};
  RemoteObject_HasMethod_ResponseParamsDataView input_data_view(params, message);
  
  if (success)
    p_method_exists = input_data_view.method_exists();
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 0, true);
    return false;
  }
  *out_method_exists_ = std::move(p_method_exists);
  *result_ = true;
  return true;
}
class RemoteObject_GetMethods_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static RemoteObject::GetMethodsCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<RemoteObject_GetMethods_ProxyToResponder> proxy(
        new RemoteObject_GetMethods_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&RemoteObject_GetMethods_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~RemoteObject_GetMethods_ProxyToResponder() {
#if DCHECK_IS_ON()
    if (responder_) {
      // If we're being destroyed without being run, we want to ensure the
      // binding endpoint has been closed. This checks for that asynchronously.
      // We pass a bound generated callback to handle the response so that any
      // resulting DCHECK stack will have useful interface type information.
      // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to
      // fizzle if this happens after shutdown and the endpoint is bound to a
      // BLOCK_SHUTDOWN sequence.
      base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler;
      responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
    }
#endif
  }

 private:
  RemoteObject_GetMethods_ProxyToResponder(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
      : ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
  }

#if DCHECK_IS_ON()
  static void OnIsConnectedComplete(bool connected) {
    DCHECK(!connected)
        << "RemoteObject::GetMethodsCallback was destroyed without "
        << "first either being run or its corresponding binding being closed. "
        << "It is an error to drop response callbacks which still correspond "
        << "to an open interface pipe.";
  }
#endif

  void Run(
      const std::vector<std::string>& in_method_names);
};

bool RemoteObject_GetMethods_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_GetMethods_ResponseParams_Data* params =
      reinterpret_cast<
          internal::RemoteObject_GetMethods_ResponseParams_Data*>(
              message->mutable_payload());
  

  // Validation for RemoteObject.1
  bool success = true;
  std::vector<std::string> p_method_names{};
  RemoteObject_GetMethods_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadMethodNames(&p_method_names))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 1, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_method_names));
  }
  return true;
}

void RemoteObject_GetMethods_ProxyToResponder::Run(
    const std::vector<std::string>& in_method_names) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::RemoteObject::GetMethods", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("method_names"), in_method_names,
                        "<value of type const std::vector<std::string>&>");
   });
#endif

  const uint32_t kFlags = mojo::Message::kFlagIsResponse |
      ((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
      ((true) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((false) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kGetMethods), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_GetMethods_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->method_names)::BaseType>
      method_names_fragment(params.message());
  constexpr const mojo::internal::ContainerValidateParams& method_names_validate_params =
      mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
  
  mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
    in_method_names,
    method_names_fragment,
    &method_names_validate_params);

  params->method_names.Set(
      method_names_fragment.is_null() ? nullptr : method_names_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->method_names.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null method_names in ");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("GetMethods");
#endif

  message.set_request_id(request_id_);
  message.set_trace_nonce(trace_nonce_);
  ::mojo::internal::SendMojoMessage(*responder_, message);
  // SendMojoMessage() fails silently if the responder connection is closed,
  // or if the message is malformed.
  //
  // TODO(darin): If Accept() returns false due to a malformed message, that
  // may be good reason to close the connection. However, we don't have a
  // way to do that from here. We should add a way.
  responder_ = nullptr;
}
bool RemoteObject_GetMethods_HandleSyncResponse::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_GetMethods_ResponseParams_Data* params =
      reinterpret_cast<internal::RemoteObject_GetMethods_ResponseParams_Data*>(
          message->mutable_payload());
  

  // Validation for RemoteObject.1
  bool success = true;
  std::vector<std::string> p_method_names{};
  RemoteObject_GetMethods_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadMethodNames(&p_method_names))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 1, true);
    return false;
  }
  *out_method_names_ = std::move(p_method_names);
  *result_ = true;
  return true;
}
class RemoteObject_InvokeMethod_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static RemoteObject::InvokeMethodCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<RemoteObject_InvokeMethod_ProxyToResponder> proxy(
        new RemoteObject_InvokeMethod_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&RemoteObject_InvokeMethod_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~RemoteObject_InvokeMethod_ProxyToResponder() {
#if DCHECK_IS_ON()
    if (responder_) {
      // If we're being destroyed without being run, we want to ensure the
      // binding endpoint has been closed. This checks for that asynchronously.
      // We pass a bound generated callback to handle the response so that any
      // resulting DCHECK stack will have useful interface type information.
      // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to
      // fizzle if this happens after shutdown and the endpoint is bound to a
      // BLOCK_SHUTDOWN sequence.
      base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler;
      responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
    }
#endif
  }

 private:
  RemoteObject_InvokeMethod_ProxyToResponder(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
      : ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
  }

#if DCHECK_IS_ON()
  static void OnIsConnectedComplete(bool connected) {
    DCHECK(!connected)
        << "RemoteObject::InvokeMethodCallback was destroyed without "
        << "first either being run or its corresponding binding being closed. "
        << "It is an error to drop response callbacks which still correspond "
        << "to an open interface pipe.";
  }
#endif

  void Run(
      RemoteInvocationResultPtr in_result);
};

bool RemoteObject_InvokeMethod_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_InvokeMethod_ResponseParams_Data* params =
      reinterpret_cast<
          internal::RemoteObject_InvokeMethod_ResponseParams_Data*>(
              message->mutable_payload());
  

  // Validation for RemoteObject.2
  bool success = true;
  RemoteInvocationResultPtr p_result{};
  RemoteObject_InvokeMethod_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadResult(&p_result))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 2, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_result));
  }
  return true;
}

void RemoteObject_InvokeMethod_ProxyToResponder::Run(
    RemoteInvocationResultPtr in_result) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::RemoteObject::InvokeMethod", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("result"), in_result,
                        "<value of type RemoteInvocationResultPtr>");
   });
#endif

  const uint32_t kFlags = mojo::Message::kFlagIsResponse |
      ((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
      ((true) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((false) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObject::kInvokeMethod), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObject_InvokeMethod_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->result)::BaseType> result_fragment(
          params.message());
  
  mojo::internal::Serialize<::blink::mojom::RemoteInvocationResultDataView>(
    in_result,
    result_fragment);

  params->result.Set(
      result_fragment.is_null() ? nullptr : result_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->result.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null result in ");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObject::Name_);
  message.set_method_name("InvokeMethod");
#endif

  message.set_request_id(request_id_);
  message.set_trace_nonce(trace_nonce_);
  ::mojo::internal::SendMojoMessage(*responder_, message);
  // SendMojoMessage() fails silently if the responder connection is closed,
  // or if the message is malformed.
  //
  // TODO(darin): If Accept() returns false due to a malformed message, that
  // may be good reason to close the connection. However, we don't have a
  // way to do that from here. We should add a way.
  responder_ = nullptr;
}
bool RemoteObject_InvokeMethod_HandleSyncResponse::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RemoteObject_InvokeMethod_ResponseParams_Data* params =
      reinterpret_cast<internal::RemoteObject_InvokeMethod_ResponseParams_Data*>(
          message->mutable_payload());
  

  // Validation for RemoteObject.2
  bool success = true;
  RemoteInvocationResultPtr p_result{};
  RemoteObject_InvokeMethod_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadResult(&p_result))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RemoteObject::Name_, 2, true);
    return false;
  }
  *out_result_ = std::move(p_result);
  *result_ = true;
  return true;
}

// static
bool RemoteObjectStubDispatch::Accept(
    RemoteObject* impl,
    mojo::Message* message) {
  switch (static_cast<messages::RemoteObject>(message->header()->name)) {
    case messages::RemoteObject::kHasMethod: {
      break;
    }
    case messages::RemoteObject::kGetMethods: {
      break;
    }
    case messages::RemoteObject::kInvokeMethod: {
      break;
    }
    case messages::RemoteObject::kNotifyReleasedObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObject_NotifyReleasedObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObject_NotifyReleasedObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObject.3
      bool success = true;
      RemoteObject_NotifyReleasedObject_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObject::Name_, 3, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->NotifyReleasedObject(        );
      return true;
    }
  }
  return false;
}

// static
bool RemoteObjectStubDispatch::AcceptWithResponder(
    RemoteObject* impl,
    mojo::Message* message,
    std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
  [[maybe_unused]] const bool message_is_sync =
      message->has_flag(mojo::Message::kFlagIsSync);
  [[maybe_unused]] const uint64_t request_id = message->request_id();
  switch (static_cast<messages::RemoteObject>(message->header()->name)) {
    case messages::RemoteObject::kHasMethod: {
      internal::RemoteObject_HasMethod_Params_Data* params =
          reinterpret_cast<
              internal::RemoteObject_HasMethod_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RemoteObject.0
      bool success = true;
      std::string p_name{};
      RemoteObject_HasMethod_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObject::Name_, 0, false);
        return false;
      }
      auto callback =
          RemoteObject_HasMethod_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->HasMethod(        
        std::move(p_name), std::move(callback));
      return true;
    }
    case messages::RemoteObject::kGetMethods: {
      internal::RemoteObject_GetMethods_Params_Data* params =
          reinterpret_cast<
              internal::RemoteObject_GetMethods_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RemoteObject.1
      bool success = true;
      RemoteObject_GetMethods_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObject::Name_, 1, false);
        return false;
      }
      auto callback =
          RemoteObject_GetMethods_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->GetMethods(std::move(callback));
      return true;
    }
    case messages::RemoteObject::kInvokeMethod: {
      internal::RemoteObject_InvokeMethod_Params_Data* params =
          reinterpret_cast<
              internal::RemoteObject_InvokeMethod_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RemoteObject.2
      bool success = true;
      std::string p_name{};
      std::vector<RemoteInvocationArgumentPtr> p_arguments{};
      RemoteObject_InvokeMethod_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (success && !input_data_view.ReadArguments(&p_arguments))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObject::Name_, 2, false);
        return false;
      }
      auto callback =
          RemoteObject_InvokeMethod_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->InvokeMethod(        
        std::move(p_name), 
        std::move(p_arguments), std::move(callback));
      return true;
    }
    case messages::RemoteObject::kNotifyReleasedObject: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kRemoteObjectValidationInfo[] = {
    { &internal::RemoteObject_HasMethod_Params_Data::Validate,
     &internal::RemoteObject_HasMethod_ResponseParams_Data::Validate},
    { &internal::RemoteObject_GetMethods_Params_Data::Validate,
     &internal::RemoteObject_GetMethods_ResponseParams_Data::Validate},
    { &internal::RemoteObject_InvokeMethod_Params_Data::Validate,
     &internal::RemoteObject_InvokeMethod_ResponseParams_Data::Validate},
    { &internal::RemoteObject_NotifyReleasedObject_Params_Data::Validate,
     nullptr /* no response */},
};

bool RemoteObjectRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::RemoteObject::Name_,
    kRemoteObjectValidationInfo);
}

bool RemoteObjectResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::blink::mojom::RemoteObject::Name_,
    kRemoteObjectValidationInfo);
}
// The declaration includes the definition on other builds.

RemoteObjectGatewayFactory::IPCStableHashFunction RemoteObjectGatewayFactory::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::RemoteObjectGatewayFactory>(message.name())) {
    case messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway: {
      return &RemoteObjectGatewayFactory::CreateRemoteObjectGateway_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* RemoteObjectGatewayFactory::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (!is_response) {
    switch (static_cast<messages::RemoteObjectGatewayFactory>(message.name())) {
      case messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway:
            return "Receive blink::mojom::RemoteObjectGatewayFactory::CreateRemoteObjectGateway";
    }
  } else {
    switch (static_cast<messages::RemoteObjectGatewayFactory>(message.name())) {
      case messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway:
            return "Receive reply blink::mojom::RemoteObjectGatewayFactory::CreateRemoteObjectGateway";
    }
  }
  return "Receive unknown mojo message";
#else
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (is_response) {
    return "Receive mojo reply";
  } else {
    return "Receive mojo message";
  }
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}

#if !BUILDFLAG(IS_FUCHSIA)
uint32_t RemoteObjectGatewayFactory::CreateRemoteObjectGateway_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0xdeb48365;  // IPCStableHash for blink::mojom::RemoteObjectGatewayFactory::CreateRemoteObjectGateway
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

RemoteObjectGatewayFactoryProxy::RemoteObjectGatewayFactoryProxy(mojo::MessageReceiverWithResponder* receiver)
    : receiver_(receiver) {
}

void RemoteObjectGatewayFactoryProxy::CreateRemoteObjectGateway(
    ::mojo::PendingRemote<RemoteObjectHost> in_host, ::mojo::PendingReceiver<RemoteObjectGateway> in_gateway) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectGatewayFactory::CreateRemoteObjectGateway", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("host"), in_host,
                        "<value of type ::mojo::PendingRemote<RemoteObjectHost>>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("gateway"), in_gateway,
                        "<value of type ::mojo::PendingReceiver<RemoteObjectGateway>>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectGatewayFactory_CreateRemoteObjectGateway_Params_Data> params(
          message);
  params.Allocate();

  
  mojo::internal::Serialize<mojo::InterfacePtrDataView<::blink::mojom::RemoteObjectHostInterfaceBase>>(
    in_host,
    &params->host,
    &params.message());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(!mojo::internal::IsHandleOrInterfaceValid(params->host)),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
    "invalid host in RemoteObjectGatewayFactory.CreateRemoteObjectGateway request");

  
  mojo::internal::Serialize<mojo::InterfaceRequestDataView<::blink::mojom::RemoteObjectGatewayInterfaceBase>>(
    in_gateway,
    &params->gateway,
    &params.message());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(!mojo::internal::IsHandleOrInterfaceValid(params->gateway)),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
    "invalid gateway in RemoteObjectGatewayFactory.CreateRemoteObjectGateway request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectGatewayFactory::Name_);
  message.set_method_name("CreateRemoteObjectGateway");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

// static
bool RemoteObjectGatewayFactoryStubDispatch::Accept(
    RemoteObjectGatewayFactory* impl,
    mojo::Message* message) {
  switch (static_cast<messages::RemoteObjectGatewayFactory>(message->header()->name)) {
    case messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectGatewayFactory_CreateRemoteObjectGateway_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectGatewayFactory_CreateRemoteObjectGateway_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectGatewayFactory.0
      bool success = true;
      ::mojo::PendingRemote<RemoteObjectHost> p_host{};
      ::mojo::PendingReceiver<RemoteObjectGateway> p_gateway{};
      RemoteObjectGatewayFactory_CreateRemoteObjectGateway_ParamsDataView input_data_view(params, message);
      
      if (success) {
        p_host =
            input_data_view.TakeHost<decltype(p_host)>();
      }
      if (success) {
        p_gateway =
            input_data_view.TakeGateway<decltype(p_gateway)>();
      }
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectGatewayFactory::Name_, 0, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->CreateRemoteObjectGateway(        
        std::move(p_host), 
        std::move(p_gateway));
      return true;
    }
  }
  return false;
}

// static
bool RemoteObjectGatewayFactoryStubDispatch::AcceptWithResponder(
    RemoteObjectGatewayFactory* impl,
    mojo::Message* message,
    std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
  [[maybe_unused]] const bool message_is_sync =
      message->has_flag(mojo::Message::kFlagIsSync);
  [[maybe_unused]] const uint64_t request_id = message->request_id();
  switch (static_cast<messages::RemoteObjectGatewayFactory>(message->header()->name)) {
    case messages::RemoteObjectGatewayFactory::kCreateRemoteObjectGateway: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kRemoteObjectGatewayFactoryValidationInfo[] = {
    { &internal::RemoteObjectGatewayFactory_CreateRemoteObjectGateway_Params_Data::Validate,
     nullptr /* no response */},
};

bool RemoteObjectGatewayFactoryRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::RemoteObjectGatewayFactory::Name_,
    kRemoteObjectGatewayFactoryValidationInfo);
}

// The declaration includes the definition on other builds.

RemoteObjectGateway::IPCStableHashFunction RemoteObjectGateway::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::RemoteObjectGateway>(message.name())) {
    case messages::RemoteObjectGateway::kAddNamedObject: {
      return &RemoteObjectGateway::AddNamedObject_Sym::IPCStableHash;
    }
    case messages::RemoteObjectGateway::kRemoveNamedObject: {
      return &RemoteObjectGateway::RemoveNamedObject_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* RemoteObjectGateway::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (!is_response) {
    switch (static_cast<messages::RemoteObjectGateway>(message.name())) {
      case messages::RemoteObjectGateway::kAddNamedObject:
            return "Receive blink::mojom::RemoteObjectGateway::AddNamedObject";
      case messages::RemoteObjectGateway::kRemoveNamedObject:
            return "Receive blink::mojom::RemoteObjectGateway::RemoveNamedObject";
    }
  } else {
    switch (static_cast<messages::RemoteObjectGateway>(message.name())) {
      case messages::RemoteObjectGateway::kAddNamedObject:
            return "Receive reply blink::mojom::RemoteObjectGateway::AddNamedObject";
      case messages::RemoteObjectGateway::kRemoveNamedObject:
            return "Receive reply blink::mojom::RemoteObjectGateway::RemoveNamedObject";
    }
  }
  return "Receive unknown mojo message";
#else
  bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
  if (is_response) {
    return "Receive mojo reply";
  } else {
    return "Receive mojo message";
  }
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}

#if !BUILDFLAG(IS_FUCHSIA)
uint32_t RemoteObjectGateway::AddNamedObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0xa0ef64af;  // IPCStableHash for blink::mojom::RemoteObjectGateway::AddNamedObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RemoteObjectGateway::RemoveNamedObject_Sym::IPCStableHash() {
  // This method's address is used for identifying the mojo method name after
  // symbolization. So each IPCStableHash should have a unique address.
  // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
  // __LINE__ value, which is not unique across different mojo modules.
  // The code below is very similar to NO_CODE_FOLDING, but it uses a unique
  // hash instead of __LINE__.
  static constexpr uint32_t kHash = 0x17cf96bf;  // IPCStableHash for blink::mojom::RemoteObjectGateway::RemoveNamedObject
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

RemoteObjectGatewayProxy::RemoteObjectGatewayProxy(mojo::MessageReceiverWithResponder* receiver)
    : receiver_(receiver) {
}

void RemoteObjectGatewayProxy::AddNamedObject(
    const std::string& in_name, int32_t in_object_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectGateway::AddNamedObject", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("object_id"), in_object_id,
                        "<value of type int32_t>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectGateway::kAddNamedObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectGateway_AddNamedObject_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObjectGateway.AddNamedObject request");

  params->object_id = in_object_id;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectGateway::Name_);
  message.set_method_name("AddNamedObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

void RemoteObjectGatewayProxy::RemoveNamedObject(
    const std::string& in_name) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RemoteObjectGateway::RemoveNamedObject", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
   });
#endif

  const bool kExpectsResponse = false;
  const bool kIsSync = false;
  const bool kAllowInterrupt = true;
  const bool is_urgent = false;

  const uint32_t kFlags =
      ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
      ((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
      ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
      ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RemoteObjectGateway::kRemoveNamedObject), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RemoteObjectGateway_RemoveNamedObject_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->name)::BaseType> name_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_name,
    name_fragment);

  params->name.Set(
      name_fragment.is_null() ? nullptr : name_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->name.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null name in RemoteObjectGateway.RemoveNamedObject request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RemoteObjectGateway::Name_);
  message.set_method_name("RemoveNamedObject");
#endif
  // This return value may be ignored as false implies the Connector has
  // encountered an error, which will be visible through other means.
  ::mojo::internal::SendMojoMessage(*receiver_, message);
}

// static
bool RemoteObjectGatewayStubDispatch::Accept(
    RemoteObjectGateway* impl,
    mojo::Message* message) {
  switch (static_cast<messages::RemoteObjectGateway>(message->header()->name)) {
    case messages::RemoteObjectGateway::kAddNamedObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectGateway_AddNamedObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectGateway_AddNamedObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectGateway.0
      bool success = true;
      std::string p_name{};
      int32_t p_object_id{};
      RemoteObjectGateway_AddNamedObject_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (success)
        p_object_id = input_data_view.object_id();
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectGateway::Name_, 0, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->AddNamedObject(        
        std::move(p_name), 
        std::move(p_object_id));
      return true;
    }
    case messages::RemoteObjectGateway::kRemoveNamedObject: {
      DCHECK(message->is_serialized());
      internal::RemoteObjectGateway_RemoveNamedObject_Params_Data* params =
          reinterpret_cast<internal::RemoteObjectGateway_RemoveNamedObject_Params_Data*>(
              message->mutable_payload());
      

      // Validation for RemoteObjectGateway.1
      bool success = true;
      std::string p_name{};
      RemoteObjectGateway_RemoveNamedObject_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RemoteObjectGateway::Name_, 1, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->RemoveNamedObject(        
        std::move(p_name));
      return true;
    }
  }
  return false;
}

// static
bool RemoteObjectGatewayStubDispatch::AcceptWithResponder(
    RemoteObjectGateway* impl,
    mojo::Message* message,
    std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
  [[maybe_unused]] const bool message_is_sync =
      message->has_flag(mojo::Message::kFlagIsSync);
  [[maybe_unused]] const uint64_t request_id = message->request_id();
  switch (static_cast<messages::RemoteObjectGateway>(message->header()->name)) {
    case messages::RemoteObjectGateway::kAddNamedObject: {
      break;
    }
    case messages::RemoteObjectGateway::kRemoveNamedObject: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kRemoteObjectGatewayValidationInfo[] = {
    { &internal::RemoteObjectGateway_AddNamedObject_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::RemoteObjectGateway_RemoveNamedObject_Params_Data::Validate,
     nullptr /* no response */},
};

bool RemoteObjectGatewayRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::RemoteObjectGateway::Name_,
    kRemoteObjectGatewayValidationInfo);
}



}  // blink::mojom


namespace mojo {


// static
bool StructTraits<::blink::mojom::RemoteTypedArray::DataView, ::blink::mojom::RemoteTypedArrayPtr>::Read(
    ::blink::mojom::RemoteTypedArray::DataView input,
    ::blink::mojom::RemoteTypedArrayPtr* output) {
  bool success = true;
  ::blink::mojom::RemoteTypedArrayPtr result(::blink::mojom::RemoteTypedArray::New());
  
      if (success && !input.ReadType(&result->type))
        success = false;
      if (success && !input.ReadBuffer(&result->buffer))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::RemoteInvocationResult::DataView, ::blink::mojom::RemoteInvocationResultPtr>::Read(
    ::blink::mojom::RemoteInvocationResult::DataView input,
    ::blink::mojom::RemoteInvocationResultPtr* output) {
  bool success = true;
  ::blink::mojom::RemoteInvocationResultPtr result(::blink::mojom::RemoteInvocationResult::New());
  
      if (success && !input.ReadError(&result->error))
        success = false;
      if (success && !input.ReadValue(&result->value))
        success = false;
  *output = std::move(result);
  return success;
}

// static
bool UnionTraits<::blink::mojom::RemoteInvocationArgument::DataView, ::blink::mojom::RemoteInvocationArgumentPtr>::Read(
    ::blink::mojom::RemoteInvocationArgument::DataView input,
    ::blink::mojom::RemoteInvocationArgumentPtr* output) {
  using UnionType = ::blink::mojom::RemoteInvocationArgument;
  using Tag = UnionType::Tag;

  switch (input.tag()) {
    case Tag::kNumberValue: {
      *output = UnionType::NewNumberValue(input.number_value());
      break;
    }
    case Tag::kBooleanValue: {
      *output = UnionType::NewBooleanValue(input.boolean_value());
      break;
    }
    case Tag::kStringValue: {
      ::std::u16string result_string_value{};
      if (!input.ReadStringValue(&result_string_value))
        return false;

      *output = UnionType::NewStringValue(
          std::move(result_string_value));
      break;
    }
    case Tag::kSingletonValue: {
      ::blink::mojom::SingletonJavaScriptValue result_singleton_value;
      if (!input.ReadSingletonValue(&result_singleton_value))
        return false;

      *output = UnionType::NewSingletonValue(result_singleton_value);
      break;
    }
    case Tag::kArrayValue: {
      std::vector<::blink::mojom::RemoteInvocationArgumentPtr> result_array_value{};
      if (!input.ReadArrayValue(&result_array_value))
        return false;

      *output = UnionType::NewArrayValue(
          std::move(result_array_value));
      break;
    }
    case Tag::kTypedArrayValue: {
      ::blink::mojom::RemoteTypedArrayPtr result_typed_array_value{};
      if (!input.ReadTypedArrayValue(&result_typed_array_value))
        return false;

      *output = UnionType::NewTypedArrayValue(
          std::move(result_typed_array_value));
      break;
    }
    case Tag::kObjectIdValue: {
      *output = UnionType::NewObjectIdValue(input.object_id_value());
      break;
    }
    default:

      return false;
  }
  return true;
}

// static
bool UnionTraits<::blink::mojom::RemoteInvocationResultValue::DataView, ::blink::mojom::RemoteInvocationResultValuePtr>::Read(
    ::blink::mojom::RemoteInvocationResultValue::DataView input,
    ::blink::mojom::RemoteInvocationResultValuePtr* output) {
  using UnionType = ::blink::mojom::RemoteInvocationResultValue;
  using Tag = UnionType::Tag;

  switch (input.tag()) {
    case Tag::kNumberValue: {
      *output = UnionType::NewNumberValue(input.number_value());
      break;
    }
    case Tag::kBooleanValue: {
      *output = UnionType::NewBooleanValue(input.boolean_value());
      break;
    }
    case Tag::kStringValue: {
      ::std::u16string result_string_value{};
      if (!input.ReadStringValue(&result_string_value))
        return false;

      *output = UnionType::NewStringValue(
          std::move(result_string_value));
      break;
    }
    case Tag::kSingletonValue: {
      ::blink::mojom::SingletonJavaScriptValue result_singleton_value;
      if (!input.ReadSingletonValue(&result_singleton_value))
        return false;

      *output = UnionType::NewSingletonValue(result_singleton_value);
      break;
    }
    case Tag::kObjectId: {
      *output = UnionType::NewObjectId(input.object_id());
      break;
    }
    default:

      return false;
  }
  return true;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace blink::mojom {


void RemoteObjectHostInterceptorForTesting::GetObject(int32_t object_id, ::mojo::PendingReceiver<RemoteObject> receiver) {
  GetForwardingInterface()->GetObject(
    std::move(object_id)
    , 
    std::move(receiver)
    );
}
void RemoteObjectHostInterceptorForTesting::AcquireObject(int32_t object_id) {
  GetForwardingInterface()->AcquireObject(
    std::move(object_id)
    );
}
void RemoteObjectHostInterceptorForTesting::ReleaseObject(int32_t object_id) {
  GetForwardingInterface()->ReleaseObject(
    std::move(object_id)
    );
}
RemoteObjectHostAsyncWaiter::RemoteObjectHostAsyncWaiter(
    RemoteObjectHost* proxy) : proxy_(proxy) {}

RemoteObjectHostAsyncWaiter::~RemoteObjectHostAsyncWaiter() = default;





void RemoteObjectInterceptorForTesting::HasMethod(const std::string& name, HasMethodCallback callback) {
  GetForwardingInterface()->HasMethod(
    std::move(name)
    , std::move(callback));
}
void RemoteObjectInterceptorForTesting::GetMethods(GetMethodsCallback callback) {
  GetForwardingInterface()->GetMethods(std::move(callback));
}
void RemoteObjectInterceptorForTesting::InvokeMethod(const std::string& name, std::vector<RemoteInvocationArgumentPtr> arguments, InvokeMethodCallback callback) {
  GetForwardingInterface()->InvokeMethod(
    std::move(name)
    , 
    std::move(arguments)
    , std::move(callback));
}
void RemoteObjectInterceptorForTesting::NotifyReleasedObject() {
  GetForwardingInterface()->NotifyReleasedObject();
}
RemoteObjectAsyncWaiter::RemoteObjectAsyncWaiter(
    RemoteObject* proxy) : proxy_(proxy) {}

RemoteObjectAsyncWaiter::~RemoteObjectAsyncWaiter() = default;


void RemoteObjectAsyncWaiter::HasMethod(
    const std::string& name, bool* out_method_exists) {
  base::RunLoop loop;
  proxy_->HasMethod(
      std::move(name),
      base::BindOnce(
          [](base::RunLoop* loop,
             bool* out_method_exists
,
             bool method_exists) {*out_method_exists = std::move(method_exists);
            loop->Quit();
          },
          &loop,
          out_method_exists));
  loop.Run();
}

bool RemoteObjectAsyncWaiter::HasMethod(
    const std::string& name) {
  bool async_wait_result;
  HasMethod(std::move(name),&async_wait_result);
  return async_wait_result;
}

void RemoteObjectAsyncWaiter::GetMethods(
    std::vector<std::string>* out_method_names) {
  base::RunLoop loop;
  proxy_->GetMethods(
      base::BindOnce(
          [](base::RunLoop* loop,
             std::vector<std::string>* out_method_names
,
             const std::vector<std::string>& method_names) {*out_method_names = std::move(method_names);
            loop->Quit();
          },
          &loop,
          out_method_names));
  loop.Run();
}

std::vector<std::string> RemoteObjectAsyncWaiter::GetMethods(
    ) {
  std::vector<std::string> async_wait_result;
  GetMethods(&async_wait_result);
  return async_wait_result;
}

void RemoteObjectAsyncWaiter::InvokeMethod(
    const std::string& name, std::vector<RemoteInvocationArgumentPtr> arguments, RemoteInvocationResultPtr* out_result) {
  base::RunLoop loop;
  proxy_->InvokeMethod(
      std::move(name),
      std::move(arguments),
      base::BindOnce(
          [](base::RunLoop* loop,
             RemoteInvocationResultPtr* out_result
,
             RemoteInvocationResultPtr result) {*out_result = std::move(result);
            loop->Quit();
          },
          &loop,
          out_result));
  loop.Run();
}

RemoteInvocationResultPtr RemoteObjectAsyncWaiter::InvokeMethod(
    const std::string& name, std::vector<RemoteInvocationArgumentPtr> arguments) {
  RemoteInvocationResultPtr async_wait_result;
  InvokeMethod(std::move(name),std::move(arguments),&async_wait_result);
  return async_wait_result;
}




void RemoteObjectGatewayFactoryInterceptorForTesting::CreateRemoteObjectGateway(::mojo::PendingRemote<RemoteObjectHost> host, ::mojo::PendingReceiver<RemoteObjectGateway> gateway) {
  GetForwardingInterface()->CreateRemoteObjectGateway(
    std::move(host)
    , 
    std::move(gateway)
    );
}
RemoteObjectGatewayFactoryAsyncWaiter::RemoteObjectGatewayFactoryAsyncWaiter(
    RemoteObjectGatewayFactory* proxy) : proxy_(proxy) {}

RemoteObjectGatewayFactoryAsyncWaiter::~RemoteObjectGatewayFactoryAsyncWaiter() = default;





void RemoteObjectGatewayInterceptorForTesting::AddNamedObject(const std::string& name, int32_t object_id) {
  GetForwardingInterface()->AddNamedObject(
    std::move(name)
    , 
    std::move(object_id)
    );
}
void RemoteObjectGatewayInterceptorForTesting::RemoveNamedObject(const std::string& name) {
  GetForwardingInterface()->RemoveNamedObject(
    std::move(name)
    );
}
RemoteObjectGatewayAsyncWaiter::RemoteObjectGatewayAsyncWaiter(
    RemoteObjectGateway* proxy) : proxy_(proxy) {}

RemoteObjectGatewayAsyncWaiter::~RemoteObjectGatewayAsyncWaiter() = default;







}  // blink::mojom


#if defined(__clang__)
#pragma clang diagnostic pop
#endif