// third_party/blink/public/mojom/content_extraction/script_tools.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/content_extraction/script_tools.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/content_extraction/script_tools.mojom-params-data.h"
#include "third_party/blink/public/mojom/content_extraction/script_tools.mojom-shared-message-ids.h"

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


namespace blink::mojom {
ScriptToolAnnotations::ScriptToolAnnotations()
    : read_only(),
      untrusted_content(),
      consequential() {}

ScriptToolAnnotations::ScriptToolAnnotations(
    bool read_only_in,
    bool untrusted_content_in,
    bool consequential_in)
    : read_only(std::move(read_only_in)),
      untrusted_content(std::move(untrusted_content_in)),
      consequential(std::move(consequential_in)) {}

ScriptToolAnnotations::~ScriptToolAnnotations() = default;
size_t ScriptToolAnnotations::Hash(size_t seed) const {
  seed = mojo::internal::Hash(seed, this->read_only);
  seed = mojo::internal::Hash(seed, this->untrusted_content);
  seed = mojo::internal::Hash(seed, this->consequential);
  return seed;
}

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

bool ScriptToolAnnotations::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
ScriptTool::ScriptTool()
    : name(),
      title(),
      description(),
      input_schema(),
      annotations(),
      exposed_origins(),
      tool_owner_frame_token(),
      origin() {}

ScriptTool::ScriptTool(
    const std::string& name_in,
    const std::optional<std::string>& title_in,
    const std::string& description_in,
    const std::optional<std::string>& input_schema_in,
    ScriptToolAnnotationsPtr annotations_in,
    std::vector<::url::Origin> exposed_origins_in,
    const ::blink::FrameToken& tool_owner_frame_token_in,
    const ::url::Origin& origin_in)
    : name(std::move(name_in)),
      title(std::move(title_in)),
      description(std::move(description_in)),
      input_schema(std::move(input_schema_in)),
      annotations(std::move(annotations_in)),
      exposed_origins(std::move(exposed_origins_in)),
      tool_owner_frame_token(std::move(tool_owner_frame_token_in)),
      origin(std::move(origin_in)) {}

ScriptTool::~ScriptTool() = default;

void ScriptTool::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "name"), this->name,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "title"), this->title,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::string>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "description"), this->description,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "input_schema"), this->input_schema,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<std::string>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "annotations"), this->annotations,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ScriptToolAnnotationsPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "exposed_origins"), this->exposed_origins,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::vector<::url::Origin>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "tool_owner_frame_token"), this->tool_owner_frame_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::FrameToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "origin"), this->origin,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::url::Origin&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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

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


const char* ScriptToolHost::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::ScriptToolHost>(message.name())) {
      case messages::ScriptToolHost::kPauseExecution:
            return "Receive blink::mojom::ScriptToolHost::PauseExecution";
    }
  } else {
    switch (static_cast<messages::ScriptToolHost>(message.name())) {
      case messages::ScriptToolHost::kPauseExecution:
            return "Receive reply blink::mojom::ScriptToolHost::PauseExecution";
    }
  }
  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 ScriptToolHost::PauseExecution_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 = 0xe5be0b43;  // IPCStableHash for blink::mojom::ScriptToolHost::PauseExecution
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

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

