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

#include "third_party/blink/public/mojom/webrtc/rtc_logging.mojom-blink-import-headers.h"
#include "third_party/blink/public/mojom/webrtc/rtc_logging.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace blink::mojom::blink {
RTCMetadata::RTCMetadata()
    : values() {}

RTCMetadata::RTCMetadata(
    const ::blink::HashMap<::blink::String, ::blink::String>& values_in)
    : values(std::move(values_in)) {}

RTCMetadata::~RTCMetadata() = default;

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

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

RTCLoggingDispatcher::IPCStableHashFunction RTCLoggingDispatcher::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
  switch (static_cast<messages::RTCLoggingDispatcher>(message.name())) {
    case messages::RTCLoggingDispatcher::kStartDiagnosticLogging: {
      return &RTCLoggingDispatcher::StartDiagnosticLogging_Sym::IPCStableHash;
    }
    case messages::RTCLoggingDispatcher::kFinishDiagnosticLogging: {
      return &RTCLoggingDispatcher::FinishDiagnosticLogging_Sym::IPCStableHash;
    }
    case messages::RTCLoggingDispatcher::kCancelDiagnosticLogging: {
      return &RTCLoggingDispatcher::CancelDiagnosticLogging_Sym::IPCStableHash;
    }
  }
#endif  // !BUILDFLAG(IS_FUCHSIA)
  return nullptr;
}


const char* RTCLoggingDispatcher::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::RTCLoggingDispatcher>(message.name())) {
      case messages::RTCLoggingDispatcher::kStartDiagnosticLogging:
            return "Receive blink::mojom::RTCLoggingDispatcher::StartDiagnosticLogging";
      case messages::RTCLoggingDispatcher::kFinishDiagnosticLogging:
            return "Receive blink::mojom::RTCLoggingDispatcher::FinishDiagnosticLogging";
      case messages::RTCLoggingDispatcher::kCancelDiagnosticLogging:
            return "Receive blink::mojom::RTCLoggingDispatcher::CancelDiagnosticLogging";
    }
  } else {
    switch (static_cast<messages::RTCLoggingDispatcher>(message.name())) {
      case messages::RTCLoggingDispatcher::kStartDiagnosticLogging:
            return "Receive reply blink::mojom::RTCLoggingDispatcher::StartDiagnosticLogging";
      case messages::RTCLoggingDispatcher::kFinishDiagnosticLogging:
            return "Receive reply blink::mojom::RTCLoggingDispatcher::FinishDiagnosticLogging";
      case messages::RTCLoggingDispatcher::kCancelDiagnosticLogging:
            return "Receive reply blink::mojom::RTCLoggingDispatcher::CancelDiagnosticLogging";
    }
  }
  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 RTCLoggingDispatcher::StartDiagnosticLogging_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 = 0x29f80e38;  // IPCStableHash for blink::mojom::RTCLoggingDispatcher::StartDiagnosticLogging
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RTCLoggingDispatcher::FinishDiagnosticLogging_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 = 0xff82cb11;  // IPCStableHash for blink::mojom::RTCLoggingDispatcher::FinishDiagnosticLogging
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
uint32_t RTCLoggingDispatcher::CancelDiagnosticLogging_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 = 0x76530929;  // IPCStableHash for blink::mojom::RTCLoggingDispatcher::CancelDiagnosticLogging
  const uint32_t hash = kHash;
  base::debug::Alias(&hash);
  return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)

class RTCLoggingDispatcher_StartDiagnosticLogging_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RTCLoggingDispatcher_StartDiagnosticLogging_ForwardToCallback(
      RTCLoggingDispatcher::StartDiagnosticLoggingCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RTCLoggingDispatcher::StartDiagnosticLoggingCallback callback_;
};

class RTCLoggingDispatcher_FinishDiagnosticLogging_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RTCLoggingDispatcher_FinishDiagnosticLogging_ForwardToCallback(
      RTCLoggingDispatcher::FinishDiagnosticLoggingCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RTCLoggingDispatcher::FinishDiagnosticLoggingCallback callback_;
};

