// services/webnn/public/mojom/webnn_context_provider.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 "services/webnn/public/mojom/webnn_context_provider.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 "services/webnn/public/mojom/webnn_context_provider.mojom-params-data.h"
#include "services/webnn/public/mojom/webnn_context_provider.mojom-shared-message-ids.h"

#include "services/webnn/public/mojom/webnn_context_provider.mojom-import-headers.h"
#include "services/webnn/public/mojom/webnn_context_provider.mojom-test-utils.h"


namespace webnn::mojom {
CreateContextOptions::CreateContextOptions()
    : device(),
      power_preference() {}

CreateContextOptions::CreateContextOptions(
    ::webnn::mojom::Device device_in,
    CreateContextOptions::PowerPreference power_preference_in)
    : device(std::move(device_in)),
      power_preference(std::move(power_preference_in)) {}

CreateContextOptions::~CreateContextOptions() = default;
size_t CreateContextOptions::Hash(size_t seed) const {
  seed = mojo::internal::Hash(seed, this->device);
  seed = mojo::internal::Hash(seed, this->power_preference);
  return seed;
}

void CreateContextOptions::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "device"), this->device,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::webnn::mojom::Device>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "power_preference"), this->power_preference,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CreateContextOptions::PowerPreference>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool CreateContextOptions::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
CreateContextSuccess::CreateContextSuccess()
    : context_remote(),
      compiler_context_remote(),
      context_properties(mojo::internal::DefaultConstructTag()),
      context_handle(),
      write_tensor_producer(),
      read_tensor_consumer(),
      command_buffer_id() {}

CreateContextSuccess::CreateContextSuccess(
    ::mojo::PendingRemote<::webnn::mojom::WebNNContext> context_remote_in,
    ::mojo::PendingRemote<::webnn::mojom::WebNNCompilerContext> compiler_context_remote_in,
    const ::webnn::ContextProperties& context_properties_in,
    const ::blink::WebNNContextToken& context_handle_in,
    ::mojo::ScopedDataPipeProducerHandle write_tensor_producer_in,
    ::mojo::ScopedDataPipeConsumerHandle read_tensor_consumer_in,
    uint64_t command_buffer_id_in)
    : context_remote(std::move(context_remote_in)),
      compiler_context_remote(std::move(compiler_context_remote_in)),
      context_properties(std::move(context_properties_in)),
      context_handle(std::move(context_handle_in)),
      write_tensor_producer(std::move(write_tensor_producer_in)),
      read_tensor_consumer(std::move(read_tensor_consumer_in)),
      command_buffer_id(std::move(command_buffer_id_in)) {}

CreateContextSuccess::~CreateContextSuccess() = default;

void CreateContextSuccess::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "context_remote"), this->context_remote,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo::PendingRemote<::webnn::mojom::WebNNContext>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "compiler_context_remote"), this->compiler_context_remote,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo::PendingRemote<::webnn::mojom::WebNNCompilerContext>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "context_properties"), this->context_properties,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::webnn::ContextProperties&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "context_handle"), this->context_handle,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::WebNNContextToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "write_tensor_producer"), this->write_tensor_producer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo::ScopedDataPipeProducerHandle>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "read_tensor_consumer"), this->read_tensor_consumer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo::ScopedDataPipeConsumerHandle>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "command_buffer_id"), this->command_buffer_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool CreateContextSuccess::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
CreateContextResultPtr
CreateContextResult::NewSuccess(
    CreateContextSuccessPtr value) {
  return CreateContextResultPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kSuccess)>,
      std::move(value));
}

CreateContextResultPtr
CreateContextResult::NewError(
    ::webnn::mojom::ErrorPtr value) {
  return CreateContextResultPtr(
      std::in_place,
      std::in_place_index<static_cast<size_t>(Tag::kError)>,
      std::move(value));
}

CreateContextResult::CreateContextResult(
    std::in_place_index_t<static_cast<size_t>(Tag::kSuccess)>,
    CreateContextSuccessPtr value)
    : tag_(Tag::kSuccess),
      data_(std::in_place_index<static_cast<size_t>(Tag::kSuccess)>,
            std::move(value)) {}

CreateContextResult::CreateContextResult(
    std::in_place_index_t<static_cast<size_t>(Tag::kError)>,
    ::webnn::mojom::ErrorPtr value)
    : tag_(Tag::kError),
      data_(std::in_place_index<static_cast<size_t>(Tag::kError)>,
            std::move(value)) {}