void ScriptToolHostProxy::PauseExecution(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send blink::mojom::ScriptToolHost::PauseExecution");
#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::ScriptToolHost::kPauseExecution), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ScriptToolHost_PauseExecution_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ScriptToolHost::Name_);
  message.set_method_name("PauseExecution");
#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 ScriptToolHostStubDispatch::Accept(
    ScriptToolHost* impl,
    mojo::Message* message) {
  switch (static_cast<messages::ScriptToolHost>(message->header()->name)) {
    case messages::ScriptToolHost::kPauseExecution: {
      DCHECK(message->is_serialized());
      internal::ScriptToolHost_PauseExecution_Params_Data* params =
          reinterpret_cast<internal::ScriptToolHost_PauseExecution_Params_Data*>(
              message->mutable_payload());
      

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

// static
bool ScriptToolHostStubDispatch::AcceptWithResponder(
    ScriptToolHost* 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::ScriptToolHost>(message->header()->name)) {
    case messages::ScriptToolHost::kPauseExecution: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kScriptToolHostValidationInfo[] = {
    { &internal::ScriptToolHost_PauseExecution_Params_Data::Validate,
     nullptr /* no response */},
};

bool ScriptToolHostRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::ScriptToolHost::Name_,
    kScriptToolHostValidationInfo);
}

// The declaration includes the definition on other builds.

ModelContextHost::IPCStableHashFunction ModelContextHost::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::ModelContextHost>(message.name())) {
    case messages::ModelContextHost::kBindModelContext: {
      return &ModelContextHost::BindModelContext_Sym::IPCStableHash;
    }
    case messages::ModelContextHost::kRegisterScriptTool: {
      return &ModelContextHost::RegisterScriptTool_Sym::IPCStableHash;
    }
    case messages::ModelContextHost::kUnregisterScriptTool: {
      return &ModelContextHost::UnregisterScriptTool_Sym::IPCStableHash;
    }
    case messages::ModelContextHost::kGetScriptTools: {
      return &ModelContextHost::GetScriptTools_Sym::IPCStableHash;
    }
    case messages::ModelContextHost::kExecuteRemoteScriptTool: {
      return &ModelContextHost::ExecuteRemoteScriptTool_Sym::IPCStableHash;
    }
    case messages::ModelContextHost::kCancelRemoteScriptTool: {
      return &ModelContextHost::CancelRemoteScriptTool_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* ModelContextHost::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::ModelContextHost>(message.name())) {
      case messages::ModelContextHost::kBindModelContext:
            return "Receive blink::mojom::ModelContextHost::BindModelContext";
      case messages::ModelContextHost::kRegisterScriptTool:
            return "Receive blink::mojom::ModelContextHost::RegisterScriptTool";
      case messages::ModelContextHost::kUnregisterScriptTool:
            return "Receive blink::mojom::ModelContextHost::UnregisterScriptTool";
      case messages::ModelContextHost::kGetScriptTools:
            return "Receive blink::mojom::ModelContextHost::GetScriptTools";
      case messages::ModelContextHost::kExecuteRemoteScriptTool:
            return "Receive blink::mojom::ModelContextHost::ExecuteRemoteScriptTool";
      case messages::ModelContextHost::kCancelRemoteScriptTool:
            return "Receive blink::mojom::ModelContextHost::CancelRemoteScriptTool";
    }
  } else {
    switch (static_cast<messages::ModelContextHost>(message.name())) {
      case messages::ModelContextHost::kBindModelContext:
            return "Receive reply blink::mojom::ModelContextHost::BindModelContext";
      case messages::ModelContextHost::kRegisterScriptTool:
            return "Receive reply blink::mojom::ModelContextHost::RegisterScriptTool";
      case messages::ModelContextHost::kUnregisterScriptTool:
            return "Receive reply blink::mojom::ModelContextHost::UnregisterScriptTool";
      case messages::ModelContextHost::kGetScriptTools:
            return "Receive reply blink::mojom::ModelContextHost::GetScriptTools";
      case messages::ModelContextHost::kExecuteRemoteScriptTool:
            return "Receive reply blink::mojom::ModelContextHost::ExecuteRemoteScriptTool";
      case messages::ModelContextHost::kCancelRemoteScriptTool:
            return "Receive reply blink::mojom::ModelContextHost::CancelRemoteScriptTool";
    }
  }
  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 ModelContextHost::BindModelContext_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 = 0x8d306642;  // IPCStableHash for blink::mojom::ModelContextHost::BindModelContext
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContextHost::RegisterScriptTool_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 = 0x4b09d8b7;  // IPCStableHash for blink::mojom::ModelContextHost::RegisterScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContextHost::UnregisterScriptTool_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 = 0x4b10a709;  // IPCStableHash for blink::mojom::ModelContextHost::UnregisterScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContextHost::GetScriptTools_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 = 0x7e61878d;  // IPCStableHash for blink::mojom::ModelContextHost::GetScriptTools
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContextHost::ExecuteRemoteScriptTool_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 = 0x5f30330c;  // IPCStableHash for blink::mojom::ModelContextHost::ExecuteRemoteScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContextHost::CancelRemoteScriptTool_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 = 0xd07765e5;  // IPCStableHash for blink::mojom::ModelContextHost::CancelRemoteScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

class ModelContextHost_RegisterScriptTool_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  ModelContextHost_RegisterScriptTool_ForwardToCallback(
      ModelContextHost::RegisterScriptToolCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  ModelContextHost::RegisterScriptToolCallback callback_;
};

class ModelContextHost_GetScriptTools_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  ModelContextHost_GetScriptTools_ForwardToCallback(
      ModelContextHost::GetScriptToolsCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  ModelContextHost::GetScriptToolsCallback callback_;
};

class ModelContextHost_ExecuteRemoteScriptTool_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  ModelContextHost_ExecuteRemoteScriptTool_ForwardToCallback(
      ModelContextHost::ExecuteRemoteScriptToolCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  ModelContextHost::ExecuteRemoteScriptToolCallback callback_;
};

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

void ModelContextHostProxy::BindModelContext(
    ::mojo::PendingRemote<ModelContext> in_model_context) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::BindModelContext", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("model_context"), in_model_context,
                        "<value of type ::mojo::PendingRemote<ModelContext>>");
   });
#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::ModelContextHost::kBindModelContext), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_BindModelContext_Params_Data> params(
          message);
  params.Allocate();

  
  mojo::internal::Serialize<mojo::InterfacePtrDataView<::blink::mojom::ModelContextInterfaceBase>>(
    in_model_context,
    &params->model_context,
    &params.message());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(!mojo::internal::IsHandleOrInterfaceValid(params->model_context)),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
    "invalid model_context in ModelContextHost.BindModelContext request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("BindModelContext");
#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 ModelContextHostProxy::RegisterScriptTool(
    ScriptToolPtr in_tool, RegisterScriptToolCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::RegisterScriptTool", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("tool"), in_tool,
                        "<value of type ScriptToolPtr>");
   });
#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::ModelContextHost::kRegisterScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_RegisterScriptTool_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->tool)::BaseType> tool_fragment(
          params.message());
  
  mojo::internal::Serialize<::blink::mojom::ScriptToolDataView>(
    in_tool,
    tool_fragment);

  params->tool.Set(
      tool_fragment.is_null() ? nullptr : tool_fragment.data());

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

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

