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/. */ 4 5include ChannelInfo; 6include ClientIPCTypes; 7include DOMTypes; 8include FetchTypes; 9 10include "mozilla/dom/ServiceWorkerIPCUtils.h"; 11 12using ServiceWorkerState from "mozilla/dom/ServiceWorkerBinding.h"; 13 14namespace mozilla { 15namespace dom { 16 17/** 18 * ServiceWorkerOpArgs 19 */ 20struct ServiceWorkerCheckScriptEvaluationOpArgs {}; 21 22struct ServiceWorkerUpdateStateOpArgs { 23 ServiceWorkerState state; 24}; 25 26struct ServiceWorkerTerminateWorkerOpArgs { 27 uint32_t shutdownStateId; 28}; 29 30struct ServiceWorkerLifeCycleEventOpArgs { 31 nsString eventName; 32}; 33 34// Possibly need to differentiate an empty array from the absence of an array. 35union OptionalPushData { 36 void_t; 37 uint8_t[]; 38}; 39 40struct ServiceWorkerPushEventOpArgs { 41 nsString messageId; 42 OptionalPushData data; 43}; 44 45struct ServiceWorkerPushSubscriptionChangeEventOpArgs {}; 46 47struct ServiceWorkerNotificationEventOpArgs { 48 nsString eventName; 49 nsString id; 50 nsString title; 51 nsString dir; 52 nsString lang; 53 nsString body; 54 nsString tag; 55 nsString icon; 56 nsString data; 57 nsString behavior; 58 nsString scope; 59 uint32_t disableOpenClickDelay; 60}; 61 62struct ServiceWorkerMessageEventOpArgs { 63 ClientInfoAndState clientInfoAndState; 64 ClonedOrErrorMessageData clonedData; 65}; 66 67struct ServiceWorkerFetchEventOpArgs { 68 nsCString workerScriptSpec; 69 IPCInternalRequest internalRequest; 70 nsString clientId; 71 nsString resultingClientId; 72 bool isNonSubresourceRequest; 73 // Failure injection helper; non-NS_OK values indicate that the event, instead 74 // of dispatching should instead return a `CancelInterceptionArgs` response 75 // with this nsresult. This value originates from 76 // `nsIServiceWorkerInfo::testingInjectCancellation`. 77 nsresult testingInjectCancellation; 78}; 79 80union ServiceWorkerOpArgs { 81 ServiceWorkerCheckScriptEvaluationOpArgs; 82 ServiceWorkerUpdateStateOpArgs; 83 ServiceWorkerTerminateWorkerOpArgs; 84 ServiceWorkerLifeCycleEventOpArgs; 85 ServiceWorkerPushEventOpArgs; 86 ServiceWorkerPushSubscriptionChangeEventOpArgs; 87 ServiceWorkerNotificationEventOpArgs; 88 ServiceWorkerMessageEventOpArgs; 89 ServiceWorkerFetchEventOpArgs; 90}; 91 92/** 93 * IPCFetchEventRespondWithResult 94 */ 95struct FetchEventRespondWithClosure { 96 nsCString respondWithScriptSpec; 97 uint32_t respondWithLineNumber; 98 uint32_t respondWithColumnNumber; 99}; 100 101struct IPCSynthesizeResponseArgs { 102 IPCInternalResponse internalResponse; 103 FetchEventRespondWithClosure closure; 104}; 105 106struct ResetInterceptionArgs {}; 107 108struct CancelInterceptionArgs { 109 nsresult status; 110}; 111 112union IPCFetchEventRespondWithResult { 113 IPCSynthesizeResponseArgs; 114 ResetInterceptionArgs; 115 CancelInterceptionArgs; 116}; 117 118/** 119 * ServiceWorkerOpResult 120 */ 121struct ServiceWorkerCheckScriptEvaluationOpResult { 122 bool workerScriptExecutedSuccessfully; 123 bool fetchHandlerWasAdded; 124}; 125 126struct ServiceWorkerFetchEventOpResult { 127 nsresult rv; 128}; 129 130union ServiceWorkerOpResult { 131 nsresult; 132 ServiceWorkerCheckScriptEvaluationOpResult; 133 ServiceWorkerFetchEventOpResult; 134}; 135 136} // namespace dom 137} // namespace mozilla 138