2019-08-15 17:26:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_serviceworkeroppromise_h__
|
|
|
|
#define mozilla_dom_serviceworkeroppromise_h__
|
|
|
|
|
2020-03-17 12:42:12 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2019-08-15 17:26:22 +00:00
|
|
|
#include "mozilla/MozPromise.h"
|
2023-03-27 07:20:25 +00:00
|
|
|
|
2021-11-08 13:29:32 +00:00
|
|
|
#include "mozilla/dom/SafeRefPtr.h"
|
2019-08-15 17:26:22 +00:00
|
|
|
#include "mozilla/dom/ServiceWorkerOpArgs.h"
|
|
|
|
|
2022-05-09 20:41:14 +00:00
|
|
|
namespace mozilla::dom {
|
2019-08-15 17:26:22 +00:00
|
|
|
|
|
|
|
class InternalResponse;
|
|
|
|
|
|
|
|
using SynthesizeResponseArgs =
|
2023-03-27 07:20:25 +00:00
|
|
|
std::tuple<SafeRefPtr<InternalResponse>, FetchEventRespondWithClosure,
|
|
|
|
FetchEventTimeStamps>;
|
2019-08-15 17:26:22 +00:00
|
|
|
|
|
|
|
using FetchEventRespondWithResult =
|
|
|
|
Variant<SynthesizeResponseArgs, ResetInterceptionArgs,
|
|
|
|
CancelInterceptionArgs>;
|
|
|
|
|
|
|
|
using FetchEventRespondWithPromise =
|
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 11:02:18 +00:00
|
|
|
MozPromise<FetchEventRespondWithResult, CancelInterceptionArgs, true>;
|
2019-08-15 17:26:22 +00:00
|
|
|
|
2021-11-09 20:24:27 +00:00
|
|
|
// The reject type int is arbitrary, since this promise will never get rejected.
|
|
|
|
// Unfortunately void is not supported as a reject type.
|
2022-05-11 19:40:47 +00:00
|
|
|
using FetchEventPreloadResponseAvailablePromise =
|
|
|
|
MozPromise<SafeRefPtr<InternalResponse>, int, true>;
|
|
|
|
|
2023-02-23 02:52:54 +00:00
|
|
|
using FetchEventPreloadResponseTimingPromise =
|
|
|
|
MozPromise<ResponseTiming, int, true>;
|
|
|
|
|
2022-05-11 19:40:47 +00:00
|
|
|
using FetchEventPreloadResponseEndPromise =
|
|
|
|
MozPromise<ResponseEndArgs, int, true>;
|
2021-11-09 20:24:27 +00:00
|
|
|
|
2019-08-15 17:26:22 +00:00
|
|
|
using ServiceWorkerOpPromise =
|
|
|
|
MozPromise<ServiceWorkerOpResult, nsresult, true>;
|
|
|
|
|
2020-10-07 16:02:24 +00:00
|
|
|
using ServiceWorkerFetchEventOpPromise =
|
|
|
|
MozPromise<ServiceWorkerFetchEventOpResult, nsresult, true>;
|
|
|
|
|
2022-05-09 20:41:14 +00:00
|
|
|
} // namespace mozilla::dom
|
2019-08-15 17:26:22 +00:00
|
|
|
|
|
|
|
#endif // mozilla_dom_serviceworkeroppromise_h__
|