chromium/third_party/blink/public/common/tokens/tokens_mojom_traits.h

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

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_MOJOM_TRAITS_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_MOJOM_TRAITS_H_

#include "base/immediate_crash.h"
#include "third_party/blink/public/common/common_export.h"
#include "third_party/blink/public/common/tokens/token_mojom_traits_helper.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/mojom/tokens/tokens.mojom-shared.h"

namespace mojo {

// Mojom traits for the various token types.
// See third_party/blink/public/common/tokens/tokens.h for more details.

////////////////////////////////////////////////////////////////////////////////
// DOCUMENT TOKENS
template <>
struct StructTraits<blink::mojom::DocumentTokenDataView, blink::DocumentToken>
    : public blink::TokenMojomTraitsHelper<blink::mojom::DocumentTokenDataView,
                                           blink::DocumentToken> {};

////////////////////////////////////////////////////////////////////////////////
// FRAME TOKENS

template <>
struct StructTraits<blink::mojom::LocalFrameTokenDataView,
                    blink::LocalFrameToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::LocalFrameTokenDataView,
          blink::LocalFrameToken> {};

template <>
struct StructTraits<blink::mojom::RemoteFrameTokenDataView,
                    blink::RemoteFrameToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::RemoteFrameTokenDataView,
          blink::RemoteFrameToken> {};

template <>
struct BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::FrameTokenDataView, blink::FrameToken> {};

////////////////////////////////////////////////////////////////////////////////
// WORKER TOKENS

template <>
struct StructTraits<blink::mojom::DedicatedWorkerTokenDataView,
                    blink::DedicatedWorkerToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::DedicatedWorkerTokenDataView,
          blink::DedicatedWorkerToken> {};

template <>
struct StructTraits<blink::mojom::ServiceWorkerTokenDataView,
                    blink::ServiceWorkerToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::ServiceWorkerTokenDataView,
          blink::ServiceWorkerToken> {};

template <>
struct StructTraits<blink::mojom::SharedWorkerTokenDataView,
                    blink::SharedWorkerToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::SharedWorkerTokenDataView,
          blink::SharedWorkerToken> {};

template <>
struct BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::WorkerTokenDataView, blink::WorkerToken> {};

////////////////////////////////////////////////////////////////////////////////
// WORKLET TOKENS

template <>
struct StructTraits<blink::mojom::AnimationWorkletTokenDataView,
                    blink::AnimationWorkletToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::AnimationWorkletTokenDataView,
          blink::AnimationWorkletToken> {};

template <>
struct StructTraits<blink::mojom::AudioWorkletTokenDataView,
                    blink::AudioWorkletToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::AudioWorkletTokenDataView,
          blink::AudioWorkletToken> {};

template <>
struct StructTraits<blink::mojom::LayoutWorkletTokenDataView,
                    blink::LayoutWorkletToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::LayoutWorkletTokenDataView,
          blink::LayoutWorkletToken> {};

template <>
struct StructTraits<blink::mojom::PaintWorkletTokenDataView,
                    blink::PaintWorkletToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::PaintWorkletTokenDataView,
          blink::PaintWorkletToken> {};

template <>
struct StructTraits<blink::mojom::SharedStorageWorkletTokenDataView,
                    blink::SharedStorageWorkletToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::SharedStorageWorkletTokenDataView,
          blink::SharedStorageWorkletToken> {};

template <>
struct BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::WorkletTokenDataView, blink::WorkletToken> {};

////////////////////////////////////////////////////////////////////////////////
// SHADOW REALM TOKENS

template <>
struct StructTraits<blink::mojom::ShadowRealmTokenDataView,
                    blink::ShadowRealmToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::ShadowRealmTokenDataView,
          blink::ShadowRealmToken> {};

////////////////////////////////////////////////////////////////////////////////
// OTHER TOKENS
//
// Keep this section last.
//
// If you have multiple tokens that make a thematic group, please lift them to
// their own section, in alphabetical order. If adding a new token here, please
// keep the following list in alphabetic order.

template <>
struct StructTraits<blink::mojom::AttributionSrcTokenDataView,
                    blink::AttributionSrcToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::AttributionSrcTokenDataView,
          blink::AttributionSrcToken> {};

template <>
struct StructTraits<blink::mojom::ClipboardSequenceNumberTokenDataView,
                    blink::ClipboardSequenceNumberToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::ClipboardSequenceNumberTokenDataView,
          blink::ClipboardSequenceNumberToken> {};

template <>
struct BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::ExecutionContextTokenDataView,
                blink::ExecutionContextToken> {};

template <>
struct StructTraits<
    blink::mojom::SameDocNavigationScreenshotDestinationTokenDataView,
    blink::SameDocNavigationScreenshotDestinationToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::SameDocNavigationScreenshotDestinationTokenDataView,
          blink::SameDocNavigationScreenshotDestinationToken> {};

template <>
struct StructTraits<blink::mojom::V8ContextTokenDataView, blink::V8ContextToken>
    : public blink::TokenMojomTraitsHelper<blink::mojom::V8ContextTokenDataView,
                                           blink::V8ContextToken> {};

template <>
struct StructTraits<blink::mojom::ViewTransitionTokenDataView,
                    blink::ViewTransitionToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::ViewTransitionTokenDataView,
          blink::ViewTransitionToken> {};

template <>
struct BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::WebGPUExecutionContextTokenDataView,
                blink::WebGPUExecutionContextToken> {};

template <>
struct StructTraits<blink::mojom::WebNNContextTokenDataView,
                    blink::WebNNContextToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::WebNNContextTokenDataView,
          blink::WebNNContextToken> {};

template <>
struct StructTraits<blink::mojom::WebNNBufferTokenDataView,
                    blink::WebNNBufferToken>
    : public blink::TokenMojomTraitsHelper<
          blink::mojom::WebNNBufferTokenDataView,
          blink::WebNNBufferToken> {};

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_MOJOM_TRAITS_H_