CreateContextResult::~CreateContextResult() {
  DestroyActive();
}

void CreateContextResult::set_success(CreateContextSuccessPtr success) {
  if (tag_ == Tag::kSuccess) {
    data_.success = std::move(success);
  } else {
    DestroyActive();
    tag_ = Tag::kSuccess;
    new (&data_.success) CreateContextSuccessPtr(
        std::move(success));
  }
}

void CreateContextResult::set_error(::webnn::mojom::ErrorPtr error) {
  if (tag_ == Tag::kError) {
    data_.error = std::move(error);
  } else {
    DestroyActive();
    tag_ = Tag::kError;
    new (&data_.error) ::webnn::mojom::ErrorPtr(
        std::move(error));
  }
}


CreateContextResult::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kSuccess)>,
    CreateContextSuccessPtr value)
    : success(std::move(value)) {}

CreateContextResult::Union_::Union_(
    std::in_place_index_t<static_cast<size_t>(Tag::kError)>,
    ::webnn::mojom::ErrorPtr value)
    : error(std::move(value)) {}

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

    case Tag::kSuccess:
      std::destroy_at(&data_.success);
      break;
    case Tag::kError:
      std::destroy_at(&data_.error);
      break;
  }
}

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

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


const char* WebNNContextProvider::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::WebNNContextProvider>(message.name())) {
      case messages::WebNNContextProvider::kCreateWebNNContext:
            return "Receive webnn::mojom::WebNNContextProvider::CreateWebNNContext";
    }
  } else {
    switch (static_cast<messages::WebNNContextProvider>(message.name())) {
      case messages::WebNNContextProvider::kCreateWebNNContext:
            return "Receive reply webnn::mojom::WebNNContextProvider::CreateWebNNContext";
    }
  }
  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 WebNNContextProvider::CreateWebNNContext_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 = 0x20fe6edd;  // IPCStableHash for webnn::mojom::WebNNContextProvider::CreateWebNNContext
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

// static
bool WebNNContextProvider::RuntimeFeature_IsEnabled_(bool expected) {
  bool enabled = base::FeatureList::IsEnabled(::webnn::mojom::features::kWebMachineLearningNeuralNetwork);
#if DCHECK_IS_ON()
  if (expected) {
    DCHECK(enabled) << "RuntimeFeature ::webnn::mojom::features::kWebMachineLearningNeuralNetwork for WebNNContextProvider is not enabled";
  }
#endif
  return enabled;
}

class WebNNContextProvider_CreateWebNNContext_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  WebNNContextProvider_CreateWebNNContext_ForwardToCallback(
      WebNNContextProvider::CreateWebNNContextCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  WebNNContextProvider::CreateWebNNContextCallback callback_;
};

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

void WebNNContextProviderProxy::CreateWebNNContext(
    CreateContextOptionsPtr in_options, CreateWebNNContextCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send webnn::mojom::WebNNContextProvider::CreateWebNNContext", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("options"), in_options,
                        "<value of type CreateContextOptionsPtr>");
   });
#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::WebNNContextProvider::kCreateWebNNContext), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WebNNContextProvider_CreateWebNNContext_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->options)::BaseType> options_fragment(
          params.message());
  
  mojo::internal::Serialize<::webnn::mojom::CreateContextOptionsDataView>(
    in_options,
    options_fragment);

  params->options.Set(
      options_fragment.is_null() ? nullptr : options_fragment.data());

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

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WebNNContextProvider::Name_);
  message.set_method_name("CreateWebNNContext");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new WebNNContextProvider_CreateWebNNContext_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
class WebNNContextProvider_CreateWebNNContext_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static WebNNContextProvider::CreateWebNNContextCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<WebNNContextProvider_CreateWebNNContext_ProxyToResponder> proxy(
        new WebNNContextProvider_CreateWebNNContext_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&WebNNContextProvider_CreateWebNNContext_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~WebNNContextProvider_CreateWebNNContext_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:
  WebNNContextProvider_CreateWebNNContext_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)
        << "WebNNContextProvider::CreateWebNNContextCallback 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(
      CreateContextResultPtr in_result);
};

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

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

void WebNNContextProvider_CreateWebNNContext_ProxyToResponder::Run(
    CreateContextResultPtr in_result) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply webnn::mojom::WebNNContextProvider::CreateWebNNContext", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("result"), in_result,
                        "<value of type CreateContextResultPtr>");
   });
