1/*
2 * Copyright (C) 2017 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#if ENABLE(SERVICE_WORKER)
29
30#include "DocumentIdentifier.h"
31#include "ServiceWorkerIdentifier.h"
32#include <wtf/ObjectIdentifier.h>
33#include <wtf/Variant.h>
34
35namespace WebCore {
36
37struct ServiceWorkerData;
38struct ServiceWorkerClientData;
39struct ServiceWorkerClientIdentifier;
40
41enum class ServiceWorkerRegistrationState : uint8_t {
42 Installing = 0,
43 Waiting = 1,
44 Active = 2,
45};
46
47enum class ServiceWorkerState : uint8_t {
48 Installing,
49 Installed,
50 Activating,
51 Activated,
52 Redundant,
53};
54
55enum class ServiceWorkerClientFrameType {
56 Auxiliary,
57 TopLevel,
58 Nested,
59 None
60};
61
62enum class ShouldNotifyWhenResolved : bool { No, Yes };
63
64enum ServiceWorkerRegistrationIdentifierType { };
65using ServiceWorkerRegistrationIdentifier = ObjectIdentifier<ServiceWorkerRegistrationIdentifierType>;
66
67enum ServiceWorkerJobIdentifierType { };
68using ServiceWorkerJobIdentifier = ObjectIdentifier<ServiceWorkerJobIdentifierType>;
69
70enum SWServerToContextConnectionIdentifierType { };
71using SWServerToContextConnectionIdentifier = ObjectIdentifier<SWServerToContextConnectionIdentifierType>;
72
73enum SWServerConnectionIdentifierType { };
74using SWServerConnectionIdentifier = ObjectIdentifier<SWServerConnectionIdentifierType>;
75
76using DocumentOrWorkerIdentifier = Variant<DocumentIdentifier, ServiceWorkerIdentifier>;
77
78using ServiceWorkerOrClientData = Variant<ServiceWorkerData, ServiceWorkerClientData>;
79using ServiceWorkerOrClientIdentifier = Variant<ServiceWorkerIdentifier, ServiceWorkerClientIdentifier>;
80
81} // namespace WebCore
82
83namespace WTF {
84
85template <> struct EnumTraits<WebCore::ServiceWorkerClientFrameType> {
86 using values = EnumValues<
87 WebCore::ServiceWorkerClientFrameType,
88 WebCore::ServiceWorkerClientFrameType::Auxiliary,
89 WebCore::ServiceWorkerClientFrameType::TopLevel,
90 WebCore::ServiceWorkerClientFrameType::Nested,
91 WebCore::ServiceWorkerClientFrameType::None
92 >;
93};
94
95template <> struct EnumTraits<WebCore::ServiceWorkerRegistrationState> {
96 using values = EnumValues<
97 WebCore::ServiceWorkerRegistrationState,
98 WebCore::ServiceWorkerRegistrationState::Installing,
99 WebCore::ServiceWorkerRegistrationState::Waiting,
100 WebCore::ServiceWorkerRegistrationState::Active
101 >;
102};
103
104template <> struct EnumTraits<WebCore::ServiceWorkerState> {
105 using values = EnumValues<
106 WebCore::ServiceWorkerState,
107 WebCore::ServiceWorkerState::Installing,
108 WebCore::ServiceWorkerState::Installed,
109 WebCore::ServiceWorkerState::Activating,
110 WebCore::ServiceWorkerState::Activated,
111 WebCore::ServiceWorkerState::Redundant
112 >;
113};
114
115template <> struct EnumTraits<WebCore::ShouldNotifyWhenResolved> {
116 using values = EnumValues<
117 WebCore::ShouldNotifyWhenResolved,
118 WebCore::ShouldNotifyWhenResolved::No,
119 WebCore::ShouldNotifyWhenResolved::Yes
120 >;
121};
122
123} // namespace WTF
124
125#endif // ENABLE(SERVICE_WORKER)
126