void ModelContextHostProxy::UnregisterScriptTool(
    const std::string& in_name) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::UnregisterScriptTool", "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::ModelContextHost::kUnregisterScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_UnregisterScriptTool_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 ModelContextHost.UnregisterScriptTool request");

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("UnregisterScriptTool");
#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 ModelContextHostProxy::GetScriptTools(
    const std::vector<::url::Origin>& in_from_origins, GetScriptToolsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::GetScriptTools", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("from_origins"), in_from_origins,
                        "<value of type const std::vector<::url::Origin>&>");
   });
#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::ModelContextHost::kGetScriptTools), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_GetScriptTools_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->from_origins)::BaseType>
      from_origins_fragment(params.message());
  constexpr const mojo::internal::ContainerValidateParams& from_origins_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  
  mojo::internal::Serialize<mojo::ArrayDataView<::url::mojom::OriginDataView>>(
    in_from_origins,
    from_origins_fragment,
    &from_origins_validate_params);

  params->from_origins.Set(
      from_origins_fragment.is_null() ? nullptr : from_origins_fragment.data());

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

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

void ModelContextHostProxy::ExecuteRemoteScriptTool(
    const ::base::UnguessableToken& in_invocation_id, const ::blink::FrameToken& in_tool_owner_frame_token, const ::url::Origin& in_expected_target_origin, const std::string& in_name, const std::string& in_input_arguments, ExecuteRemoteScriptToolCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::ExecuteRemoteScriptTool", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("invocation_id"), in_invocation_id,
                        "<value of type const ::base::UnguessableToken&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("tool_owner_frame_token"), in_tool_owner_frame_token,
                        "<value of type const ::blink::FrameToken&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("expected_target_origin"), in_expected_target_origin,
                        "<value of type const ::url::Origin&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("input_arguments"), in_input_arguments,
                        "<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::ModelContextHost::kExecuteRemoteScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_ExecuteRemoteScriptTool_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->invocation_id)::BaseType> invocation_id_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::UnguessableTokenDataView>(
    in_invocation_id,
    invocation_id_fragment);

  params->invocation_id.Set(
      invocation_id_fragment.is_null() ? nullptr : invocation_id_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->invocation_id.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null invocation_id in ModelContextHost.ExecuteRemoteScriptTool request");
  mojo::internal::MessageFragment<decltype(params->tool_owner_frame_token)>
      tool_owner_frame_token_fragment(params.message());
  tool_owner_frame_token_fragment.Claim(&params->tool_owner_frame_token);
  
  mojo::internal::Serialize<::blink::mojom::FrameTokenDataView>(
    in_tool_owner_frame_token,
    tool_owner_frame_token_fragment,
    true);

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->tool_owner_frame_token.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null tool_owner_frame_token in ModelContextHost.ExecuteRemoteScriptTool request");
  mojo::internal::MessageFragment<
      typename decltype(params->expected_target_origin)::BaseType> expected_target_origin_fragment(
          params.message());
  
  mojo::internal::Serialize<::url::mojom::OriginDataView>(
    in_expected_target_origin,
    expected_target_origin_fragment);

  params->expected_target_origin.Set(
      expected_target_origin_fragment.is_null() ? nullptr : expected_target_origin_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->expected_target_origin.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null expected_target_origin in ModelContextHost.ExecuteRemoteScriptTool request");
  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 ModelContextHost.ExecuteRemoteScriptTool request");
  mojo::internal::MessageFragment<
      typename decltype(params->input_arguments)::BaseType> input_arguments_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_input_arguments,
    input_arguments_fragment);

  params->input_arguments.Set(
      input_arguments_fragment.is_null() ? nullptr : input_arguments_fragment.data());

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

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

void ModelContextHostProxy::CancelRemoteScriptTool(
    const ::base::UnguessableToken& in_invocation_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContextHost::CancelRemoteScriptTool", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("invocation_id"), in_invocation_id,
                        "<value of type const ::base::UnguessableToken&>");
   });
#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::ModelContextHost::kCancelRemoteScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_CancelRemoteScriptTool_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->invocation_id)::BaseType> invocation_id_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::UnguessableTokenDataView>(
    in_invocation_id,
    invocation_id_fragment);

  params->invocation_id.Set(
      invocation_id_fragment.is_null() ? nullptr : invocation_id_fragment.data());

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

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("CancelRemoteScriptTool");
#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 ModelContextHost_RegisterScriptTool_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static ModelContextHost::RegisterScriptToolCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<ModelContextHost_RegisterScriptTool_ProxyToResponder> proxy(
        new ModelContextHost_RegisterScriptTool_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&ModelContextHost_RegisterScriptTool_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~ModelContextHost_RegisterScriptTool_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:
  ModelContextHost_RegisterScriptTool_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)
        << "ModelContextHost::RegisterScriptToolCallback 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 ModelContextHost_RegisterScriptTool_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::ModelContextHost_RegisterScriptTool_ResponseParams_Data* params =
      reinterpret_cast<
          internal::ModelContextHost_RegisterScriptTool_ResponseParams_Data*>(
              message->mutable_payload());
  

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