#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::WebNNContextProvider::kCreateWebNNContext), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WebNNContextProvider_CreateWebNNContext_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<decltype(params->result)>
      result_fragment(params.message());
  result_fragment.Claim(&params->result);
  
  mojo::internal::Serialize<::webnn::mojom::CreateContextResultDataView>(
    in_result,
    result_fragment,
    true);

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

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WebNNContextProvider::Name_);
  message.set_method_name("CreateWebNNContext");
#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 WebNNContextProviderStubDispatch::Accept(
    WebNNContextProvider* impl,
    mojo::Message* message) {
  switch (static_cast<messages::WebNNContextProvider>(message->header()->name)) {
    case messages::WebNNContextProvider::kCreateWebNNContext: {
      break;
    }
  }
  return false;
}

// static
bool WebNNContextProviderStubDispatch::AcceptWithResponder(
    WebNNContextProvider* 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::WebNNContextProvider>(message->header()->name)) {
    case messages::WebNNContextProvider::kCreateWebNNContext: {
      internal::WebNNContextProvider_CreateWebNNContext_Params_Data* params =
          reinterpret_cast<
              internal::WebNNContextProvider_CreateWebNNContext_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for WebNNContextProvider.0
      bool success = true;
      CreateContextOptionsPtr p_options{};
      WebNNContextProvider_CreateWebNNContext_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadOptions(&p_options))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            WebNNContextProvider::Name_, 0, false);
        return false;
      }
      auto callback =
          WebNNContextProvider_CreateWebNNContext_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->CreateWebNNContext(        
        std::move(p_options), std::move(callback));
      return true;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kWebNNContextProviderValidationInfo[] = {
    { &internal::WebNNContextProvider_CreateWebNNContext_Params_Data::Validate,
     &internal::WebNNContextProvider_CreateWebNNContext_ResponseParams_Data::Validate},
};

bool WebNNContextProviderRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::webnn::mojom::WebNNContextProvider::Name_,
    kWebNNContextProviderValidationInfo);
}

bool WebNNContextProviderResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::webnn::mojom::WebNNContextProvider::Name_,
    kWebNNContextProviderValidationInfo);
}
// The declaration includes the definition on other builds.

WeightsFileSession::IPCStableHashFunction WeightsFileSession::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::WeightsFileSession>(message.name())) {
    case messages::WeightsFileSession::kRequestCapacityChange: {
      return &WeightsFileSession::RequestCapacityChange_Sym::IPCStableHash;
    }
    case messages::WeightsFileSession::kFinalize: {
      return &WeightsFileSession::Finalize_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* WeightsFileSession::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::WeightsFileSession>(message.name())) {
      case messages::WeightsFileSession::kRequestCapacityChange:
            return "Receive webnn::mojom::WeightsFileSession::RequestCapacityChange";
      case messages::WeightsFileSession::kFinalize:
            return "Receive webnn::mojom::WeightsFileSession::Finalize";
    }
  } else {
    switch (static_cast<messages::WeightsFileSession>(message.name())) {
      case messages::WeightsFileSession::kRequestCapacityChange:
            return "Receive reply webnn::mojom::WeightsFileSession::RequestCapacityChange";
      case messages::WeightsFileSession::kFinalize:
            return "Receive reply webnn::mojom::WeightsFileSession::Finalize";
    }
  }
  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 WeightsFileSession::RequestCapacityChange_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 = 0x099b2f13;  // IPCStableHash for webnn::mojom::WeightsFileSession::RequestCapacityChange
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t WeightsFileSession::Finalize_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 = 0xd21327cf;  // IPCStableHash for webnn::mojom::WeightsFileSession::Finalize
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

