// services/network/public/mojom/cors.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 "services/network/public/mojom/cors.mojom-blink.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.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 "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "services/network/public/mojom/cors.mojom-params-data.h"
#include "services/network/public/mojom/cors.mojom-shared-message-ids.h"

#include "services/network/public/mojom/cors.mojom-blink-import-headers.h"
#include "services/network/public/mojom/cors.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace network::mojom::blink {
CorsErrorStatus::CorsErrorStatus()
    : cors_error(),
      failed_parameter(),
      resource_address_space(::network::mojom::blink::IPAddressSpace::kUnknown),
      inconsistent_address_space(::network::mojom::blink::IPAddressSpace::kUnknown),
      has_authorization_covered_by_wildcard_on_preflight(false),
      issue_id() {}

CorsErrorStatus::CorsErrorStatus(
    CorsError cors_error_in,
    const ::blink::String& failed_parameter_in,
    ::network::mojom::blink::IPAddressSpace resource_address_space_in,
    ::network::mojom::blink::IPAddressSpace inconsistent_address_space_in,
    bool has_authorization_covered_by_wildcard_on_preflight_in,
    const ::base::UnguessableToken& issue_id_in)
    : cors_error(std::move(cors_error_in)),
      failed_parameter(std::move(failed_parameter_in)),
      resource_address_space(std::move(resource_address_space_in)),
      inconsistent_address_space(std::move(inconsistent_address_space_in)),
      has_authorization_covered_by_wildcard_on_preflight(std::move(has_authorization_covered_by_wildcard_on_preflight_in)),
      issue_id(std::move(issue_id_in)) {}

CorsErrorStatus::~CorsErrorStatus() = default;

void CorsErrorStatus::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "cors_error"), this->cors_error,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CorsError>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "failed_parameter"), this->failed_parameter,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "resource_address_space"), this->resource_address_space,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::network::mojom::blink::IPAddressSpace>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "inconsistent_address_space"), this->inconsistent_address_space,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::network::mojom::blink::IPAddressSpace>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "has_authorization_covered_by_wildcard_on_preflight"), this->has_authorization_covered_by_wildcard_on_preflight,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "issue_id"), this->issue_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::base::UnguessableToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool CorsErrorStatus::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // network::mojom::blink


namespace mojo {


// static
bool StructTraits<::network::mojom::blink::CorsErrorStatus::DataView, ::network::mojom::blink::CorsErrorStatusPtr>::Read(
    ::network::mojom::blink::CorsErrorStatus::DataView input,
    ::network::mojom::blink::CorsErrorStatusPtr* output) {
  bool success = true;
  ::network::mojom::blink::CorsErrorStatusPtr result(::network::mojom::blink::CorsErrorStatus::New());
  
      if (success && !input.ReadCorsError(&result->cors_error))
        success = false;
      if (success && !input.ReadFailedParameter(&result->failed_parameter))
        success = false;
      if (success && !input.ReadResourceAddressSpace(&result->resource_address_space))
        success = false;
      if (success && !input.ReadInconsistentAddressSpace(&result->inconsistent_address_space))
        success = false;
      if (success)
        result->has_authorization_covered_by_wildcard_on_preflight = input.has_authorization_covered_by_wildcard_on_preflight();
      if (success && !input.ReadIssueId(&result->issue_id))
        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 network::mojom::blink {




}  // network::mojom::blink


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