// third_party/blink/public/mojom/speech/speech_synthesis.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/public/mojom/speech/speech_synthesis.mojom-shared.h"
#include <ostream>
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "third_party/blink/public/mojom/speech/speech_synthesis.mojom-params-data.h"
namespace blink {
namespace mojom {

NOINLINE static const char* SpeechSynthesisErrorCodeToStringHelper(SpeechSynthesisErrorCode value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case SpeechSynthesisErrorCode::kCancelled:
      return "kCancelled";
    case SpeechSynthesisErrorCode::kInterrupted:
      return "kInterrupted";
    case SpeechSynthesisErrorCode::kErrorOccurred:
      return "kErrorOccurred";
    case SpeechSynthesisErrorCode::kNoError:
      return "kNoError";
    default:
      return nullptr;
  }
}

std::string SpeechSynthesisErrorCodeToString(SpeechSynthesisErrorCode value) {
  const char *str = SpeechSynthesisErrorCodeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown SpeechSynthesisErrorCode value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, SpeechSynthesisErrorCode value) {
  return os << SpeechSynthesisErrorCodeToString(value);
}

namespace internal {


// static
bool SpeechSynthesisUtterance_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 56, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisUtterance_Data* object =
      static_cast<const SpeechSynthesisUtterance_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->text, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& text_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->text, validation_context,
                                         &text_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->lang, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& lang_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->lang, validation_context,
                                         &lang_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->voice, 3, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& voice_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->voice, validation_context,
                                         &voice_validate_params)) {
    return false;
  }

  return true;
}

SpeechSynthesisUtterance_Data::SpeechSynthesisUtterance_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisVoice_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 40, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisVoice_Data* object =
      static_cast<const SpeechSynthesisVoice_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->voice_uri, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& voice_uri_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->voice_uri, validation_context,
                                         &voice_uri_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->name, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& name_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->name, validation_context,
                                         &name_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->lang, 3, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& lang_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->lang, validation_context,
                                         &lang_validate_params)) {
    return false;
  }

  return true;
}

SpeechSynthesisVoice_Data::SpeechSynthesisVoice_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisVoiceListObserver_OnSetVoiceList_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisVoiceListObserver_OnSetVoiceList_Params_Data* object =
      static_cast<const SpeechSynthesisVoiceListObserver_OnSetVoiceList_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->voice_list, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& voice_list_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->voice_list, validation_context,
                                         &voice_list_validate_params)) {
    return false;
  }

  return true;
}

SpeechSynthesisVoiceListObserver_OnSetVoiceList_Params_Data::SpeechSynthesisVoiceListObserver_OnSetVoiceList_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnStartedSpeaking_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnStartedSpeaking_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnStartedSpeaking_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnStartedSpeaking_Params_Data::SpeechSynthesisClient_OnStartedSpeaking_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnFinishedSpeaking_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnFinishedSpeaking_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnFinishedSpeaking_Params_Data*>(data);


  if (!::blink::mojom::internal::SpeechSynthesisErrorCode_Data
        ::Validate(object->error_code, validation_context))
    return false;

  return true;
}

SpeechSynthesisClient_OnFinishedSpeaking_Params_Data::SpeechSynthesisClient_OnFinishedSpeaking_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnPausedSpeaking_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnPausedSpeaking_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnPausedSpeaking_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnPausedSpeaking_Params_Data::SpeechSynthesisClient_OnPausedSpeaking_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnResumedSpeaking_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnResumedSpeaking_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnResumedSpeaking_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnResumedSpeaking_Params_Data::SpeechSynthesisClient_OnResumedSpeaking_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnEncounteredWordBoundary_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnEncounteredWordBoundary_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnEncounteredWordBoundary_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnEncounteredWordBoundary_Params_Data::SpeechSynthesisClient_OnEncounteredWordBoundary_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnEncounteredSentenceBoundary_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnEncounteredSentenceBoundary_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnEncounteredSentenceBoundary_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnEncounteredSentenceBoundary_Params_Data::SpeechSynthesisClient_OnEncounteredSentenceBoundary_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesisClient_OnEncounteredSpeakingError_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesisClient_OnEncounteredSpeakingError_Params_Data* object =
      static_cast<const SpeechSynthesisClient_OnEncounteredSpeakingError_Params_Data*>(data);

  return true;
}

SpeechSynthesisClient_OnEncounteredSpeakingError_Params_Data::SpeechSynthesisClient_OnEncounteredSpeakingError_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesis_AddVoiceListObserver_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesis_AddVoiceListObserver_Params_Data* object =
      static_cast<const SpeechSynthesis_AddVoiceListObserver_Params_Data*>(data);

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->observer, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->observer,
                                                 validation_context)) {
    return false;
  }

  return true;
}

SpeechSynthesis_AddVoiceListObserver_Params_Data::SpeechSynthesis_AddVoiceListObserver_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesis_Speak_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesis_Speak_Params_Data* object =
      static_cast<const SpeechSynthesis_Speak_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->utterance, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->utterance, validation_context))
    return false;

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->client, 2, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->client,
                                                 validation_context)) {
    return false;
  }

  return true;
}

SpeechSynthesis_Speak_Params_Data::SpeechSynthesis_Speak_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesis_Pause_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesis_Pause_Params_Data* object =
      static_cast<const SpeechSynthesis_Pause_Params_Data*>(data);

  return true;
}

SpeechSynthesis_Pause_Params_Data::SpeechSynthesis_Pause_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesis_Resume_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesis_Resume_Params_Data* object =
      static_cast<const SpeechSynthesis_Resume_Params_Data*>(data);

  return true;
}

SpeechSynthesis_Resume_Params_Data::SpeechSynthesis_Resume_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool SpeechSynthesis_Cancel_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const SpeechSynthesis_Cancel_Params_Data* object =
      static_cast<const SpeechSynthesis_Cancel_Params_Data*>(data);

  return true;
}

SpeechSynthesis_Cancel_Params_Data::SpeechSynthesis_Cancel_Params_Data()
    : header_({sizeof(*this), 0}) {}

}  // namespace internal
}  // namespace mojom
}  // namespace blink

namespace perfetto {

// static
void TraceFormatTraits<::blink::mojom::SpeechSynthesisErrorCode>::WriteIntoTrace(
   perfetto::TracedValue context, ::blink::mojom::SpeechSynthesisErrorCode value) {
  return std::move(context).WriteString(::blink::mojom::SpeechSynthesisErrorCodeToString(value));
}

} // namespace perfetto