// static
bool WeightsFileSession::RuntimeFeature_IsEnabled_(bool expected) {
  bool enabled = base::FeatureList::IsEnabled(::webnn::mojom::features::kWebMachineLearningNeuralNetwork);
#if DCHECK_IS_ON()
  if (expected) {
    DCHECK(enabled) << "RuntimeFeature ::webnn::mojom::features::kWebMachineLearningNeuralNetwork for WeightsFileSession is not enabled";
  }
#endif
  return enabled;
}
bool WeightsFileSession::RequestCapacityChange(uint64_t new_size, bool* out_granted) {
  NOTREACHED();
}
class WeightsFileSession_RequestCapacityChange_HandleSyncResponse
    : public mojo::MessageReceiver {
 public:
  WeightsFileSession_RequestCapacityChange_HandleSyncResponse(
      bool* result, bool* out_granted)
      : result_(result), out_granted_(out_granted) {
    DCHECK(!*result_);
  }

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

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

class WeightsFileSession_RequestCapacityChange_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  WeightsFileSession_RequestCapacityChange_ForwardToCallback(
      WeightsFileSession::RequestCapacityChangeCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  WeightsFileSession::RequestCapacityChangeCallback callback_;
};

class WeightsFileSession_Finalize_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  WeightsFileSession_Finalize_ForwardToCallback(
      WeightsFileSession::FinalizeCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  WeightsFileSession::FinalizeCallback callback_;
};

WeightsFileSessionProxy::WeightsFileSessionProxy(mojo::MessageReceiverWithResponder* receiver)
    : receiver_(receiver) {
}
bool WeightsFileSessionProxy::RequestCapacityChange(
    uint64_t param_new_size, bool* out_param_granted) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT_BEGIN1(
    "mojom", "Call webnn::mojom::WeightsFileSession::RequestCapacityChange (sync)", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("new_size"), param_new_size,
                        "<value of type uint64_t>");
   });
#else
  TRACE_EVENT0("mojom", "WeightsFileSession::RequestCapacityChange");
#endif
  
  const bool kExpectsResponse = true;
  const bool kIsSync = true;
  const bool kAllowInterrupt =
      true;
  const bool is_urgent = false;

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

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::WeightsFileSession::kRequestCapacityChange), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WeightsFileSession_RequestCapacityChange_Params_Data> params(
          message);
  params.Allocate();

  params->new_size = param_new_size;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WeightsFileSession::Name_);
  message.set_method_name("RequestCapacityChange");
#endif

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

void WeightsFileSessionProxy::RequestCapacityChange(
    uint64_t in_new_size, RequestCapacityChangeCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send webnn::mojom::WeightsFileSession::RequestCapacityChange", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("new_size"), in_new_size,
                        "<value of type uint64_t>");
   });
#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::WeightsFileSession::kRequestCapacityChange), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WeightsFileSession_RequestCapacityChange_Params_Data> params(
          message);
  params.Allocate();

  params->new_size = in_new_size;

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

void WeightsFileSessionProxy::Finalize(
    FinalizeCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send webnn::mojom::WeightsFileSession::Finalize");
#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::WeightsFileSession::kFinalize), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WeightsFileSession_Finalize_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WeightsFileSession::Name_);
  message.set_method_name("Finalize");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new WeightsFileSession_Finalize_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
class WeightsFileSession_RequestCapacityChange_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static WeightsFileSession::RequestCapacityChangeCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<WeightsFileSession_RequestCapacityChange_ProxyToResponder> proxy(
        new WeightsFileSession_RequestCapacityChange_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&WeightsFileSession_RequestCapacityChange_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~WeightsFileSession_RequestCapacityChange_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:
  WeightsFileSession_RequestCapacityChange_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)
        << "WeightsFileSession::RequestCapacityChangeCallback was destroyed without "
        << "first either being run or its corresponding binding being closed. "
        << "It is an error to drop response callbacks which still correspond "
        << "to an open interface pipe.";
  }
#endif

  void Run(
      bool in_granted);
};

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

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

void WeightsFileSession_RequestCapacityChange_ProxyToResponder::Run(
    bool in_granted) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply webnn::mojom::WeightsFileSession::RequestCapacityChange", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("granted"), in_granted,
                        "<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::WeightsFileSession::kRequestCapacityChange), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WeightsFileSession_RequestCapacityChange_ResponseParams_Data> params(
          message);
  params.Allocate();

  params->granted = in_granted;

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WeightsFileSession::Name_);
  message.set_method_name("RequestCapacityChange");
#endif

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

  // Validation for WeightsFileSession.0
  bool success = true;
  bool p_granted{};
  WeightsFileSession_RequestCapacityChange_ResponseParamsDataView input_data_view(params, message);
  
  if (success)
    p_granted = input_data_view.granted();
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        WeightsFileSession::Name_, 0, true);
    return false;
  }
  *out_granted_ = std::move(p_granted);
  *result_ = true;
  return true;
}
class WeightsFileSession_Finalize_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static WeightsFileSession::FinalizeCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<WeightsFileSession_Finalize_ProxyToResponder> proxy(
        new WeightsFileSession_Finalize_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&WeightsFileSession_Finalize_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~WeightsFileSession_Finalize_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:
  WeightsFileSession_Finalize_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)
        << "WeightsFileSession::FinalizeCallback 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(
      ::base::File in_sealed_file);
};

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

  // Validation for WeightsFileSession.1
  bool success = true;
  ::base::File p_sealed_file{};
  WeightsFileSession_Finalize_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadSealedFile(&p_sealed_file))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        WeightsFileSession::Name_, 1, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_sealed_file));
  }
  return true;
}

