// ui/latency/mojom/latency_info.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 "ui/latency/mojom/latency_info.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 "ui/latency/mojom/latency_info.mojom-params-data.h"
#include "ui/latency/mojom/latency_info.mojom-shared-message-ids.h"

#include "ui/latency/mojom/latency_info.mojom-blink-import-headers.h"
#include "ui/latency/mojom/latency_info.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace ui::mojom::blink {
LatencyInfo::LatencyInfo()
    : latency_components(),
      trace_id(),
      coalesced(),
      began(),
      terminated(),
      gesture_scroll_id(),
      touch_trace_id() {}

LatencyInfo::LatencyInfo(
    const ::blink::HashMap<::ui::LatencyComponentType, ::base::TimeTicks>& latency_components_in,
    int64_t trace_id_in,
    bool coalesced_in,
    bool began_in,
    bool terminated_in,
    int64_t gesture_scroll_id_in,
    int64_t touch_trace_id_in)
    : latency_components(std::move(latency_components_in)),
      trace_id(std::move(trace_id_in)),
      coalesced(std::move(coalesced_in)),
      began(std::move(began_in)),
      terminated(std::move(terminated_in)),
      gesture_scroll_id(std::move(gesture_scroll_id_in)),
      touch_trace_id(std::move(touch_trace_id_in)) {}

LatencyInfo::~LatencyInfo() = default;

void LatencyInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "latency_components"), this->latency_components,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::HashMap<::ui::LatencyComponentType, ::base::TimeTicks>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "trace_id"), this->trace_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "coalesced"), this->coalesced,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "began"), this->began,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "terminated"), this->terminated,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "gesture_scroll_id"), this->gesture_scroll_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "touch_trace_id"), this->touch_trace_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int64_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // ui::mojom::blink


namespace mojo {


// static
bool StructTraits<::ui::mojom::blink::LatencyInfo::DataView, ::ui::mojom::blink::LatencyInfoPtr>::Read(
    ::ui::mojom::blink::LatencyInfo::DataView input,
    ::ui::mojom::blink::LatencyInfoPtr* output) {
  bool success = true;
  ::ui::mojom::blink::LatencyInfoPtr result(::ui::mojom::blink::LatencyInfo::New());
  
      if (success && !input.ReadLatencyComponents(&result->latency_components))
        success = false;
      if (success)
        result->trace_id = input.trace_id();
      if (success)
        result->coalesced = input.coalesced();
      if (success)
        result->began = input.began();
      if (success)
        result->terminated = input.terminated();
      if (success)
        result->gesture_scroll_id = input.gesture_scroll_id();
      if (success)
        result->touch_trace_id = input.touch_trace_id();
  *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 ui::mojom::blink {




}  // ui::mojom::blink


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