tokens.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_H_
  5. #define THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_H_
  6. #include "base/util/type_safety/token_type.h"
  7. #include "third_party/blink/public/common/tokens/multi_token.h"
  8. namespace blink {
  9. // Various token types. These are used as cross-layer and cross-process
  10. // identifiers for objects that exist in blink, but which have representations
  11. // in the browser process. They should not be used to identify objects in
  12. // browser-to-renderer control messages; rather, such messages should exist as
  13. // methods on the interface bound to the object itself. They are fine to use
  14. // for informational messages that cross over other interfaces, in both
  15. // directions.
  16. //
  17. // See README.md for more details.
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // FRAME TOKENS
  20. // Uniquely identifies a blink::LocalFrame / blink::WebLocalFrame /
  21. // content::RenderFrame in a renderer process, and its content::RenderFrameHost
  22. // counterpart in the browser.
  23. using LocalFrameToken = util::TokenType<class LocalFrameTokenTypeMarker>;
  24. // Uniquely identifies an blink::RemoteFrame / blink::WebRemoteFrame /
  25. // content::RenderFrameProxy in a renderer process, and its
  26. // ontent::RenderFrameProxyHost counterpart in the browser. There can be
  27. // multiple RemoteFrames corresponding to a single LocalFrame, and each token
  28. // will be distinct.
  29. using RemoteFrameToken = util::TokenType<class RemoteFrameTokenTypeMarker>;
  30. // Can represent either type of FrameToken.
  31. using FrameToken = MultiToken<LocalFrameToken, RemoteFrameToken>;
  32. ////////////////////////////////////////////////////////////////////////////////
  33. // WORKER TOKENS
  34. // Identifies a blink::DedicatedWorkerGlobalScope in the renderer and a
  35. // content::DedicatedWorkerHost in the browser.
  36. using DedicatedWorkerToken =
  37. util::TokenType<class DedicatedWorkerTokenTypeMarker>;
  38. // Identifies a blink::ServiceWorkerGlobalScope in the renderer and a
  39. // content::ServiceWorkerVersion in the browser.
  40. using ServiceWorkerToken = util::TokenType<class ServiceWorkerTokenTypeMarker>;
  41. // Identifies a blink::SharedWorkerGlobalScope in the renderer and a
  42. // content::SharedWorkerHost in the browser.
  43. using SharedWorkerToken = util::TokenType<class SharedWorkerTokenTypeMarker>;
  44. // Can represent any type of WorkerToken.
  45. using WorkerToken =
  46. MultiToken<DedicatedWorkerToken, ServiceWorkerToken, SharedWorkerToken>;
  47. ////////////////////////////////////////////////////////////////////////////////
  48. // WORKLET TOKENS
  49. // Identifies an animation worklet.
  50. using AnimationWorkletToken =
  51. util::TokenType<class AnimationWorkletTokenTypeMarker>;
  52. // Identifies an audio worklet.
  53. using AudioWorkletToken = util::TokenType<class AudioWorkletTokenTypeMarker>;
  54. // Identifies a layout worklet.
  55. using LayoutWorkletToken = util::TokenType<class LayoutWorkletTokenTypeMarker>;
  56. // Identifies a paint worklet.
  57. using PaintWorkletToken = util::TokenType<class PaintWorkletTokenTypeMarker>;
  58. // Can represent any type of WorkletToken.
  59. using WorkletToken = MultiToken<AnimationWorkletToken,
  60. AudioWorkletToken,
  61. LayoutWorkletToken,
  62. PaintWorkletToken>;
  63. ////////////////////////////////////////////////////////////////////////////////
  64. // OTHER TOKENS
  65. //
  66. // Keep this section last.
  67. //
  68. // If you have multiple tokens that make a thematic group, please lift them to
  69. // their own section, in alphabetical order. If adding a new token here, please
  70. // keep the following list in alphabetic order.
  71. // Identifies an arbitrary ExecutionContext. Each concrete implementation of an
  72. // ExecutionContext has a distinct token type that can be represented here.
  73. using ExecutionContextToken = MultiToken<LocalFrameToken,
  74. DedicatedWorkerToken,
  75. ServiceWorkerToken,
  76. SharedWorkerToken,
  77. AnimationWorkletToken,
  78. AudioWorkletToken,
  79. LayoutWorkletToken,
  80. PaintWorkletToken>;
  81. // Identifies a blink::PortalContents / blink::HTMLPortalElement in the
  82. // renderer process, and a content::Portal in the browser process.
  83. using PortalToken = util::TokenType<class PortalTokenTypeMarker>;
  84. // Identifies a v8::Context / blink::ScriptState.
  85. using V8ContextToken = util::TokenType<class V8ContextTokenTypeMarker>;
  86. } // namespace blink
  87. #endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_TOKENS_TOKENS_H_