void WeightsFileSession_Finalize_ProxyToResponder::Run(
    ::base::File in_sealed_file) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply webnn::mojom::WeightsFileSession::Finalize", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("sealed_file"), in_sealed_file,
                        "<value of type ::base::File>");
   });
#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::WeightsFileSession::kFinalize), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WeightsFileSession_Finalize_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->sealed_file)::BaseType> sealed_file_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::ReadOnlyFileDataView>(
    in_sealed_file,
    sealed_file_fragment);

  params->sealed_file.Set(
      sealed_file_fragment.is_null() ? nullptr : sealed_file_fragment.data());

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WeightsFileSession::Name_);
  message.set_method_name("Finalize");
#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 WeightsFileSessionStubDispatch::Accept(
    WeightsFileSession* impl,
    mojo::Message* message) {
  switch (static_cast<messages::WeightsFileSession>(message->header()->name)) {
    case messages::WeightsFileSession::kRequestCapacityChange: {
      break;
    }
    case messages::WeightsFileSession::kFinalize: {
      break;
    }
  }
  return false;
}

// static
bool WeightsFileSessionStubDispatch::AcceptWithResponder(
    WeightsFileSession* 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::WeightsFileSession>(message->header()->name)) {
    case messages::WeightsFileSession::kRequestCapacityChange: {
      internal::WeightsFileSession_RequestCapacityChange_Params_Data* params =
          reinterpret_cast<
              internal::WeightsFileSession_RequestCapacityChange_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for WeightsFileSession.0
      bool success = true;
      uint64_t p_new_size{};
      WeightsFileSession_RequestCapacityChange_ParamsDataView input_data_view(params, message);
      
      if (success)
        p_new_size = input_data_view.new_size();
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            WeightsFileSession::Name_, 0, false);
        return false;
      }
      auto callback =
          WeightsFileSession_RequestCapacityChange_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->RequestCapacityChange(        
        std::move(p_new_size), std::move(callback));
      return true;
    }
    case messages::WeightsFileSession::kFinalize: {
      internal::WeightsFileSession_Finalize_Params_Data* params =
          reinterpret_cast<
              internal::WeightsFileSession_Finalize_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for WeightsFileSession.1
      bool success = true;
      WeightsFileSession_Finalize_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            WeightsFileSession::Name_, 1, false);
        return false;
      }
      auto callback =
          WeightsFileSession_Finalize_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->Finalize(std::move(callback));
      return true;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kWeightsFileSessionValidationInfo[] = {
    { &internal::WeightsFileSession_RequestCapacityChange_Params_Data::Validate,
     &internal::WeightsFileSession_RequestCapacityChange_ResponseParams_Data::Validate},
    { &internal::WeightsFileSession_Finalize_Params_Data::Validate,
     &internal::WeightsFileSession_Finalize_ResponseParams_Data::Validate},
};

bool WeightsFileSessionRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::webnn::mojom::WeightsFileSession::Name_,
    kWeightsFileSessionValidationInfo);
}

bool WeightsFileSessionResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::webnn::mojom::WeightsFileSession::Name_,
    kWeightsFileSessionValidationInfo);
}
// The declaration includes the definition on other builds.

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


const char* WebNNWeightsFileCreator::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::WebNNWeightsFileCreator>(message.name())) {
      case messages::WebNNWeightsFileCreator::kOpenWeightsFile:
            return "Receive webnn::mojom::WebNNWeightsFileCreator::OpenWeightsFile";
    }
  } else {
    switch (static_cast<messages::WebNNWeightsFileCreator>(message.name())) {
      case messages::WebNNWeightsFileCreator::kOpenWeightsFile:
            return "Receive reply webnn::mojom::WebNNWeightsFileCreator::OpenWeightsFile";
    }
  }
  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 WebNNWeightsFileCreator::OpenWeightsFile_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 = 0x4e10f280;  // IPCStableHash for webnn::mojom::WebNNWeightsFileCreator::OpenWeightsFile
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

