// services/proxy_resolver/public/mojom/proxy_resolver.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 "services/proxy_resolver/public/mojom/proxy_resolver.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 "services/proxy_resolver/public/mojom/proxy_resolver.mojom-params-data.h"
namespace proxy_resolver {
namespace mojom {

NOINLINE static const char* HostResolveOperationToStringHelper(HostResolveOperation value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case HostResolveOperation::DNS_RESOLVE:
      return "DNS_RESOLVE";
    case HostResolveOperation::DNS_RESOLVE_EX:
      return "DNS_RESOLVE_EX";
    case HostResolveOperation::MY_IP_ADDRESS:
      return "MY_IP_ADDRESS";
    case HostResolveOperation::MY_IP_ADDRESS_EX:
      return "MY_IP_ADDRESS_EX";
    default:
      return nullptr;
  }
}

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

std::ostream& operator<<(std::ostream& os, HostResolveOperation value) {
  return os << HostResolveOperationToString(value);
}

namespace internal {


// static
bool ProxyInfo_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 ProxyInfo_Data* object =
      static_cast<const ProxyInfo_Data*>(data);

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

  return true;
}

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


// static
bool SystemProxyResolutionStatus_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 SystemProxyResolutionStatus_Data* object =
      static_cast<const SystemProxyResolutionStatus_Data*>(data);

  return true;
}

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


// static
bool HostResolverRequestClient_ReportResult_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 HostResolverRequestClient_ReportResult_Params_Data* object =
      static_cast<const HostResolverRequestClient_ReportResult_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolver_GetProxyForUrl_Params_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 ProxyResolver_GetProxyForUrl_Params_Data* object =
      static_cast<const ProxyResolver_GetProxyForUrl_Params_Data*>(data);

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

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->network_anonymization_key, 2, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->network_anonymization_key, validation_context))
    return false;

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

  return true;
}

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


// static
bool ProxyResolverRequestClient_ReportResult_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 ProxyResolverRequestClient_ReportResult_Params_Data* object =
      static_cast<const ProxyResolverRequestClient_ReportResult_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolverRequestClient_Alert_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 ProxyResolverRequestClient_Alert_Params_Data* object =
      static_cast<const ProxyResolverRequestClient_Alert_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolverRequestClient_OnError_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 ProxyResolverRequestClient_OnError_Params_Data* object =
      static_cast<const ProxyResolverRequestClient_OnError_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolverRequestClient_ResolveDns_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 48, 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 ProxyResolverRequestClient_ResolveDns_Params_Data* object =
      static_cast<const ProxyResolverRequestClient_ResolveDns_Params_Data*>(data);

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


  if (!::proxy_resolver::mojom::internal::HostResolveOperation_Data
        ::Validate(object->operation, validation_context))
    return false;

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->network_anonymization_key, 3, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->network_anonymization_key, validation_context))
    return false;

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

  return true;
}

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


// static
bool ProxyResolverFactory_CreateResolver_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 32, 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 ProxyResolverFactory_CreateResolver_Params_Data* object =
      static_cast<const ProxyResolverFactory_CreateResolver_Params_Data*>(data);

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

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

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

  return true;
}

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


// static
bool ProxyResolverFactoryRequestClient_ReportResult_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 ProxyResolverFactoryRequestClient_ReportResult_Params_Data* object =
      static_cast<const ProxyResolverFactoryRequestClient_ReportResult_Params_Data*>(data);

  return true;
}

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


// static
bool ProxyResolverFactoryRequestClient_Alert_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 ProxyResolverFactoryRequestClient_Alert_Params_Data* object =
      static_cast<const ProxyResolverFactoryRequestClient_Alert_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolverFactoryRequestClient_OnError_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 ProxyResolverFactoryRequestClient_OnError_Params_Data* object =
      static_cast<const ProxyResolverFactoryRequestClient_OnError_Params_Data*>(data);

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

  return true;
}

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


// static
bool ProxyResolverFactoryRequestClient_ResolveDns_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 48, 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 ProxyResolverFactoryRequestClient_ResolveDns_Params_Data* object =
      static_cast<const ProxyResolverFactoryRequestClient_ResolveDns_Params_Data*>(data);

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


  if (!::proxy_resolver::mojom::internal::HostResolveOperation_Data
        ::Validate(object->operation, validation_context))
    return false;

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->network_anonymization_key, 3, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->network_anonymization_key, validation_context))
    return false;

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

  return true;
}

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

}  // namespace internal
}  // namespace mojom
}  // namespace proxy_resolver

namespace perfetto {

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

} // namespace perfetto