void ModelContextHost_RegisterScriptTool_ProxyToResponder::Run(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send reply blink::mojom::ModelContextHost::RegisterScriptTool");
#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::ModelContextHost::kRegisterScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_RegisterScriptTool_ResponseParams_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("RegisterScriptTool");
#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;
}
class ModelContextHost_GetScriptTools_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static ModelContextHost::GetScriptToolsCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<ModelContextHost_GetScriptTools_ProxyToResponder> proxy(
        new ModelContextHost_GetScriptTools_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&ModelContextHost_GetScriptTools_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~ModelContextHost_GetScriptTools_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:
  ModelContextHost_GetScriptTools_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)
        << "ModelContextHost::GetScriptToolsCallback 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(
      std::vector<ScriptToolPtr> in_tools);
};

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

  // Validation for ModelContextHost.3
  bool success = true;
  std::vector<ScriptToolPtr> p_tools{};
  ModelContextHost_GetScriptTools_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadTools(&p_tools))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        ModelContextHost::Name_, 3, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_tools));
  }
  return true;
}

void ModelContextHost_GetScriptTools_ProxyToResponder::Run(
    std::vector<ScriptToolPtr> in_tools) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::ModelContextHost::GetScriptTools", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("tools"), in_tools,
                        "<value of type std::vector<ScriptToolPtr>>");
   });
#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::ModelContextHost::kGetScriptTools), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_GetScriptTools_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->tools)::BaseType>
      tools_fragment(params.message());
  constexpr const mojo::internal::ContainerValidateParams& tools_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  
  mojo::internal::Serialize<mojo::ArrayDataView<::blink::mojom::ScriptToolDataView>>(
    in_tools,
    tools_fragment,
    &tools_validate_params);

  params->tools.Set(
      tools_fragment.is_null() ? nullptr : tools_fragment.data());

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

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("GetScriptTools");
#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;
}
class ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static ModelContextHost::ExecuteRemoteScriptToolCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder> proxy(
        new ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~ModelContextHost_ExecuteRemoteScriptTool_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:
  ModelContextHost_ExecuteRemoteScriptTool_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)
        << "ModelContextHost::ExecuteRemoteScriptToolCallback 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::optional<std::string>& in_result, bool in_success);
};

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

  // Validation for ModelContextHost.4
  bool success = true;
  std::optional<std::string> p_result{};
  bool p_success{};
  ModelContextHost_ExecuteRemoteScriptTool_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadResult(&p_result))
    success = false;
  if (success)
    p_success = input_data_view.success();
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        ModelContextHost::Name_, 4, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_result), 
std::move(p_success));
  }
  return true;
}

void ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder::Run(
    const std::optional<std::string>& in_result, bool in_success) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::ModelContextHost::ExecuteRemoteScriptTool", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("result"), in_result,
                        "<value of type const std::optional<std::string>&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("success"), in_success,
                        "<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::ModelContextHost::kExecuteRemoteScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContextHost_ExecuteRemoteScriptTool_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->result)::BaseType> result_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_result,
    result_fragment);

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

  params->success = in_success;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContextHost::Name_);
  message.set_method_name("ExecuteRemoteScriptTool");
#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;
}

// static
bool ModelContextHostStubDispatch::Accept(
    ModelContextHost* impl,
    mojo::Message* message) {
  switch (static_cast<messages::ModelContextHost>(message->header()->name)) {
    case messages::ModelContextHost::kBindModelContext: {
      DCHECK(message->is_serialized());
      internal::ModelContextHost_BindModelContext_Params_Data* params =
          reinterpret_cast<internal::ModelContextHost_BindModelContext_Params_Data*>(
              message->mutable_payload());
      

      // Validation for ModelContextHost.0
      bool success = true;
      ::mojo::PendingRemote<ModelContext> p_model_context{};
      ModelContextHost_BindModelContext_ParamsDataView input_data_view(params, message);
      
      if (success) {
        p_model_context =
            input_data_view.TakeModelContext<decltype(p_model_context)>();
      }
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContextHost::Name_, 0, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->BindModelContext(        
        std::move(p_model_context));
      return true;
    }
    case messages::ModelContextHost::kRegisterScriptTool: {
      break;
    }
    case messages::ModelContextHost::kUnregisterScriptTool: {
      DCHECK(message->is_serialized());
      internal::ModelContextHost_UnregisterScriptTool_Params_Data* params =
          reinterpret_cast<internal::ModelContextHost_UnregisterScriptTool_Params_Data*>(
              message->mutable_payload());
      

      // Validation for ModelContextHost.2
      bool success = true;
      std::string p_name{};
      ModelContextHost_UnregisterScriptTool_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,
            ModelContextHost::Name_, 2, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->UnregisterScriptTool(        
        std::move(p_name));
      return true;
    }
    case messages::ModelContextHost::kGetScriptTools: {
      break;
    }
    case messages::ModelContextHost::kExecuteRemoteScriptTool: {
      break;
    }
    case messages::ModelContextHost::kCancelRemoteScriptTool: {
      DCHECK(message->is_serialized());
      internal::ModelContextHost_CancelRemoteScriptTool_Params_Data* params =
          reinterpret_cast<internal::ModelContextHost_CancelRemoteScriptTool_Params_Data*>(
              message->mutable_payload());
      

      // Validation for ModelContextHost.5
      bool success = true;
      ::base::UnguessableToken p_invocation_id{};
      ModelContextHost_CancelRemoteScriptTool_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadInvocationId(&p_invocation_id))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContextHost::Name_, 5, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->CancelRemoteScriptTool(        
        std::move(p_invocation_id));
      return true;
    }
  }
  return false;
}

