chromium/components/metrics/structured/mojom/event_mojom_traits.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_METRICS_STRUCTURED_MOJOM_EVENT_MOJOM_TRAITS_H_
#define COMPONENTS_METRICS_STRUCTURED_MOJOM_EVENT_MOJOM_TRAITS_H_

#include <memory>
#include <optional>

#include "base/strings/string_number_conversions.h"
#include "components/metrics/structured/event.h"
#include "components/metrics/structured/mojom/event.mojom.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"

namespace mojo {

// Converts MetricValue into the union mojom::MetricValue and vice versa.
template <>
struct UnionTraits<metrics::structured::mojom::MetricValueDataView,
                   metrics::structured::Event::MetricValue> {};

// Converts mojom::Event to/from Event, so that Event can be used throughout the
// codebase without any direct reference to mojom::Event.
template <>
class StructTraits<metrics::structured::mojom::EventDataView,
                   metrics::structured::Event> {};

}  // namespace mojo

#endif  // COMPONENTS_METRICS_STRUCTURED_MOJOM_EVENT_MOJOM_TRAITS_H_