class RTCLoggingDispatcher_CancelDiagnosticLogging_ForwardToCallback
    : public mojo::MessageReceiver {
 public:
  RTCLoggingDispatcher_CancelDiagnosticLogging_ForwardToCallback(
      RTCLoggingDispatcher::CancelDiagnosticLoggingCallback callback
      ) : callback_(std::move(callback)) {
  }

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

  bool Accept(mojo::Message* message) override;
 private:
  RTCLoggingDispatcher::CancelDiagnosticLoggingCallback callback_;
};

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

void RTCLoggingDispatcherProxy::StartDiagnosticLogging(
    bool in_upload, const ::blink::HashMap<::blink::String, ::blink::String>& in_metadata, StartDiagnosticLoggingCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RTCLoggingDispatcher::StartDiagnosticLogging", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("upload"), in_upload,
                        "<value of type bool>");
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("metadata"), in_metadata,
                        "<value of type const ::blink::HashMap<::blink::String, ::blink::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::RTCLoggingDispatcher::kStartDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_StartDiagnosticLogging_Params_Data> params(
          message);
  params.Allocate();

  params->upload = in_upload;
  mojo::internal::MessageFragment<
      typename decltype(params->metadata)::BaseType> metadata_fragment(
          params.message());
  
  mojo::internal::Serialize<::blink::mojom::RTCMetadataDataView>(
    in_metadata,
    metadata_fragment);

  params->metadata.Set(
      metadata_fragment.is_null() ? nullptr : metadata_fragment.data());

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

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

void RTCLoggingDispatcherProxy::FinishDiagnosticLogging(
    const ::blink::HashMap<::blink::String, ::blink::String>& in_metadata, FinishDiagnosticLoggingCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send blink::mojom::RTCLoggingDispatcher::FinishDiagnosticLogging", "input_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("metadata"), in_metadata,
                        "<value of type const ::blink::HashMap<::blink::String, ::blink::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::RTCLoggingDispatcher::kFinishDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_FinishDiagnosticLogging_Params_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->metadata)::BaseType> metadata_fragment(
          params.message());
  
  mojo::internal::Serialize<::blink::mojom::RTCMetadataDataView>(
    in_metadata,
    metadata_fragment);

  params->metadata.Set(
      metadata_fragment.is_null() ? nullptr : metadata_fragment.data());

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

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

void RTCLoggingDispatcherProxy::CancelDiagnosticLogging(
    CancelDiagnosticLoggingCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send blink::mojom::RTCLoggingDispatcher::CancelDiagnosticLogging");
#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::RTCLoggingDispatcher::kCancelDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_CancelDiagnosticLogging_Params_Data> params(
          message);
  params.Allocate();

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

  ~RTCLoggingDispatcher_StartDiagnosticLogging_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:
  RTCLoggingDispatcher_StartDiagnosticLogging_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)
        << "RTCLoggingDispatcher::StartDiagnosticLoggingCallback 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 ::blink::String& in_uuid);
};

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

  // Validation for RTCLoggingDispatcher.0
  bool success = true;
  ::blink::String p_uuid{};
  RTCLoggingDispatcher_StartDiagnosticLogging_ResponseParamsDataView input_data_view(params, message);
  
  if (success && !input_data_view.ReadUuid(&p_uuid))
    success = false;
  if (!success) {
    ReportValidationErrorForMessage(
        message,
        mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
        RTCLoggingDispatcher::Name_, 0, true);
    return false;
  }
  if (!callback_.is_null()) {
    std::move(callback_).Run(
std::move(p_uuid));
  }
  return true;
}