// static
bool ModelContextHostStubDispatch::AcceptWithResponder(
    ModelContextHost* 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::ModelContextHost>(message->header()->name)) {
    case messages::ModelContextHost::kBindModelContext: {
      break;
    }
    case messages::ModelContextHost::kRegisterScriptTool: {
      internal::ModelContextHost_RegisterScriptTool_Params_Data* params =
          reinterpret_cast<
              internal::ModelContextHost_RegisterScriptTool_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for ModelContextHost.1
      bool success = true;
      ScriptToolPtr p_tool{};
      ModelContextHost_RegisterScriptTool_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadTool(&p_tool))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContextHost::Name_, 1, false);
        return false;
      }
      auto callback =
          ModelContextHost_RegisterScriptTool_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->RegisterScriptTool(        
        std::move(p_tool), std::move(callback));
      return true;
    }
    case messages::ModelContextHost::kUnregisterScriptTool: {
      break;
    }
    case messages::ModelContextHost::kGetScriptTools: {
      internal::ModelContextHost_GetScriptTools_Params_Data* params =
          reinterpret_cast<
              internal::ModelContextHost_GetScriptTools_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for ModelContextHost.3
      bool success = true;
      std::vector<::url::Origin> p_from_origins{};
      ModelContextHost_GetScriptTools_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadFromOrigins(&p_from_origins))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContextHost::Name_, 3, false);
        return false;
      }
      auto callback =
          ModelContextHost_GetScriptTools_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->GetScriptTools(        
        std::move(p_from_origins), std::move(callback));
      return true;
    }
    case messages::ModelContextHost::kExecuteRemoteScriptTool: {
      internal::ModelContextHost_ExecuteRemoteScriptTool_Params_Data* params =
          reinterpret_cast<
              internal::ModelContextHost_ExecuteRemoteScriptTool_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for ModelContextHost.4
      bool success = true;
      ::base::UnguessableToken p_invocation_id{};
      ::blink::FrameToken p_tool_owner_frame_token{};
      ::url::Origin p_expected_target_origin{};
      std::string p_name{};
      std::string p_input_arguments{};
      ModelContextHost_ExecuteRemoteScriptTool_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadInvocationId(&p_invocation_id))
        success = false;
      if (success && !input_data_view.ReadToolOwnerFrameToken(&p_tool_owner_frame_token))
        success = false;
      if (success && !input_data_view.ReadExpectedTargetOrigin(&p_expected_target_origin))
        success = false;
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (success && !input_data_view.ReadInputArguments(&p_input_arguments))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContextHost::Name_, 4, false);
        return false;
      }
      auto callback =
          ModelContextHost_ExecuteRemoteScriptTool_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->ExecuteRemoteScriptTool(        
        std::move(p_invocation_id), 
        std::move(p_tool_owner_frame_token), 
        std::move(p_expected_target_origin), 
        std::move(p_name), 
        std::move(p_input_arguments), std::move(callback));
      return true;
    }
    case messages::ModelContextHost::kCancelRemoteScriptTool: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kModelContextHostValidationInfo[] = {
    { &internal::ModelContextHost_BindModelContext_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::ModelContextHost_RegisterScriptTool_Params_Data::Validate,
     &internal::ModelContextHost_RegisterScriptTool_ResponseParams_Data::Validate},
    { &internal::ModelContextHost_UnregisterScriptTool_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::ModelContextHost_GetScriptTools_Params_Data::Validate,
     &internal::ModelContextHost_GetScriptTools_ResponseParams_Data::Validate},
    { &internal::ModelContextHost_ExecuteRemoteScriptTool_Params_Data::Validate,
     &internal::ModelContextHost_ExecuteRemoteScriptTool_ResponseParams_Data::Validate},
    { &internal::ModelContextHost_CancelRemoteScriptTool_Params_Data::Validate,
     nullptr /* no response */},
};

bool ModelContextHostRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::ModelContextHost::Name_,
    kModelContextHostValidationInfo);
}

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

ModelContext::IPCStableHashFunction ModelContext::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::ModelContext>(message.name())) {
    case messages::ModelContext::kNotifyToolChange: {
      return &ModelContext::NotifyToolChange_Sym::IPCStableHash;
    }
    case messages::ModelContext::kExecuteScriptTool: {
      return &ModelContext::ExecuteScriptTool_Sym::IPCStableHash;
    }
    case messages::ModelContext::kCancelScriptTool: {
      return &ModelContext::CancelScriptTool_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* ModelContext::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::ModelContext>(message.name())) {
      case messages::ModelContext::kNotifyToolChange:
            return "Receive blink::mojom::ModelContext::NotifyToolChange";
      case messages::ModelContext::kExecuteScriptTool:
            return "Receive blink::mojom::ModelContext::ExecuteScriptTool";
      case messages::ModelContext::kCancelScriptTool:
            return "Receive blink::mojom::ModelContext::CancelScriptTool";
    }
  } else {
    switch (static_cast<messages::ModelContext>(message.name())) {
      case messages::ModelContext::kNotifyToolChange:
            return "Receive reply blink::mojom::ModelContext::NotifyToolChange";
      case messages::ModelContext::kExecuteScriptTool:
            return "Receive reply blink::mojom::ModelContext::ExecuteScriptTool";
      case messages::ModelContext::kCancelScriptTool:
            return "Receive reply blink::mojom::ModelContext::CancelScriptTool";
    }
  }
  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 ModelContext::NotifyToolChange_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 = 0xcb6eecfe;  // IPCStableHash for blink::mojom::ModelContext::NotifyToolChange
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContext::ExecuteScriptTool_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 = 0xe7afd415;  // IPCStableHash for blink::mojom::ModelContext::ExecuteScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t ModelContext::CancelScriptTool_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 = 0x3815c307;  // IPCStableHash for blink::mojom::ModelContext::CancelScriptTool
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