// static
bool WebNNWeightsFileCreator::RuntimeFeature_IsEnabled_(bool expected) {
  bool enabled = base::FeatureList::IsEnabled(::webnn::mojom::features::kWebMachineLearningNeuralNetwork);
#if DCHECK_IS_ON()
  if (expected) {
    DCHECK(enabled) << "RuntimeFeature ::webnn::mojom::features::kWebMachineLearningNeuralNetwork for WebNNWeightsFileCreator is not enabled";
  }
#endif
  return enabled;
}

class WebNNWeightsFileCreator_OpenWeightsFile_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  WebNNWeightsFileCreator_OpenWeightsFile_ForwardToCallback(
      WebNNWeightsFileCreator::OpenWeightsFileCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  WebNNWeightsFileCreator::OpenWeightsFileCallback callback_;
};

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

void WebNNWeightsFileCreatorProxy::OpenWeightsFile(
    OpenWeightsFileCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send webnn::mojom::WebNNWeightsFileCreator::OpenWeightsFile");
#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::WebNNWeightsFileCreator::kOpenWeightsFile), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WebNNWeightsFileCreator_OpenWeightsFile_Params_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WebNNWeightsFileCreator::Name_);
  message.set_method_name("OpenWeightsFile");
#endif
  std::unique_ptr<mojo::MessageReceiver> responder(
      new WebNNWeightsFileCreator_OpenWeightsFile_ForwardToCallback(
          std::move(callback)));
  ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
class WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
 public:
  static WebNNWeightsFileCreator::OpenWeightsFileCallback CreateCallback(
      ::mojo::Message& message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
    std::unique_ptr<WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder> proxy(
        new WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder(
            message, std::move(responder)));
    return base::BindOnce(&WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder::Run,
                          std::move(proxy));
  }

  ~WebNNWeightsFileCreator_OpenWeightsFile_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:
  WebNNWeightsFileCreator_OpenWeightsFile_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)
        << "WebNNWeightsFileCreator::OpenWeightsFileCallback 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(
      ::base::File in_writable_fd, ::mojo::PendingRemote<WeightsFileSession> in_session);
};

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

  // Validation for WebNNWeightsFileCreator.0
  bool success = true;
  ::base::File p_writable_fd{};
  ::mojo::PendingRemote<WeightsFileSession> p_session{};
  WebNNWeightsFileCreator_OpenWeightsFile_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadWritableFd(&p_writable_fd))
    success = false;
  if (success) {
    p_session =
        input_data_view.TakeSession<decltype(p_session)>();
  }
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        WebNNWeightsFileCreator::Name_, 0, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_writable_fd), 
std::move(p_session));
  }
  return true;
}

void WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder::Run(
    ::base::File in_writable_fd, ::mojo::PendingRemote<WeightsFileSession> in_session) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply webnn::mojom::WebNNWeightsFileCreator::OpenWeightsFile", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("writable_fd"), in_writable_fd,
                        "<value of type ::base::File>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("session"), in_session,
                        "<value of type ::mojo::PendingRemote<WeightsFileSession>>");
   });
#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::WebNNWeightsFileCreator::kOpenWeightsFile), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::webnn::mojom::internal::WebNNWeightsFileCreator_OpenWeightsFile_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->writable_fd)::BaseType> writable_fd_fragment(
          params.message());
  
  mojo::internal::Serialize<::mojo_base::mojom::FileDataView>(
    in_writable_fd,
    writable_fd_fragment);

  params->writable_fd.Set(
      writable_fd_fragment.is_null() ? nullptr : writable_fd_fragment.data());

  
  mojo::internal::Serialize<mojo::InterfacePtrDataView<::webnn::mojom::WeightsFileSessionInterfaceBase>>(
    in_session,
    &params->session,
    &params.message());

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(WebNNWeightsFileCreator::Name_);
  message.set_method_name("OpenWeightsFile");
#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 WebNNWeightsFileCreatorStubDispatch::Accept(
    WebNNWeightsFileCreator* impl,
    mojo::Message* message) {
  switch (static_cast<messages::WebNNWeightsFileCreator>(message->header()->name)) {
    case messages::WebNNWeightsFileCreator::kOpenWeightsFile: {
      break;
    }
  }
  return false;
}

