// components/os_crypt/async/common/encryptor.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 "components/os_crypt/async/common/encryptor.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 "components/os_crypt/async/common/encryptor.mojom-params-data.h"
#include "components/os_crypt/async/common/encryptor.mojom-shared-message-ids.h"

#include "components/os_crypt/async/common/encryptor.mojom-blink-import-headers.h"
#include "components/os_crypt/async/common/encryptor.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace os_crypt_async::mojom::blink {
Key::Key()
    : algorithm(),
      key() {}

Key::Key(
    ::os_crypt_async::mojom::blink::Algorithm algorithm_in,
    ::base::UnsafeSharedMemoryRegion key_in)
    : algorithm(std::move(algorithm_in)),
      key(std::move(key_in)) {}

Key::~Key() = default;

void Key::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "algorithm"), this->algorithm,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::os_crypt_async::mojom::blink::Algorithm>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "key"), this->key,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::UnsafeSharedMemoryRegion>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool Key::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
Encryptor::Encryptor()
    : provider_for_encryption(),
      key_entries() {}

Encryptor::Encryptor(
    const ::blink::String& provider_for_encryption_in,
    ::blink::HashMap<::blink::String, KeyPtr> key_entries_in)
    : provider_for_encryption(std::move(provider_for_encryption_in)),
      key_entries(std::move(key_entries_in)) {}

Encryptor::~Encryptor() = default;

void Encryptor::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "provider_for_encryption"), this->provider_for_encryption,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::String&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "key_entries"), this->key_entries,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::blink::HashMap<::blink::String, KeyPtr>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // os_crypt_async::mojom::blink


namespace mojo {


// static
bool StructTraits<::os_crypt_async::mojom::blink::Key::DataView, ::os_crypt_async::mojom::blink::KeyPtr>::Read(
    ::os_crypt_async::mojom::blink::Key::DataView input,
    ::os_crypt_async::mojom::blink::KeyPtr* output) {
  bool success = true;
  ::os_crypt_async::mojom::blink::KeyPtr result(::os_crypt_async::mojom::blink::Key::New());
  
      if (success && !input.ReadAlgorithm(&result->algorithm))
        success = false;
      if (success && !input.ReadKey(&result->key))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::os_crypt_async::mojom::blink::Encryptor::DataView, ::os_crypt_async::mojom::blink::EncryptorPtr>::Read(
    ::os_crypt_async::mojom::blink::Encryptor::DataView input,
    ::os_crypt_async::mojom::blink::EncryptorPtr* output) {
  bool success = true;
  ::os_crypt_async::mojom::blink::EncryptorPtr result(::os_crypt_async::mojom::blink::Encryptor::New());
  
      if (success && !input.ReadProviderForEncryption(&result->provider_for_encryption))
        success = false;
      if (success && !input.ReadKeyEntries(&result->key_entries))
        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 os_crypt_async::mojom::blink {




}  // os_crypt_async::mojom::blink


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