class ModelContext_ExecuteScriptTool_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  ModelContext_ExecuteScriptTool_ForwardToCallback(
      ModelContext::ExecuteScriptToolCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  ModelContext::ExecuteScriptToolCallback callback_;
};

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

void ModelContextProxy::NotifyToolChange(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send blink::mojom::ModelContext::NotifyToolChange");
#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::ModelContext::kNotifyToolChange), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContext_NotifyToolChange_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContext::Name_);
  message.set_method_name("NotifyToolChange");
#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 ModelContextProxy::ExecuteScriptTool(
    const ::base::UnguessableToken& in_invocation_id, const std::string& in_name, const std::string& in_input_arguments, ExecuteScriptToolCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContext::ExecuteScriptTool", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("invocation_id"), in_invocation_id,
                        "<value of type const ::base::UnguessableToken&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("name"), in_name,
                        "<value of type const std::string&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("input_arguments"), in_input_arguments,
                        "<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::ModelContext::kExecuteScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContext_ExecuteScriptTool_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->invocation_id)::BaseType> invocation_id_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::UnguessableTokenDataView>(
    in_invocation_id,
    invocation_id_fragment);

  params->invocation_id.Set(
      invocation_id_fragment.is_null() ? nullptr : invocation_id_fragment.data());

  
  MOJO_INTERNAL_CHECK_SERIALIZATION(
    mojo::internal::SendValidation::kDefault,
    !(params->invocation_id.is_null()),
    mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
    "null invocation_id in ModelContext.ExecuteScriptTool request");
  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 ModelContext.ExecuteScriptTool request");
  mojo::internal::MessageFragment<
      typename decltype(params->input_arguments)::BaseType> input_arguments_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_input_arguments,
    input_arguments_fragment);

  params->input_arguments.Set(
      input_arguments_fragment.is_null() ? nullptr : input_arguments_fragment.data());

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

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

void ModelContextProxy::CancelScriptTool(
    const ::base::UnguessableToken& in_invocation_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::ModelContext::CancelScriptTool", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("invocation_id"), in_invocation_id,
                        "<value of type const ::base::UnguessableToken&>");
   });
#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::ModelContext::kCancelScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContext_CancelScriptTool_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->invocation_id)::BaseType> invocation_id_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::UnguessableTokenDataView>(
    in_invocation_id,
    invocation_id_fragment);

  params->invocation_id.Set(
      invocation_id_fragment.is_null() ? nullptr : invocation_id_fragment.data());

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

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContext::Name_);
  message.set_method_name("CancelScriptTool");
#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 ModelContext_ExecuteScriptTool_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static ModelContext::ExecuteScriptToolCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<ModelContext_ExecuteScriptTool_ProxyToResponder> proxy(
        new ModelContext_ExecuteScriptTool_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&ModelContext_ExecuteScriptTool_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~ModelContext_ExecuteScriptTool_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:
  ModelContext_ExecuteScriptTool_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)
        << "ModelContext::ExecuteScriptToolCallback 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::optional<std::string>& in_result, bool in_success);
};

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

  // Validation for ModelContext.1
  bool success = true;
  std::optional<std::string> p_result{};
  bool p_success{};
  ModelContext_ExecuteScriptTool_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadResult(&p_result))
    success = false;
  if (success)
    p_success = input_data_view.success();
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        ModelContext::Name_, 1, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_result), 
std::move(p_success));
  }
  return true;
}

void ModelContext_ExecuteScriptTool_ProxyToResponder::Run(
    const std::optional<std::string>& in_result, bool in_success) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::ModelContext::ExecuteScriptTool", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("result"), in_result,
                        "<value of type const std::optional<std::string>&>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("success"), in_success,
                        "<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::ModelContext::kExecuteScriptTool), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::ModelContext_ExecuteScriptTool_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->result)::BaseType> result_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_result,
    result_fragment);

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

  params->success = in_success;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(ModelContext::Name_);
  message.set_method_name("ExecuteScriptTool");
#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;
}