void RTCLoggingDispatcher_StartDiagnosticLogging_ProxyToResponder::Run(
    const ::blink::String& in_uuid) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT1(
    "mojom", "Send reply blink::mojom::RTCLoggingDispatcher::StartDiagnosticLogging", "async_response_parameters",
    [&](perfetto::TracedValue context){
      auto dict = std::move(context).WriteDictionary();
      perfetto::WriteIntoTracedValueWithFallback(
           dict.AddItem("uuid"), in_uuid,
                        "<value of type const ::blink::String&>");
   });
#endif

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

  const size_t estimated_payload_size =
    0;
  mojo::Message message(
      std::to_underlying(messages::RTCLoggingDispatcher::kStartDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_StartDiagnosticLogging_ResponseParams_Data> params(
          message);
  params.Allocate();
  mojo::internal::MessageFragment<
      typename decltype(params->uuid)::BaseType> uuid_fragment(
          params.message());
  
  mojo::internal::Serialize<mojo::StringDataView>(
    in_uuid,
    uuid_fragment);

  params->uuid.Set(
      uuid_fragment.is_null() ? nullptr : uuid_fragment.data());

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

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

  ~RTCLoggingDispatcher_FinishDiagnosticLogging_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:
  RTCLoggingDispatcher_FinishDiagnosticLogging_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)
        << "RTCLoggingDispatcher::FinishDiagnosticLoggingCallback 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 RTCLoggingDispatcher_FinishDiagnosticLogging_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RTCLoggingDispatcher_FinishDiagnosticLogging_ResponseParams_Data* params =
      reinterpret_cast<
          internal::RTCLoggingDispatcher_FinishDiagnosticLogging_ResponseParams_Data*>(
              message->mutable_payload());
  

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

void RTCLoggingDispatcher_FinishDiagnosticLogging_ProxyToResponder::Run(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send reply blink::mojom::RTCLoggingDispatcher::FinishDiagnosticLogging");
#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::RTCLoggingDispatcher::kFinishDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_FinishDiagnosticLogging_ResponseParams_Data> params(
          message);
  params.Allocate();

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

  ~RTCLoggingDispatcher_CancelDiagnosticLogging_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:
  RTCLoggingDispatcher_CancelDiagnosticLogging_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)
        << "RTCLoggingDispatcher::CancelDiagnosticLoggingCallback 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 RTCLoggingDispatcher_CancelDiagnosticLogging_ForwardToCallback::Accept(
    mojo::Message* message) {
  DCHECK(message->is_serialized());
  internal::RTCLoggingDispatcher_CancelDiagnosticLogging_ResponseParams_Data* params =
      reinterpret_cast<
          internal::RTCLoggingDispatcher_CancelDiagnosticLogging_ResponseParams_Data*>(
              message->mutable_payload());
  

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

void RTCLoggingDispatcher_CancelDiagnosticLogging_ProxyToResponder::Run(
    ) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
  TRACE_EVENT0("mojom", "Send reply blink::mojom::RTCLoggingDispatcher::CancelDiagnosticLogging");
#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::RTCLoggingDispatcher::kCancelDiagnosticLogging), kFlags, estimated_payload_size);
  mojo::internal::MessageFragment<
      ::blink::mojom::internal::RTCLoggingDispatcher_CancelDiagnosticLogging_ResponseParams_Data> params(
          message);
  params.Allocate();

#if defined(ENABLE_IPC_FUZZER)
  message.set_interface_name(RTCLoggingDispatcher::Name_);
  message.set_method_name("CancelDiagnosticLogging");
#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 RTCLoggingDispatcherStubDispatch::Accept(
    RTCLoggingDispatcher* impl,
    mojo::Message* message) {
  switch (static_cast<messages::RTCLoggingDispatcher>(message->header()->name)) {
    case messages::RTCLoggingDispatcher::kStartDiagnosticLogging: {
      break;
    }
    case messages::RTCLoggingDispatcher::kFinishDiagnosticLogging: {
      break;
    }
    case messages::RTCLoggingDispatcher::kCancelDiagnosticLogging: {
      break;
    }
  }
  return false;
}