// static
bool WebNNWeightsFileCreatorStubDispatch::AcceptWithResponder(
    WebNNWeightsFileCreator* 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::WebNNWeightsFileCreator>(message->header()->name)) {
    case messages::WebNNWeightsFileCreator::kOpenWeightsFile: {
      internal::WebNNWeightsFileCreator_OpenWeightsFile_Params_Data* params =
          reinterpret_cast<
              internal::WebNNWeightsFileCreator_OpenWeightsFile_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for WebNNWeightsFileCreator.0
      bool success = true;
      WebNNWeightsFileCreator_OpenWeightsFile_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            WebNNWeightsFileCreator::Name_, 0, false);
        return false;
      }
      auto callback =
          WebNNWeightsFileCreator_OpenWeightsFile_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->OpenWeightsFile(std::move(callback));
      return true;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kWebNNWeightsFileCreatorValidationInfo[] = {
    { &internal::WebNNWeightsFileCreator_OpenWeightsFile_Params_Data::Validate,
     &internal::WebNNWeightsFileCreator_OpenWeightsFile_ResponseParams_Data::Validate},
};

bool WebNNWeightsFileCreatorRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::webnn::mojom::WebNNWeightsFileCreator::Name_,
    kWebNNWeightsFileCreatorValidationInfo);
}

bool WebNNWeightsFileCreatorResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::webnn::mojom::WebNNWeightsFileCreator::Name_,
    kWebNNWeightsFileCreatorValidationInfo);
}


}  // webnn::mojom


