summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/public/common/tokens/tokens_mojom_traits.h
blob: aa038987be136a5f7b320af1918fb1c52f7ba327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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 "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.

////////////////////////////////////////////////////////////////////////////////
// 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> {
  static bool Read(blink::mojom::FrameTokenDataView input,
                   blink::FrameToken* output);
  static blink::mojom::FrameTokenDataView::Tag GetTag(
      const blink::FrameToken& token);
  static blink::LocalFrameToken local_frame_token(
      const blink::FrameToken& token);
  static blink::RemoteFrameToken remote_frame_token(
      const blink::FrameToken& token);
};

////////////////////////////////////////////////////////////////////////////////
// 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> {
  static bool Read(blink::mojom::WorkerTokenDataView input,
                   blink::WorkerToken* output);
  static blink::mojom::WorkerTokenDataView::Tag GetTag(
      const blink::WorkerToken& token);
  static blink::DedicatedWorkerToken dedicated_worker_token(
      const blink::WorkerToken& token);
  static blink::ServiceWorkerToken service_worker_token(
      const blink::WorkerToken& token);
  static blink::SharedWorkerToken shared_worker_token(
      const blink::WorkerToken& token);
};

////////////////////////////////////////////////////////////////////////////////
// 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 BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::WorkletTokenDataView, blink::WorkletToken> {
  static bool Read(blink::mojom::WorkletTokenDataView input,
                   blink::WorkletToken* output);
  static blink::mojom::WorkletTokenDataView::Tag GetTag(
      const blink::WorkletToken& token);
  static blink::AnimationWorkletToken animation_worklet_token(
      const blink::WorkletToken& token);
  static blink::AudioWorkletToken audio_worklet_token(
      const blink::WorkletToken& token);
  static blink::LayoutWorkletToken layout_worklet_token(
      const blink::WorkletToken& token);
  static blink::PaintWorkletToken paint_worklet_token(
      const blink::WorkletToken& token);
};

////////////////////////////////////////////////////////////////////////////////
// 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 BLINK_COMMON_EXPORT
    UnionTraits<blink::mojom::ExecutionContextTokenDataView,
                blink::ExecutionContextToken> {
  static bool Read(blink::mojom::ExecutionContextTokenDataView input,
                   blink::ExecutionContextToken* output);
  static blink::mojom::ExecutionContextTokenDataView::Tag GetTag(
      const blink::ExecutionContextToken& token);
  static blink::LocalFrameToken local_frame_token(
      const blink::ExecutionContextToken& token);
  static blink::DedicatedWorkerToken dedicated_worker_token(
      const blink::ExecutionContextToken& token);
  static blink::ServiceWorkerToken service_worker_token(
      const blink::ExecutionContextToken& token);
  static blink::SharedWorkerToken shared_worker_token(
      const blink::ExecutionContextToken& token);
  static blink::AnimationWorkletToken animation_worklet_token(
      const blink::ExecutionContextToken& token);
  static blink::AudioWorkletToken audio_worklet_token(
      const blink::ExecutionContextToken& token);
  static blink::LayoutWorkletToken layout_worklet_token(
      const blink::ExecutionContextToken& token);
  static blink::PaintWorkletToken paint_worklet_token(
      const blink::ExecutionContextToken& token);
};

template <>
struct StructTraits<blink::mojom::PortalTokenDataView, blink::PortalToken>
    : public blink::TokenMojomTraitsHelper<blink::mojom::PortalTokenDataView,
                                           blink::PortalToken> {};

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

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_MOJOM_TRAITS_H_