// static
bool RTCLoggingDispatcherStubDispatch::AcceptWithResponder(
    RTCLoggingDispatcher* 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::RTCLoggingDispatcher>(message->header()->name)) {
    case messages::RTCLoggingDispatcher::kStartDiagnosticLogging: {
      internal::RTCLoggingDispatcher_StartDiagnosticLogging_Params_Data* params =
          reinterpret_cast<
              internal::RTCLoggingDispatcher_StartDiagnosticLogging_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RTCLoggingDispatcher.0
      bool success = true;
      bool p_upload{};
      ::blink::HashMap<::blink::String, ::blink::String> p_metadata{};
      RTCLoggingDispatcher_StartDiagnosticLogging_ParamsDataView input_data_view(params, message);
      
      if (success)
        p_upload = input_data_view.upload();
      if (success && !input_data_view.ReadMetadata(&p_metadata))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RTCLoggingDispatcher::Name_, 0, false);
        return false;
      }
      auto callback =
          RTCLoggingDispatcher_StartDiagnosticLogging_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->StartDiagnosticLogging(        
        std::move(p_upload), 
        std::move(p_metadata), std::move(callback));
      return true;
    }
    case messages::RTCLoggingDispatcher::kFinishDiagnosticLogging: {
      internal::RTCLoggingDispatcher_FinishDiagnosticLogging_Params_Data* params =
          reinterpret_cast<
              internal::RTCLoggingDispatcher_FinishDiagnosticLogging_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RTCLoggingDispatcher.1
      bool success = true;
      ::blink::HashMap<::blink::String, ::blink::String> p_metadata{};
      RTCLoggingDispatcher_FinishDiagnosticLogging_ParamsDataView input_data_view(params, message);
      
      if (success && !input_data_view.ReadMetadata(&p_metadata))
        success = false;
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RTCLoggingDispatcher::Name_, 1, false);
        return false;
      }
      auto callback =
          RTCLoggingDispatcher_FinishDiagnosticLogging_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->FinishDiagnosticLogging(        
        std::move(p_metadata), std::move(callback));
      return true;
    }
    case messages::RTCLoggingDispatcher::kCancelDiagnosticLogging: {
      internal::RTCLoggingDispatcher_CancelDiagnosticLogging_Params_Data* params =
          reinterpret_cast<
              internal::RTCLoggingDispatcher_CancelDiagnosticLogging_Params_Data*>(
                  message->mutable_payload());
      

      // Validation for RTCLoggingDispatcher.2
      bool success = true;
      RTCLoggingDispatcher_CancelDiagnosticLogging_ParamsDataView input_data_view(params, message);
      
      if (!success) {
        ReportValidationErrorForMessage(
            message,
            mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
            RTCLoggingDispatcher::Name_, 2, false);
        return false;
      }
      auto callback =
          RTCLoggingDispatcher_CancelDiagnosticLogging_ProxyToResponder::CreateCallback(
              *message, std::move(responder));
      // A null |impl| means no implementation was bound.
      DCHECK(impl);
      impl->CancelDiagnosticLogging(std::move(callback));
      return true;
    }
  }
  return false;
}
namespace {
}  // namespace
static const mojo::internal::GenericValidationInfo kRTCLoggingDispatcherValidationInfo[] = {
    { &internal::RTCLoggingDispatcher_StartDiagnosticLogging_Params_Data::Validate,
     &internal::RTCLoggingDispatcher_StartDiagnosticLogging_ResponseParams_Data::Validate},
    { &internal::RTCLoggingDispatcher_FinishDiagnosticLogging_Params_Data::Validate,
     &internal::RTCLoggingDispatcher_FinishDiagnosticLogging_ResponseParams_Data::Validate},
    { &internal::RTCLoggingDispatcher_CancelDiagnosticLogging_Params_Data::Validate,
     &internal::RTCLoggingDispatcher_CancelDiagnosticLogging_ResponseParams_Data::Validate},
};

bool RTCLoggingDispatcherRequestValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateRequestGenericPacked(
    message,
    ::blink::mojom::blink::RTCLoggingDispatcher::Name_,
    kRTCLoggingDispatcherValidationInfo);
}

