2019-08-15 20:26:22 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
include ClientIPCTypes;
|
|
|
|
include DOMTypes;
|
|
|
|
include FetchTypes;
|
|
|
|
|
2020-11-23 19:05:38 +03:00
|
|
|
include "mozilla/dom/ServiceWorkerIPCUtils.h";
|
|
|
|
|
2023-01-25 13:52:10 +03:00
|
|
|
using mozilla::dom::ServiceWorkerState from "mozilla/dom/ServiceWorkerBinding.h";
|
2022-02-09 02:53:44 +03:00
|
|
|
using mozilla::TimeStamp from "mozilla/TimeStamp.h";
|
2019-08-15 20:26:22 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ServiceWorkerOpArgs
|
|
|
|
*/
|
|
|
|
struct ServiceWorkerCheckScriptEvaluationOpArgs {};
|
|
|
|
|
|
|
|
struct ServiceWorkerUpdateStateOpArgs {
|
|
|
|
ServiceWorkerState state;
|
|
|
|
};
|
|
|
|
|
2020-01-29 13:08:35 +03:00
|
|
|
struct ServiceWorkerTerminateWorkerOpArgs {
|
|
|
|
uint32_t shutdownStateId;
|
|
|
|
};
|
2019-08-15 20:26:22 +03:00
|
|
|
|
|
|
|
struct ServiceWorkerLifeCycleEventOpArgs {
|
|
|
|
nsString eventName;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Possibly need to differentiate an empty array from the absence of an array.
|
|
|
|
union OptionalPushData {
|
|
|
|
void_t;
|
|
|
|
uint8_t[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ServiceWorkerPushEventOpArgs {
|
|
|
|
nsString messageId;
|
|
|
|
OptionalPushData data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ServiceWorkerPushSubscriptionChangeEventOpArgs {};
|
|
|
|
|
|
|
|
struct ServiceWorkerNotificationEventOpArgs {
|
|
|
|
nsString eventName;
|
|
|
|
nsString id;
|
|
|
|
nsString title;
|
|
|
|
nsString dir;
|
|
|
|
nsString lang;
|
|
|
|
nsString body;
|
|
|
|
nsString tag;
|
|
|
|
nsString icon;
|
|
|
|
nsString data;
|
|
|
|
nsString behavior;
|
|
|
|
nsString scope;
|
|
|
|
uint32_t disableOpenClickDelay;
|
|
|
|
};
|
|
|
|
|
2021-12-15 21:29:36 +03:00
|
|
|
struct ServiceWorkerExtensionAPIEventOpArgs {
|
|
|
|
// WebExtensions API namespace and event names, for a list of the API namespaces
|
|
|
|
// and related API event names refer to the API JSONSchema files in-tree:
|
|
|
|
//
|
|
|
|
// https://searchfox.org/mozilla-central/search?q=&path=extensions%2Fschemas%2F*.json
|
|
|
|
nsString apiNamespace;
|
|
|
|
nsString apiEventName;
|
|
|
|
};
|
|
|
|
|
2019-08-15 20:26:22 +03:00
|
|
|
struct ServiceWorkerMessageEventOpArgs {
|
|
|
|
ClientInfoAndState clientInfoAndState;
|
2020-07-13 11:43:27 +03:00
|
|
|
ClonedOrErrorMessageData clonedData;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
2021-11-19 19:45:19 +03:00
|
|
|
struct ServiceWorkerFetchEventOpArgsCommon {
|
2019-08-15 20:26:22 +03:00
|
|
|
nsCString workerScriptSpec;
|
|
|
|
IPCInternalRequest internalRequest;
|
|
|
|
nsString clientId;
|
|
|
|
nsString resultingClientId;
|
|
|
|
bool isNonSubresourceRequest;
|
2021-11-09 23:24:27 +03:00
|
|
|
// Is navigation preload enabled for this fetch? If true, if some
|
|
|
|
// preloadResponse was not already provided in this structure, then it's
|
|
|
|
// expected that a PreloadResponse message will eventually be sent.
|
|
|
|
bool preloadNavigation;
|
2021-07-13 00:10:26 +03:00
|
|
|
// Failure injection helper; non-NS_OK values indicate that the event, instead
|
|
|
|
// of dispatching should instead return a `CancelInterceptionArgs` response
|
|
|
|
// with this nsresult. This value originates from
|
|
|
|
// `nsIServiceWorkerInfo::testingInjectCancellation`.
|
|
|
|
nsresult testingInjectCancellation;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
2021-11-19 19:45:19 +03:00
|
|
|
struct ParentToParentServiceWorkerFetchEventOpArgs {
|
|
|
|
ServiceWorkerFetchEventOpArgsCommon common;
|
2022-05-11 22:40:47 +03:00
|
|
|
ParentToParentInternalResponse? preloadResponse;
|
2023-02-23 05:52:54 +03:00
|
|
|
ResponseTiming? preloadResponseTiming;
|
2022-05-11 22:40:47 +03:00
|
|
|
ResponseEndArgs? preloadResponseEndArgs;
|
2021-11-19 19:45:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ParentToChildServiceWorkerFetchEventOpArgs {
|
|
|
|
ServiceWorkerFetchEventOpArgsCommon common;
|
2022-05-11 22:40:47 +03:00
|
|
|
ParentToChildInternalResponse? preloadResponse;
|
2023-02-23 05:52:54 +03:00
|
|
|
ResponseTiming? preloadResponseTiming;
|
2022-05-11 22:40:47 +03:00
|
|
|
ResponseEndArgs? preloadResponseEndArgs;
|
2021-11-19 19:45:19 +03:00
|
|
|
};
|
|
|
|
|
2019-08-15 20:26:22 +03:00
|
|
|
union ServiceWorkerOpArgs {
|
|
|
|
ServiceWorkerCheckScriptEvaluationOpArgs;
|
|
|
|
ServiceWorkerUpdateStateOpArgs;
|
|
|
|
ServiceWorkerTerminateWorkerOpArgs;
|
|
|
|
ServiceWorkerLifeCycleEventOpArgs;
|
|
|
|
ServiceWorkerPushEventOpArgs;
|
|
|
|
ServiceWorkerPushSubscriptionChangeEventOpArgs;
|
|
|
|
ServiceWorkerNotificationEventOpArgs;
|
|
|
|
ServiceWorkerMessageEventOpArgs;
|
2021-12-15 21:29:36 +03:00
|
|
|
ServiceWorkerExtensionAPIEventOpArgs;
|
2021-11-19 19:45:19 +03:00
|
|
|
ParentToChildServiceWorkerFetchEventOpArgs;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IPCFetchEventRespondWithResult
|
|
|
|
*/
|
|
|
|
struct FetchEventRespondWithClosure {
|
|
|
|
nsCString respondWithScriptSpec;
|
|
|
|
uint32_t respondWithLineNumber;
|
|
|
|
uint32_t respondWithColumnNumber;
|
|
|
|
};
|
|
|
|
|
Bug 1693074 - Adding telemetry for evaluating the duration of fetch event dispatching and response synthesizing. r=dom-worker-reviewers,asuth
This patch tries to record the fetch event dispatching time, the response's synthesizing time, and interception resetting time.
Fetch event dispatching time is the time duration between interception starts, which is the time point of InterceptedHttpChannel::AsyncOpenInternal(), and the fetch handler starts. It includes the InterceptedHttpChannel setup time, ServiceWorker launch time, FetchEventOp propagation through IPC, a FetchEvent creation, initialization, and dispatching/scheduling on worker scope.
Response synthesizing time is the time duration between the fetch handler finishes, which is the resolving/rejecting promise of respondWith(), to the finish of pumping the synthesized response to InterceptedHttpChannel, which is the time point of calling InterceptedHttpChannel::OnStopRequest(). It includes the response propagation through IPC, response header and body synthesis, and pumping synthesized response to the channel.
Interception resetting time is the time duration between the fetch handler finishes and redirecting InterceptedHttpChannel to a normal HTTP channel.
Since the fetch handler is executed on the process where the service worker spawned, the timestamps related to the fetch handler need to be get on that process. So this patch adds the FetchHandlerStart and FetchHandlerFinish on IPCFetchEventRespondWithResult related types to propagate the timestamps to the parent process.
Depends on D118398
Differential Revision: https://phabricator.services.mozilla.com/D118399
2021-08-22 14:02:18 +03:00
|
|
|
struct FetchEventTimeStamps {
|
|
|
|
TimeStamp fetchHandlerStart;
|
|
|
|
TimeStamp fetchHandlerFinish;
|
|
|
|
};
|
|
|
|
|
2021-11-19 19:45:19 +03:00
|
|
|
struct ChildToParentSynthesizeResponseArgs {
|
|
|
|
ChildToParentInternalResponse internalResponse;
|
|
|
|
FetchEventRespondWithClosure closure;
|
|
|
|
FetchEventTimeStamps timeStamps;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ParentToParentSynthesizeResponseArgs {
|
|
|
|
ParentToParentInternalResponse internalResponse;
|
2019-08-15 20:26:22 +03:00
|
|
|
FetchEventRespondWithClosure closure;
|
Bug 1693074 - Adding telemetry for evaluating the duration of fetch event dispatching and response synthesizing. r=dom-worker-reviewers,asuth
This patch tries to record the fetch event dispatching time, the response's synthesizing time, and interception resetting time.
Fetch event dispatching time is the time duration between interception starts, which is the time point of InterceptedHttpChannel::AsyncOpenInternal(), and the fetch handler starts. It includes the InterceptedHttpChannel setup time, ServiceWorker launch time, FetchEventOp propagation through IPC, a FetchEvent creation, initialization, and dispatching/scheduling on worker scope.
Response synthesizing time is the time duration between the fetch handler finishes, which is the resolving/rejecting promise of respondWith(), to the finish of pumping the synthesized response to InterceptedHttpChannel, which is the time point of calling InterceptedHttpChannel::OnStopRequest(). It includes the response propagation through IPC, response header and body synthesis, and pumping synthesized response to the channel.
Interception resetting time is the time duration between the fetch handler finishes and redirecting InterceptedHttpChannel to a normal HTTP channel.
Since the fetch handler is executed on the process where the service worker spawned, the timestamps related to the fetch handler need to be get on that process. So this patch adds the FetchHandlerStart and FetchHandlerFinish on IPCFetchEventRespondWithResult related types to propagate the timestamps to the parent process.
Depends on D118398
Differential Revision: https://phabricator.services.mozilla.com/D118399
2021-08-22 14:02:18 +03:00
|
|
|
FetchEventTimeStamps timeStamps;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
Bug 1693074 - Adding telemetry for evaluating the duration of fetch event dispatching and response synthesizing. r=dom-worker-reviewers,asuth
This patch tries to record the fetch event dispatching time, the response's synthesizing time, and interception resetting time.
Fetch event dispatching time is the time duration between interception starts, which is the time point of InterceptedHttpChannel::AsyncOpenInternal(), and the fetch handler starts. It includes the InterceptedHttpChannel setup time, ServiceWorker launch time, FetchEventOp propagation through IPC, a FetchEvent creation, initialization, and dispatching/scheduling on worker scope.
Response synthesizing time is the time duration between the fetch handler finishes, which is the resolving/rejecting promise of respondWith(), to the finish of pumping the synthesized response to InterceptedHttpChannel, which is the time point of calling InterceptedHttpChannel::OnStopRequest(). It includes the response propagation through IPC, response header and body synthesis, and pumping synthesized response to the channel.
Interception resetting time is the time duration between the fetch handler finishes and redirecting InterceptedHttpChannel to a normal HTTP channel.
Since the fetch handler is executed on the process where the service worker spawned, the timestamps related to the fetch handler need to be get on that process. So this patch adds the FetchHandlerStart and FetchHandlerFinish on IPCFetchEventRespondWithResult related types to propagate the timestamps to the parent process.
Depends on D118398
Differential Revision: https://phabricator.services.mozilla.com/D118399
2021-08-22 14:02:18 +03:00
|
|
|
struct ResetInterceptionArgs {
|
|
|
|
FetchEventTimeStamps timeStamps;
|
|
|
|
};
|
2019-08-15 20:26:22 +03:00
|
|
|
|
|
|
|
struct CancelInterceptionArgs {
|
|
|
|
nsresult status;
|
Bug 1693074 - Adding telemetry for evaluating the duration of fetch event dispatching and response synthesizing. r=dom-worker-reviewers,asuth
This patch tries to record the fetch event dispatching time, the response's synthesizing time, and interception resetting time.
Fetch event dispatching time is the time duration between interception starts, which is the time point of InterceptedHttpChannel::AsyncOpenInternal(), and the fetch handler starts. It includes the InterceptedHttpChannel setup time, ServiceWorker launch time, FetchEventOp propagation through IPC, a FetchEvent creation, initialization, and dispatching/scheduling on worker scope.
Response synthesizing time is the time duration between the fetch handler finishes, which is the resolving/rejecting promise of respondWith(), to the finish of pumping the synthesized response to InterceptedHttpChannel, which is the time point of calling InterceptedHttpChannel::OnStopRequest(). It includes the response propagation through IPC, response header and body synthesis, and pumping synthesized response to the channel.
Interception resetting time is the time duration between the fetch handler finishes and redirecting InterceptedHttpChannel to a normal HTTP channel.
Since the fetch handler is executed on the process where the service worker spawned, the timestamps related to the fetch handler need to be get on that process. So this patch adds the FetchHandlerStart and FetchHandlerFinish on IPCFetchEventRespondWithResult related types to propagate the timestamps to the parent process.
Depends on D118398
Differential Revision: https://phabricator.services.mozilla.com/D118399
2021-08-22 14:02:18 +03:00
|
|
|
FetchEventTimeStamps timeStamps;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
2021-11-19 19:45:19 +03:00
|
|
|
union ChildToParentFetchEventRespondWithResult {
|
|
|
|
ChildToParentSynthesizeResponseArgs;
|
|
|
|
ResetInterceptionArgs;
|
|
|
|
CancelInterceptionArgs;
|
|
|
|
};
|
|
|
|
|
|
|
|
union ParentToParentFetchEventRespondWithResult {
|
|
|
|
ParentToParentSynthesizeResponseArgs;
|
2019-08-15 20:26:22 +03:00
|
|
|
ResetInterceptionArgs;
|
|
|
|
CancelInterceptionArgs;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ServiceWorkerOpResult
|
|
|
|
*/
|
|
|
|
struct ServiceWorkerCheckScriptEvaluationOpResult {
|
|
|
|
bool workerScriptExecutedSuccessfully;
|
|
|
|
bool fetchHandlerWasAdded;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ServiceWorkerFetchEventOpResult {
|
|
|
|
nsresult rv;
|
|
|
|
};
|
|
|
|
|
2021-12-15 21:29:36 +03:00
|
|
|
struct ServiceWorkerExtensionAPIEventOpResult {
|
|
|
|
bool extensionAPIEventListenerWasAdded;
|
|
|
|
};
|
|
|
|
|
2019-08-15 20:26:22 +03:00
|
|
|
union ServiceWorkerOpResult {
|
|
|
|
nsresult;
|
|
|
|
ServiceWorkerCheckScriptEvaluationOpResult;
|
|
|
|
ServiceWorkerFetchEventOpResult;
|
2021-12-15 21:29:36 +03:00
|
|
|
ServiceWorkerExtensionAPIEventOpResult;
|
2019-08-15 20:26:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|