// static
bool ModelContextStubDispatch::Accept(
    ModelContext* impl,
    mojo::Message* message) {
  switch (static_cast<messages::ModelContext>(message->header()->name)) {
    case messages::ModelContext::kNotifyToolChange: {
      DCHECK(message->is_serialized());
      internal::ModelContext_NotifyToolChange_Params_Data* params =
          reinterpret_cast<internal::ModelContext_NotifyToolChange_Params_Data*>(
              message->mutable_payload());
      

      // Validation for ModelContext.0
      bool success = true;
      ModelContext_NotifyToolChange_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContext::Name_, 0, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->NotifyToolChange(        );
      return true;
    }
    case messages::ModelContext::kExecuteScriptTool: {
      break;
    }
    case messages::ModelContext::kCancelScriptTool: {
      DCHECK(message->is_serialized());
      internal::ModelContext_CancelScriptTool_Params_Data* params =
          reinterpret_cast<internal::ModelContext_CancelScriptTool_Params_Data*>(
              message->mutable_payload());
      

      // Validation for ModelContext.2
      bool success = true;
      ::base::UnguessableToken p_invocation_id{};
      ModelContext_CancelScriptTool_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadInvocationId(&p_invocation_id))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContext::Name_, 2, false);
        return false;
      }
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->CancelScriptTool(        
        std::move(p_invocation_id));
      return true;
    }
  }
  return false;
}

// static
bool ModelContextStubDispatch::AcceptWithResponder(
    ModelContext* 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::ModelContext>(message->header()->name)) {
    case messages::ModelContext::kNotifyToolChange: {
      break;
    }
    case messages::ModelContext::kExecuteScriptTool: {
      internal::ModelContext_ExecuteScriptTool_Params_Data* params =
          reinterpret_cast<
              internal::ModelContext_ExecuteScriptTool_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for ModelContext.1
      bool success = true;
      ::base::UnguessableToken p_invocation_id{};
      std::string p_name{};
      std::string p_input_arguments{};
      ModelContext_ExecuteScriptTool_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadInvocationId(&p_invocation_id))
        success = false;
      if (success && !input_data_view.ReadName(&p_name))
        success = false;
      if (success && !input_data_view.ReadInputArguments(&p_input_arguments))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            ModelContext::Name_, 1, false);
        return false;
      }
      auto callback =
          ModelContext_ExecuteScriptTool_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->ExecuteScriptTool(        
        std::move(p_invocation_id), 
        std::move(p_name), 
        std::move(p_input_arguments), std::move(callback));
      return true;
    }
    case messages::ModelContext::kCancelScriptTool: {
      break;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kModelContextValidationInfo[] = {
    { &internal::ModelContext_NotifyToolChange_Params_Data::Validate,
     nullptr /* no response */},
    { &internal::ModelContext_ExecuteScriptTool_Params_Data::Validate,
     &internal::ModelContext_ExecuteScriptTool_ResponseParams_Data::Validate},
    { &internal::ModelContext_CancelScriptTool_Params_Data::Validate,
     nullptr /* no response */},
};

bool ModelContextRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::ModelContext::Name_,
    kModelContextValidationInfo);
}

bool ModelContextResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::blink::mojom::ModelContext::Name_,
    kModelContextValidationInfo);
}


}  // blink::mojom


namespace mojo {


// static
bool StructTraits<::blink::mojom::ScriptToolAnnotations::DataView, ::blink::mojom::ScriptToolAnnotationsPtr>::Read(
    ::blink::mojom::ScriptToolAnnotations::DataView input,
    ::blink::mojom::ScriptToolAnnotationsPtr* output) {
  bool success = true;
  ::blink::mojom::ScriptToolAnnotationsPtr result(::blink::mojom::ScriptToolAnnotations::New());
  
      if (success)
        result->read_only = input.read_only();
      if (success)
        result->untrusted_content = input.untrusted_content();
      if (success)
        result->consequential = input.consequential();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::ScriptTool::DataView, ::blink::mojom::ScriptToolPtr>::Read(
    ::blink::mojom::ScriptTool::DataView input,
    ::blink::mojom::ScriptToolPtr* output) {
  bool success = true;
  ::blink::mojom::ScriptToolPtr result(::blink::mojom::ScriptTool::New());
  
      if (success && !input.ReadName(&result->name))
        success = false;
      if (success && !input.ReadTitle(&result->title))
        success = false;
      if (success && !input.ReadDescription(&result->description))
        success = false;
      if (success && !input.ReadInputSchema(&result->input_schema))
        success = false;
      if (success && !input.ReadAnnotations(&result->annotations))
        success = false;
      if (success && !input.ReadExposedOrigins(&result->exposed_origins))
        success = false;
      if (success && !input.ReadToolOwnerFrameToken(&result->tool_owner_frame_token))
        success = false;
      if (success && !input.ReadOrigin(&result->origin))
        success = false;
  *output = std::move(result);
  return success;
}

}  // 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 ScriptToolHostInterceptorForTesting::PauseExecution() {
  GetForwardingInterface()->PauseExecution();
}
ScriptToolHostAsyncWaiter::ScriptToolHostAsyncWaiter(
    ScriptToolHost* proxy) : proxy_(proxy) {}

ScriptToolHostAsyncWaiter::~ScriptToolHostAsyncWaiter() = default;