bool RTCLoggingDispatcherResponseValidator::Accept(mojo::Message* message) {
  return mojo::internal::ValidateResponseGenericPacked(
    message,
    ::blink::mojom::blink::RTCLoggingDispatcher::Name_,
    kRTCLoggingDispatcherValidationInfo);
}


}  // blink::mojom::blink


namespace mojo {


// static
bool StructTraits<::blink::mojom::blink::RTCMetadata::DataView, ::blink::mojom::blink::RTCMetadataPtr>::Read(
    ::blink::mojom::blink::RTCMetadata::DataView input,
    ::blink::mojom::blink::RTCMetadataPtr* output) {
  bool success = true;
  ::blink::mojom::blink::RTCMetadataPtr result(::blink::mojom::blink::RTCMetadata::New());
  
      if (success && !input.ReadValues(&result->values))
        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::blink {


void RTCLoggingDispatcherInterceptorForTesting::StartDiagnosticLogging(bool upload, const ::blink::HashMap<::blink::String, ::blink::String>& metadata, StartDiagnosticLoggingCallback callback) {
  GetForwardingInterface()->StartDiagnosticLogging(
    std::move(upload)
    , 
    std::move(metadata)
    , std::move(callback));
}
void RTCLoggingDispatcherInterceptorForTesting::FinishDiagnosticLogging(const ::blink::HashMap<::blink::String, ::blink::String>& metadata, FinishDiagnosticLoggingCallback callback) {
  GetForwardingInterface()->FinishDiagnosticLogging(
    std::move(metadata)
    , std::move(callback));
}
void RTCLoggingDispatcherInterceptorForTesting::CancelDiagnosticLogging(CancelDiagnosticLoggingCallback callback) {
  GetForwardingInterface()->CancelDiagnosticLogging(std::move(callback));
}
RTCLoggingDispatcherAsyncWaiter::RTCLoggingDispatcherAsyncWaiter(
    RTCLoggingDispatcher* proxy) : proxy_(proxy) {}

RTCLoggingDispatcherAsyncWaiter::~RTCLoggingDispatcherAsyncWaiter() = default;


void RTCLoggingDispatcherAsyncWaiter::StartDiagnosticLogging(
    bool upload, const ::blink::HashMap<::blink::String, ::blink::String>& metadata, ::blink::String* out_uuid) {
  base::RunLoop loop;
  proxy_->StartDiagnosticLogging(
      std::move(upload),
      std::move(metadata),
      base::BindOnce(
          [](base::RunLoop* loop,
             ::blink::String* out_uuid
,
             const ::blink::String& uuid) {*out_uuid = std::move(uuid);
            loop->Quit();
          },
          &loop,
          out_uuid));
  loop.Run();
}

::blink::String RTCLoggingDispatcherAsyncWaiter::StartDiagnosticLogging(
    bool upload, const ::blink::HashMap<::blink::String, ::blink::String>& metadata) {
  ::blink::String async_wait_result;
  StartDiagnosticLogging(std::move(upload),std::move(metadata),&async_wait_result);
  return async_wait_result;
}

void RTCLoggingDispatcherAsyncWaiter::FinishDiagnosticLogging(
    const ::blink::HashMap<::blink::String, ::blink::String>& metadata) {
  base::RunLoop loop;
  proxy_->FinishDiagnosticLogging(
      std::move(metadata),
      base::BindOnce(
          [](base::RunLoop* loop) {
            loop->Quit();
          },
          &loop));
  loop.Run();
}



void RTCLoggingDispatcherAsyncWaiter::CancelDiagnosticLogging(
    ) {
  base::RunLoop loop;
  proxy_->CancelDiagnosticLogging(
      base::BindOnce(
          [](base::RunLoop* loop) {
            loop->Quit();
          },
          &loop));
  loop.Run();
}








}  // blink::mojom::blink


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