namespace mojo {


// static
bool StructTraits<::webnn::mojom::CreateContextOptions::DataView, ::webnn::mojom::CreateContextOptionsPtr>::Read(
    ::webnn::mojom::CreateContextOptions::DataView input,
    ::webnn::mojom::CreateContextOptionsPtr* output) {
  bool success = true;
  ::webnn::mojom::CreateContextOptionsPtr result(::webnn::mojom::CreateContextOptions::New());
  
      if (success && !input.ReadDevice(&result->device))
        success = false;
      if (success && !input.ReadPowerPreference(&result->power_preference))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::webnn::mojom::CreateContextSuccess::DataView, ::webnn::mojom::CreateContextSuccessPtr>::Read(
    ::webnn::mojom::CreateContextSuccess::DataView input,
    ::webnn::mojom::CreateContextSuccessPtr* output) {
  bool success = true;
  ::webnn::mojom::CreateContextSuccessPtr result(::webnn::mojom::CreateContextSuccess::New());
  
      if (success) {
        result->context_remote =
            input.TakeContextRemote<decltype(result->context_remote)>();
      }
      if (success) {
        result->compiler_context_remote =
            input.TakeCompilerContextRemote<decltype(result->compiler_context_remote)>();
      }
      if (success && !input.ReadContextProperties(&result->context_properties))
        success = false;
      if (success && !input.ReadContextHandle(&result->context_handle))
        success = false;
      if (success)
        result->write_tensor_producer = input.TakeWriteTensorProducer();
      if (success)
        result->read_tensor_consumer = input.TakeReadTensorConsumer();
      if (success)
        result->command_buffer_id = input.command_buffer_id();
  *output = std::move(result);
  return success;
}

// static
bool UnionTraits<::webnn::mojom::CreateContextResult::DataView, ::webnn::mojom::CreateContextResultPtr>::Read(
    ::webnn::mojom::CreateContextResult::DataView input,
    ::webnn::mojom::CreateContextResultPtr* output) {
  using UnionType = ::webnn::mojom::CreateContextResult;
  using Tag = UnionType::Tag;

  switch (input.tag()) {
    case Tag::kSuccess: {
      ::webnn::mojom::CreateContextSuccessPtr result_success{};
      if (!input.ReadSuccess(&result_success))
        return false;

      *output = UnionType::NewSuccess(
          std::move(result_success));
      break;
    }
    case Tag::kError: {
      ::webnn::mojom::ErrorPtr result_error{};
      if (!input.ReadError(&result_error))
        return false;

      *output = UnionType::NewError(
          std::move(result_error));
      break;
    }
    default:

      return false;
  }
  return true;
}

}  // namespace mojo


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


namespace webnn::mojom {


void WebNNContextProviderInterceptorForTesting::CreateWebNNContext(CreateContextOptionsPtr options, CreateWebNNContextCallback callback) {
  GetForwardingInterface()->CreateWebNNContext(
    std::move(options)
    , std::move(callback));
}
WebNNContextProviderAsyncWaiter::WebNNContextProviderAsyncWaiter(
    WebNNContextProvider* proxy) : proxy_(proxy) {}

WebNNContextProviderAsyncWaiter::~WebNNContextProviderAsyncWaiter() = default;


void WebNNContextProviderAsyncWaiter::CreateWebNNContext(
    CreateContextOptionsPtr options, CreateContextResultPtr* out_result) {
  base::RunLoop loop;
  proxy_->CreateWebNNContext(
      std::move(options),
      base::BindOnce(
          [](base::RunLoop* loop,
             CreateContextResultPtr* out_result
,
             CreateContextResultPtr result) {*out_result = std::move(result);
            loop->Quit();
          },
          &loop,
          out_result));
  loop.Run();
}

CreateContextResultPtr WebNNContextProviderAsyncWaiter::CreateWebNNContext(
    CreateContextOptionsPtr options) {
  CreateContextResultPtr async_wait_result;
  CreateWebNNContext(std::move(options),&async_wait_result);
  return async_wait_result;
}




void WeightsFileSessionInterceptorForTesting::RequestCapacityChange(uint64_t new_size, RequestCapacityChangeCallback callback) {
  GetForwardingInterface()->RequestCapacityChange(
    std::move(new_size)
    , std::move(callback));
}
void WeightsFileSessionInterceptorForTesting::Finalize(FinalizeCallback callback) {
  GetForwardingInterface()->Finalize(std::move(callback));
}
WeightsFileSessionAsyncWaiter::WeightsFileSessionAsyncWaiter(
    WeightsFileSession* proxy) : proxy_(proxy) {}

WeightsFileSessionAsyncWaiter::~WeightsFileSessionAsyncWaiter() = default;


void WeightsFileSessionAsyncWaiter::RequestCapacityChange(
    uint64_t new_size, bool* out_granted) {
  base::RunLoop loop;
  proxy_->RequestCapacityChange(
      std::move(new_size),
      base::BindOnce(
          [](base::RunLoop* loop,
             bool* out_granted
,
             bool granted) {*out_granted = std::move(granted);
            loop->Quit();
          },
          &loop,
          out_granted));
  loop.Run();
}

bool WeightsFileSessionAsyncWaiter::RequestCapacityChange(
    uint64_t new_size) {
  bool async_wait_result;
  RequestCapacityChange(std::move(new_size),&async_wait_result);
  return async_wait_result;
}

void WeightsFileSessionAsyncWaiter::Finalize(
    ::base::File* out_sealed_file) {
  base::RunLoop loop;
  proxy_->Finalize(
      base::BindOnce(
          [](base::RunLoop* loop,
             ::base::File* out_sealed_file
,
             ::base::File sealed_file) {*out_sealed_file = std::move(sealed_file);
            loop->Quit();
          },
          &loop,
          out_sealed_file));
  loop.Run();
}

::base::File WeightsFileSessionAsyncWaiter::Finalize(
    ) {
  ::base::File async_wait_result;
  Finalize(&async_wait_result);
  return async_wait_result;
}




void WebNNWeightsFileCreatorInterceptorForTesting::OpenWeightsFile(OpenWeightsFileCallback callback) {
  GetForwardingInterface()->OpenWeightsFile(std::move(callback));
}
WebNNWeightsFileCreatorAsyncWaiter::WebNNWeightsFileCreatorAsyncWaiter(
    WebNNWeightsFileCreator* proxy) : proxy_(proxy) {}

WebNNWeightsFileCreatorAsyncWaiter::~WebNNWeightsFileCreatorAsyncWaiter() = default;


void WebNNWeightsFileCreatorAsyncWaiter::OpenWeightsFile(
    ::base::File* out_writable_fd, ::mojo::PendingRemote<WeightsFileSession>* out_session) {
  base::RunLoop loop;
  proxy_->OpenWeightsFile(
      base::BindOnce(
          [](base::RunLoop* loop,
             ::base::File* out_writable_fd
,
             ::mojo::PendingRemote<WeightsFileSession>* out_session
,
             ::base::File writable_fd,
             ::mojo::PendingRemote<WeightsFileSession> session) {*out_writable_fd = std::move(writable_fd);*out_session = std::move(session);
            loop->Quit();
          },
          &loop,
          out_writable_fd,
          out_session));
  loop.Run();
}








}  // webnn::mojom


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