// services/network/public/mojom/connection_allowlist.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/connection_allowlist.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/connection_allowlist.mojom-params-data.h"
#include "services/network/public/mojom/connection_allowlist.mojom-shared-message-ids.h"

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


namespace network::mojom::blink {
ConnectionAllowlist::ConnectionAllowlist()
    : allowlist(),
      reporting_endpoint(),
      issues(),
      redirect_behavior(),
      webrtc_behavior(),
      match_response_origin(),
      serialized_value() {}

ConnectionAllowlist::ConnectionAllowlist(
    ::blink::Vector<::blink::String> allowlist_in,
    const ::blink::String& reporting_endpoint_in,
    ::blink::Vector<ConnectionAllowlistIssue> issues_in,
    RedirectBehavior redirect_behavior_in,
    WebRtcBehavior webrtc_behavior_in,
    bool match_response_origin_in,
    const ::blink::String& serialized_value_in)
    : allowlist(std::move(allowlist_in)),
      reporting_endpoint(std::move(reporting_endpoint_in)),
      issues(std::move(issues_in)),
      redirect_behavior(std::move(redirect_behavior_in)),
      webrtc_behavior(std::move(webrtc_behavior_in)),
      match_response_origin(std::move(match_response_origin_in)),
      serialized_value(std::move(serialized_value_in)) {}

ConnectionAllowlist::~ConnectionAllowlist() = default;

void ConnectionAllowlist::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "allowlist"), this->allowlist,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::Vector<::blink::String>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "reporting_endpoint"), this->reporting_endpoint,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "issues"), this->issues,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::Vector<ConnectionAllowlistIssue>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "redirect_behavior"), this->redirect_behavior,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type RedirectBehavior>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "webrtc_behavior"), this->webrtc_behavior,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type WebRtcBehavior>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "match_response_origin"), this->match_response_origin,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "serialized_value"), this->serialized_value,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ConnectionAllowlist::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
ConnectionAllowlists::ConnectionAllowlists()
    : response_url(),
      enforced(),
      report_only(),
      reporting_source() {}

ConnectionAllowlists::ConnectionAllowlists(
    const ::blink::KURL& response_url_in,
    const std::optional<::network::ConnectionAllowlist>& enforced_in,
    const std::optional<::network::ConnectionAllowlist>& report_only_in,
    const std::optional<::base::UnguessableToken>& reporting_source_in)
    : response_url(std::move(response_url_in)),
      enforced(std::move(enforced_in)),
      report_only(std::move(report_only_in)),
      reporting_source(std::move(reporting_source_in)) {}

ConnectionAllowlists::~ConnectionAllowlists() = default;

void ConnectionAllowlists::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "response_url"), this->response_url,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::KURL&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "enforced"), this->enforced,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::network::ConnectionAllowlist>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "report_only"), this->report_only,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::network::ConnectionAllowlist>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "reporting_source"), this->reporting_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::base::UnguessableToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ConnectionAllowlists::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::ConnectionAllowlist::DataView, ::network::mojom::blink::ConnectionAllowlistPtr>::Read(
    ::network::mojom::blink::ConnectionAllowlist::DataView input,
    ::network::mojom::blink::ConnectionAllowlistPtr* output) {
  bool success = true;
  ::network::mojom::blink::ConnectionAllowlistPtr result(::network::mojom::blink::ConnectionAllowlist::New());
  
      if (success && !input.ReadAllowlist(&result->allowlist))
        success = false;
      if (success && !input.ReadReportingEndpoint(&result->reporting_endpoint))
        success = false;
      if (success && !input.ReadIssues(&result->issues))
        success = false;
      if (success && !input.ReadRedirectBehavior(&result->redirect_behavior))
        success = false;
      if (success && !input.ReadWebrtcBehavior(&result->webrtc_behavior))
        success = false;
      if (success)
        result->match_response_origin = input.match_response_origin();
      if (success && !input.ReadSerializedValue(&result->serialized_value))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::network::mojom::blink::ConnectionAllowlists::DataView, ::network::mojom::blink::ConnectionAllowlistsPtr>::Read(
    ::network::mojom::blink::ConnectionAllowlists::DataView input,
    ::network::mojom::blink::ConnectionAllowlistsPtr* output) {
  bool success = true;
  ::network::mojom::blink::ConnectionAllowlistsPtr result(::network::mojom::blink::ConnectionAllowlists::New());
  
      if (success && !input.ReadResponseUrl(&result->response_url))
        success = false;
      if (success && !input.ReadEnforced(&result->enforced))
        success = false;
      if (success && !input.ReadReportOnly(&result->report_only))
        success = false;
      if (success && !input.ReadReportingSource(&result->reporting_source))
        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