This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhuyujia-webhopper/collector/adg-linux/gen/content/common/speech_recognizer.mojom-shared.cc
little_stone bd2d50cf35 code update
2022-05-05 20:41:28 +08:00

679 lines
22 KiB
C++
Executable File

// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4065)
#endif
#include "content/common/speech_recognizer.mojom-shared.h"
#include <utility>
#include "base/logging.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_context.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
namespace content {
namespace mojom {
namespace internal {
// static
bool StartSpeechRecognitionRequestParams_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const StartSpeechRecognitionRequestParams_Data* object = static_cast<const StartSpeechRecognitionRequestParams_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 56 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
object->session_request, 1, validation_context)) {
return false;
}
if (!mojo::internal::ValidateHandleOrInterface(object->session_request,
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;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->language, 3, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams language_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->language, validation_context,
&language_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->grammars, 4, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams grammars_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->grammars, validation_context,
&grammars_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->origin, 5, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->origin, validation_context))
return false;
return true;
}
StartSpeechRecognitionRequestParams_Data::StartSpeechRecognitionRequestParams_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognizer_Start_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognizer_Start_Params_Data* object = static_cast<const SpeechRecognizer_Start_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 16 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->params, 1, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->params, validation_context))
return false;
return true;
}
SpeechRecognizer_Start_Params_Data::SpeechRecognizer_Start_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSession_Abort_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSession_Abort_Params_Data* object = static_cast<const SpeechRecognitionSession_Abort_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSession_Abort_Params_Data::SpeechRecognitionSession_Abort_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSession_StopCapture_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSession_StopCapture_Params_Data* object = static_cast<const SpeechRecognitionSession_StopCapture_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSession_StopCapture_Params_Data::SpeechRecognitionSession_StopCapture_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_ResultRetrieved_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_ResultRetrieved_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_ResultRetrieved_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 16 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->results, 1, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams results_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->results, validation_context,
&results_validate_params)) {
return false;
}
return true;
}
SpeechRecognitionSessionClient_ResultRetrieved_Params_Data::SpeechRecognitionSessionClient_ResultRetrieved_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_ErrorOccurred_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_ErrorOccurred_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_ErrorOccurred_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 16 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->error, 1, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->error, validation_context))
return false;
return true;
}
SpeechRecognitionSessionClient_ErrorOccurred_Params_Data::SpeechRecognitionSessionClient_ErrorOccurred_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_Started_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_Started_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_Started_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_Started_Params_Data::SpeechRecognitionSessionClient_Started_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_AudioStarted_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_AudioStarted_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_AudioStarted_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_AudioStarted_Params_Data::SpeechRecognitionSessionClient_AudioStarted_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_SoundStarted_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_SoundStarted_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_SoundStarted_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_SoundStarted_Params_Data::SpeechRecognitionSessionClient_SoundStarted_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_SoundEnded_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_SoundEnded_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_SoundEnded_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_SoundEnded_Params_Data::SpeechRecognitionSessionClient_SoundEnded_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_AudioEnded_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_AudioEnded_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_AudioEnded_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_AudioEnded_Params_Data::SpeechRecognitionSessionClient_AudioEnded_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool SpeechRecognitionSessionClient_Ended_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SpeechRecognitionSessionClient_Ended_Params_Data* object = static_cast<const SpeechRecognitionSessionClient_Ended_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 8 }};
if (object->header_.version <=
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
return true;
}
SpeechRecognitionSessionClient_Ended_Params_Data::SpeechRecognitionSessionClient_Ended_Params_Data()
: header_({sizeof(*this), 0}) {}
} // namespace internal
} // namespace mojom
} // namespace content
#if defined(_MSC_VER)
#pragma warning(pop)
#endif