1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 include ClientIPCTypes;
9 include "mozilla/dom/ServiceWorkerIPCUtils.h";
11 using mozilla::dom::ServiceWorkerState from "mozilla/dom/ServiceWorkerBinding.h";
12 using mozilla::TimeStamp from "mozilla/TimeStamp.h";
20 struct ServiceWorkerCheckScriptEvaluationOpArgs {};
22 struct ServiceWorkerUpdateStateOpArgs {
23 ServiceWorkerState state;
26 struct ServiceWorkerTerminateWorkerOpArgs {
27 uint32_t shutdownStateId;
30 struct ServiceWorkerLifeCycleEventOpArgs {
34 // Possibly need to differentiate an empty array from the absence of an array.
35 union OptionalPushData {
40 struct ServiceWorkerPushEventOpArgs {
42 OptionalPushData data;
45 struct ServiceWorkerPushSubscriptionChangeEventOpArgs {};
47 struct ServiceWorkerNotificationEventOpArgs {
58 uint32_t disableOpenClickDelay;
61 struct ServiceWorkerExtensionAPIEventOpArgs {
62 // WebExtensions API namespace and event names, for a list of the API namespaces
63 // and related API event names refer to the API JSONSchema files in-tree:
65 // https://searchfox.org/mozilla-central/search?q=&path=extensions%2Fschemas%2F*.json
66 nsString apiNamespace;
67 nsString apiEventName;
70 struct ServiceWorkerMessageEventOpArgs {
71 PostMessageSource source;
72 ClonedOrErrorMessageData clonedData;
75 struct ServiceWorkerFetchEventOpArgsCommon {
76 nsCString workerScriptSpec;
77 IPCInternalRequest internalRequest;
79 nsString resultingClientId;
80 bool isNonSubresourceRequest;
81 // Is navigation preload enabled for this fetch? If true, if some
82 // preloadResponse was not already provided in this structure, then it's
83 // expected that a PreloadResponse message will eventually be sent.
84 bool preloadNavigation;
85 // Failure injection helper; non-NS_OK values indicate that the event, instead
86 // of dispatching should instead return a `CancelInterceptionArgs` response
87 // with this nsresult. This value originates from
88 // `nsIServiceWorkerInfo::testingInjectCancellation`.
89 nsresult testingInjectCancellation;
92 struct ParentToParentServiceWorkerFetchEventOpArgs {
93 ServiceWorkerFetchEventOpArgsCommon common;
94 ParentToParentInternalResponse? preloadResponse;
95 ResponseTiming? preloadResponseTiming;
96 ResponseEndArgs? preloadResponseEndArgs;
99 struct ParentToChildServiceWorkerFetchEventOpArgs {
100 ServiceWorkerFetchEventOpArgsCommon common;
101 ParentToChildInternalResponse? preloadResponse;
102 ResponseTiming? preloadResponseTiming;
103 ResponseEndArgs? preloadResponseEndArgs;
106 struct ServiceWorkerUpdateIsOnContentBlockingAllowListOpArgs {
107 bool onContentBlockingAllowList;
110 union ServiceWorkerOpArgs {
111 ServiceWorkerCheckScriptEvaluationOpArgs;
112 ServiceWorkerUpdateStateOpArgs;
113 ServiceWorkerTerminateWorkerOpArgs;
114 ServiceWorkerLifeCycleEventOpArgs;
115 ServiceWorkerPushEventOpArgs;
116 ServiceWorkerPushSubscriptionChangeEventOpArgs;
117 ServiceWorkerNotificationEventOpArgs;
118 ServiceWorkerMessageEventOpArgs;
119 ServiceWorkerExtensionAPIEventOpArgs;
120 ParentToChildServiceWorkerFetchEventOpArgs;
121 ServiceWorkerUpdateIsOnContentBlockingAllowListOpArgs;
125 * IPCFetchEventRespondWithResult
127 struct FetchEventRespondWithClosure {
128 nsCString respondWithScriptSpec;
129 uint32_t respondWithLineNumber;
130 uint32_t respondWithColumnNumber;
133 struct FetchEventTimeStamps {
134 TimeStamp fetchHandlerStart;
135 TimeStamp fetchHandlerFinish;
138 struct ChildToParentSynthesizeResponseArgs {
139 ChildToParentInternalResponse internalResponse;
140 FetchEventRespondWithClosure closure;
141 FetchEventTimeStamps timeStamps;
144 struct ParentToParentSynthesizeResponseArgs {
145 ParentToParentInternalResponse internalResponse;
146 FetchEventRespondWithClosure closure;
147 FetchEventTimeStamps timeStamps;
150 struct ResetInterceptionArgs {
151 FetchEventTimeStamps timeStamps;
154 struct CancelInterceptionArgs {
156 FetchEventTimeStamps timeStamps;
159 union ChildToParentFetchEventRespondWithResult {
160 ChildToParentSynthesizeResponseArgs;
161 ResetInterceptionArgs;
162 CancelInterceptionArgs;
165 union ParentToParentFetchEventRespondWithResult {
166 ParentToParentSynthesizeResponseArgs;
167 ResetInterceptionArgs;
168 CancelInterceptionArgs;
172 * ServiceWorkerOpResult
174 struct ServiceWorkerCheckScriptEvaluationOpResult {
175 bool workerScriptExecutedSuccessfully;
176 bool fetchHandlerWasAdded;
179 struct ServiceWorkerFetchEventOpResult {
183 struct ServiceWorkerExtensionAPIEventOpResult {
184 bool extensionAPIEventListenerWasAdded;
187 union ServiceWorkerOpResult {
189 ServiceWorkerCheckScriptEvaluationOpResult;
190 ServiceWorkerFetchEventOpResult;
191 ServiceWorkerExtensionAPIEventOpResult;
195 } // namespace mozilla