void ModelContextHostInterceptorForTesting::BindModelContext(::mojo::PendingRemote<ModelContext> model_context) {
  GetForwardingInterface()->BindModelContext(
    std::move(model_context)
    );
}
void ModelContextHostInterceptorForTesting::RegisterScriptTool(ScriptToolPtr tool, RegisterScriptToolCallback callback) {
  GetForwardingInterface()->RegisterScriptTool(
    std::move(tool)
    , std::move(callback));
}
void ModelContextHostInterceptorForTesting::UnregisterScriptTool(const std::string& name) {
  GetForwardingInterface()->UnregisterScriptTool(
    std::move(name)
    );
}
void ModelContextHostInterceptorForTesting::GetScriptTools(const std::vector<::url::Origin>& from_origins, GetScriptToolsCallback callback) {
  GetForwardingInterface()->GetScriptTools(
    std::move(from_origins)
    , std::move(callback));
}
void ModelContextHostInterceptorForTesting::ExecuteRemoteScriptTool(const ::base::UnguessableToken& invocation_id, const ::blink::FrameToken& tool_owner_frame_token, const ::url::Origin& expected_target_origin, const std::string& name, const std::string& input_arguments, ExecuteRemoteScriptToolCallback callback) {
  GetForwardingInterface()->ExecuteRemoteScriptTool(
    std::move(invocation_id)
    , 
    std::move(tool_owner_frame_token)
    , 
    std::move(expected_target_origin)
    , 
    std::move(name)
    , 
    std::move(input_arguments)
    , std::move(callback));
}
void ModelContextHostInterceptorForTesting::CancelRemoteScriptTool(const ::base::UnguessableToken& invocation_id) {
  GetForwardingInterface()->CancelRemoteScriptTool(
    std::move(invocation_id)
    );
}
ModelContextHostAsyncWaiter::ModelContextHostAsyncWaiter(
    ModelContextHost* proxy) : proxy_(proxy) {}

ModelContextHostAsyncWaiter::~ModelContextHostAsyncWaiter() = default;


void ModelContextHostAsyncWaiter::RegisterScriptTool(
    ScriptToolPtr tool) {
  base::RunLoop loop;
  proxy_->RegisterScriptTool(
      std::move(tool),
      base::BindOnce(
          [](base::RunLoop* loop) {
            loop->Quit();
          },
          &loop));
  loop.Run();
}



void ModelContextHostAsyncWaiter::GetScriptTools(
    const std::vector<::url::Origin>& from_origins, std::vector<ScriptToolPtr>* out_tools) {
  base::RunLoop loop;
  proxy_->GetScriptTools(
      std::move(from_origins),
      base::BindOnce(
          [](base::RunLoop* loop,
             std::vector<ScriptToolPtr>* out_tools
,
             std::vector<ScriptToolPtr> tools) {*out_tools = std::move(tools);
            loop->Quit();
          },
          &loop,
          out_tools));
  loop.Run();
}

std::vector<ScriptToolPtr> ModelContextHostAsyncWaiter::GetScriptTools(
    const std::vector<::url::Origin>& from_origins) {
  std::vector<ScriptToolPtr> async_wait_result;
  GetScriptTools(std::move(from_origins),&async_wait_result);
  return async_wait_result;
}

void ModelContextHostAsyncWaiter::ExecuteRemoteScriptTool(
    const ::base::UnguessableToken& invocation_id, const ::blink::FrameToken& tool_owner_frame_token, const ::url::Origin& expected_target_origin, const std::string& name, const std::string& input_arguments, std::optional<std::string>* out_result, bool* out_success) {
  base::RunLoop loop;
  proxy_->ExecuteRemoteScriptTool(
      std::move(invocation_id),
      std::move(tool_owner_frame_token),
      std::move(expected_target_origin),
      std::move(name),
      std::move(input_arguments),
      base::BindOnce(
          [](base::RunLoop* loop,
             std::optional<std::string>* out_result
,
             bool* out_success
,
             const std::optional<std::string>& result,
             bool success) {*out_result = std::move(result);*out_success = std::move(success);
            loop->Quit();
          },
          &loop,
          out_result,
          out_success));
  loop.Run();
}






void ModelContextInterceptorForTesting::NotifyToolChange() {
  GetForwardingInterface()->NotifyToolChange();
}
void ModelContextInterceptorForTesting::ExecuteScriptTool(const ::base::UnguessableToken& invocation_id, const std::string& name, const std::string& input_arguments, ExecuteScriptToolCallback callback) {
  GetForwardingInterface()->ExecuteScriptTool(
    std::move(invocation_id)
    , 
    std::move(name)
    , 
    std::move(input_arguments)
    , std::move(callback));
}
void ModelContextInterceptorForTesting::CancelScriptTool(const ::base::UnguessableToken& invocation_id) {
  GetForwardingInterface()->CancelScriptTool(
    std::move(invocation_id)
    );
}
ModelContextAsyncWaiter::ModelContextAsyncWaiter(
    ModelContext* proxy) : proxy_(proxy) {}

ModelContextAsyncWaiter::~ModelContextAsyncWaiter() = default;


void ModelContextAsyncWaiter::ExecuteScriptTool(
    const ::base::UnguessableToken& invocation_id, const std::string& name, const std::string& input_arguments, std::optional<std::string>* out_result, bool* out_success) {
  base::RunLoop loop;
  proxy_->ExecuteScriptTool(
      std::move(invocation_id),
      std::move(name),
      std::move(input_arguments),
      base::BindOnce(
          [](base::RunLoop* loop,
             std::optional<std::string>* out_result
,
             bool* out_success
,
             const std::optional<std::string>& result,
             bool success) {*out_result = std::move(result);*out_success = std::move(success);
            loop->Quit();
          },
          &loop,
          out_result,
          out_success));
  loop.Run();
}








}  // blink::mojom


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