Bug 1771337 [wpt PR 34217] - Convert `popup=popup` to `popup=auto` or just `popup...
[gecko.git] / dom / performance / PerformanceTiming.h
blob1bac8812aaf4cbe80ab47d4cc8b3eb2faa37829c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_PerformanceTiming_h
8 #define mozilla_dom_PerformanceTiming_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/BasePrincipal.h"
12 #include "mozilla/StaticPrefs_dom.h"
13 #include "nsContentUtils.h"
14 #include "nsDOMNavigationTiming.h"
15 #include "nsRFPService.h"
16 #include "nsWrapperCache.h"
17 #include "Performance.h"
18 #include "nsITimedChannel.h"
19 #include "mozilla/dom/PerformanceTimingTypes.h"
20 #include "mozilla/ipc/IPDLParamTraits.h"
21 #include "ipc/IPCMessageUtils.h"
22 #include "ipc/IPCMessageUtilsSpecializations.h"
23 #include "mozilla/net/nsServerTiming.h"
25 class nsIHttpChannel;
27 namespace mozilla::dom {
29 class PerformanceTiming;
31 class PerformanceTimingData final {
32 friend class PerformanceTiming;
33 friend struct mozilla::ipc::IPDLParamTraits<
34 mozilla::dom::PerformanceTimingData>;
36 public:
37 PerformanceTimingData() = default; // For deserialization
38 // This can return null.
39 static PerformanceTimingData* Create(nsITimedChannel* aChannel,
40 nsIHttpChannel* aHttpChannel,
41 DOMHighResTimeStamp aZeroTime,
42 nsAString& aInitiatorType,
43 nsAString& aEntryName);
45 PerformanceTimingData(nsITimedChannel* aChannel, nsIHttpChannel* aHttpChannel,
46 DOMHighResTimeStamp aZeroTime);
48 explicit PerformanceTimingData(const IPCPerformanceTimingData& aIPCData);
50 IPCPerformanceTimingData ToIPC();
52 void SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
53 nsITimedChannel* aChannel);
55 bool IsInitialized() const { return mInitialized; }
57 const nsString& NextHopProtocol() const { return mNextHopProtocol; }
59 uint64_t TransferSize() const { return mTransferSize; }
61 uint64_t EncodedBodySize() const { return mEncodedBodySize; }
63 uint64_t DecodedBodySize() const { return mDecodedBodySize; }
65 /**
66 * @param aStamp
67 * The TimeStamp recorded for a specific event. This TimeStamp can
68 * be null.
69 * @return the duration of an event with a given TimeStamp, relative to the
70 * navigationStart TimeStamp (the moment the user landed on the
71 * page), if the given TimeStamp is valid. Otherwise, it will return
72 * the FetchStart timing value.
74 inline DOMHighResTimeStamp TimeStampToReducedDOMHighResOrFetchStart(
75 Performance* aPerformance, TimeStamp aStamp) {
76 MOZ_ASSERT(aPerformance);
78 if (aStamp.IsNull()) {
79 return FetchStartHighRes(aPerformance);
82 DOMHighResTimeStamp rawTimestamp =
83 TimeStampToDOMHighRes(aPerformance, aStamp);
85 return nsRFPService::ReduceTimePrecisionAsMSecs(
86 rawTimestamp, aPerformance->GetRandomTimelineSeed(),
87 aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
90 /**
91 * The nsITimedChannel records an absolute timestamp for each event.
92 * The nsDOMNavigationTiming will record the moment when the user landed on
93 * the page. This is a window.performance unique timestamp, so it can be used
94 * for all the events (navigation timing and resource timing events).
96 * The algorithm operates in 2 steps:
97 * 1. The first step is to subtract the two timestamps: the argument (the
98 * event's timestamp) and the navigation start timestamp. This will result in
99 * a relative timestamp of the event (relative to the navigation start -
100 * window.performance.timing.navigationStart).
101 * 2. The second step is to add any required offset (the mZeroTime). For now,
102 * this offset value is either 0 (for the resource timing), or equal to
103 * "performance.navigationStart" (for navigation timing).
104 * For the resource timing, mZeroTime is set to 0, causing the result to be a
105 * relative time.
106 * For the navigation timing, mZeroTime is set to
107 * "performance.navigationStart" causing the result be an absolute time.
109 * @param aStamp
110 * The TimeStamp recorded for a specific event. This TimeStamp can't
111 * be null.
112 * @return number of milliseconds value as one of:
113 * - relative to the navigation start time, time the user has landed on the
114 * page
115 * - an absolute wall clock time since the unix epoch
117 inline DOMHighResTimeStamp TimeStampToDOMHighRes(Performance* aPerformance,
118 TimeStamp aStamp) const {
119 MOZ_ASSERT(aPerformance);
120 MOZ_ASSERT(!aStamp.IsNull());
122 TimeDuration duration = aStamp - aPerformance->CreationTimeStamp();
123 return duration.ToMilliseconds() + mZeroTime;
126 // The last channel's AsyncOpen time. This may occur before the FetchStart
127 // in some cases.
128 DOMHighResTimeStamp AsyncOpenHighRes(Performance* aPerformance);
130 // High resolution (used by resource timing)
131 DOMHighResTimeStamp WorkerStartHighRes(Performance* aPerformance);
132 DOMHighResTimeStamp FetchStartHighRes(Performance* aPerformance);
133 DOMHighResTimeStamp RedirectStartHighRes(Performance* aPerformance);
134 DOMHighResTimeStamp RedirectEndHighRes(Performance* aPerformance);
135 DOMHighResTimeStamp DomainLookupStartHighRes(Performance* aPerformance);
136 DOMHighResTimeStamp DomainLookupEndHighRes(Performance* aPerformance);
137 DOMHighResTimeStamp ConnectStartHighRes(Performance* aPerformance);
138 DOMHighResTimeStamp SecureConnectionStartHighRes(Performance* aPerformance);
139 DOMHighResTimeStamp ConnectEndHighRes(Performance* aPerformance);
140 DOMHighResTimeStamp RequestStartHighRes(Performance* aPerformance);
141 DOMHighResTimeStamp ResponseStartHighRes(Performance* aPerformance);
142 DOMHighResTimeStamp ResponseEndHighRes(Performance* aPerformance);
144 DOMHighResTimeStamp ZeroTime() const { return mZeroTime; }
146 uint8_t RedirectCountReal() const { return mRedirectCount; }
147 uint8_t GetRedirectCount() const;
149 bool AllRedirectsSameOrigin() const { return mAllRedirectsSameOrigin; }
151 // If this is false the values of redirectStart/End will be 0 This is false if
152 // no redirects occured, or if any of the responses failed the
153 // timing-allow-origin check in HttpBaseChannel::TimingAllowCheck
155 // If aEnsureSameOriginAndIgnoreTAO is false, it checks if all redirects pass
156 // TAO. When it is true, it checks if all redirects are same-origin and
157 // ignores the result of TAO.
158 bool ShouldReportCrossOriginRedirect(
159 bool aEnsureSameOriginAndIgnoreTAO) const;
161 // Cached result of CheckAllowedOrigin. If false, security sensitive
162 // attributes of the resourceTiming object will be set to 0
163 bool TimingAllowed() const { return mTimingAllowed; }
165 nsTArray<nsCOMPtr<nsIServerTiming>> GetServerTiming();
167 private:
168 // Checks if the resource is either same origin as the page that started
169 // the load, or if the response contains the Timing-Allow-Origin header
170 // with a value of * or matching the domain of the loading Principal
171 bool CheckAllowedOrigin(nsIHttpChannel* aResourceChannel,
172 nsITimedChannel* aChannel);
174 nsTArray<nsCOMPtr<nsIServerTiming>> mServerTiming;
175 nsString mNextHopProtocol;
177 TimeStamp mAsyncOpen;
178 TimeStamp mRedirectStart;
179 TimeStamp mRedirectEnd;
180 TimeStamp mDomainLookupStart;
181 TimeStamp mDomainLookupEnd;
182 TimeStamp mConnectStart;
183 TimeStamp mSecureConnectionStart;
184 TimeStamp mConnectEnd;
185 TimeStamp mRequestStart;
186 TimeStamp mResponseStart;
187 TimeStamp mCacheReadStart;
188 TimeStamp mResponseEnd;
189 TimeStamp mCacheReadEnd;
191 // ServiceWorker interception timing information
192 TimeStamp mWorkerStart;
193 TimeStamp mWorkerRequestStart;
194 TimeStamp mWorkerResponseEnd;
196 // This is an offset that will be added to each timing ([ms] resolution).
197 // There are only 2 possible values: (1) logicaly equal to navigationStart
198 // TimeStamp (results are absolute timstamps - wallclock); (2) "0" (results
199 // are relative to the navigation start).
200 DOMHighResTimeStamp mZeroTime = 0;
202 DOMHighResTimeStamp mFetchStart = 0;
204 uint64_t mEncodedBodySize = 0;
205 uint64_t mTransferSize = 0;
206 uint64_t mDecodedBodySize = 0;
208 uint8_t mRedirectCount = 0;
210 bool mAllRedirectsSameOrigin = false;
212 bool mAllRedirectsPassTAO = false;
214 bool mSecureConnection = false;
216 bool mTimingAllowed = false;
218 bool mInitialized = false;
221 // Script "performance.timing" object
222 class PerformanceTiming final : public nsWrapperCache {
223 public:
225 * @param aPerformance
226 * The performance object (the JS parent).
227 * This will allow access to "window.performance.timing" attribute
228 * for the navigation timing (can't be null).
229 * @param aChannel
230 * An nsITimedChannel used to gather all the networking timings by
231 * both the navigation timing and the resource timing (can't be null).
232 * @param aHttpChannel
233 * An nsIHttpChannel (the resource's http channel).
234 * This will be used by the resource timing cross-domain check
235 * algorithm.
236 * Argument is null for the navigation timing (navigation timing uses
237 * another algorithm for the cross-domain redirects).
238 * @param aZeroTime
239 * The offset that will be added to the timestamp of each event. This
240 * argument should be equal to performance.navigationStart for
241 * navigation timing and "0" for the resource timing.
243 PerformanceTiming(Performance* aPerformance, nsITimedChannel* aChannel,
244 nsIHttpChannel* aHttpChannel,
245 DOMHighResTimeStamp aZeroTime);
246 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PerformanceTiming)
247 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PerformanceTiming)
249 nsDOMNavigationTiming* GetDOMTiming() const {
250 return mPerformance->GetDOMTiming();
253 Performance* GetParentObject() const { return mPerformance; }
255 virtual JSObject* WrapObject(JSContext* cx,
256 JS::Handle<JSObject*> aGivenProto) override;
258 // PerformanceNavigation WebIDL methods
259 DOMTimeMilliSec NavigationStart() const {
260 if (!StaticPrefs::dom_enable_performance()) {
261 return 0;
263 return nsRFPService::ReduceTimePrecisionAsMSecs(
264 GetDOMTiming()->GetNavigationStart(),
265 mPerformance->GetRandomTimelineSeed(),
266 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
269 DOMTimeMilliSec UnloadEventStart() {
270 if (!StaticPrefs::dom_enable_performance()) {
271 return 0;
273 return nsRFPService::ReduceTimePrecisionAsMSecs(
274 GetDOMTiming()->GetUnloadEventStart(),
275 mPerformance->GetRandomTimelineSeed(),
276 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
279 DOMTimeMilliSec UnloadEventEnd() {
280 if (!StaticPrefs::dom_enable_performance()) {
281 return 0;
283 return nsRFPService::ReduceTimePrecisionAsMSecs(
284 GetDOMTiming()->GetUnloadEventEnd(),
285 mPerformance->GetRandomTimelineSeed(),
286 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
289 // Low resolution (used by navigation timing)
290 DOMTimeMilliSec FetchStart();
291 DOMTimeMilliSec RedirectStart();
292 DOMTimeMilliSec RedirectEnd();
293 DOMTimeMilliSec DomainLookupStart();
294 DOMTimeMilliSec DomainLookupEnd();
295 DOMTimeMilliSec ConnectStart();
296 DOMTimeMilliSec SecureConnectionStart();
297 DOMTimeMilliSec ConnectEnd();
298 DOMTimeMilliSec RequestStart();
299 DOMTimeMilliSec ResponseStart();
300 DOMTimeMilliSec ResponseEnd();
302 DOMTimeMilliSec DomLoading() {
303 if (!StaticPrefs::dom_enable_performance()) {
304 return 0;
306 return nsRFPService::ReduceTimePrecisionAsMSecs(
307 GetDOMTiming()->GetDomLoading(), mPerformance->GetRandomTimelineSeed(),
308 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
311 DOMTimeMilliSec DomInteractive() const {
312 if (!StaticPrefs::dom_enable_performance()) {
313 return 0;
315 return nsRFPService::ReduceTimePrecisionAsMSecs(
316 GetDOMTiming()->GetDomInteractive(),
317 mPerformance->GetRandomTimelineSeed(),
318 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
321 DOMTimeMilliSec DomContentLoadedEventStart() const {
322 if (!StaticPrefs::dom_enable_performance()) {
323 return 0;
325 return nsRFPService::ReduceTimePrecisionAsMSecs(
326 GetDOMTiming()->GetDomContentLoadedEventStart(),
327 mPerformance->GetRandomTimelineSeed(),
328 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
331 DOMTimeMilliSec DomContentLoadedEventEnd() const {
332 if (!StaticPrefs::dom_enable_performance()) {
333 return 0;
335 return nsRFPService::ReduceTimePrecisionAsMSecs(
336 GetDOMTiming()->GetDomContentLoadedEventEnd(),
337 mPerformance->GetRandomTimelineSeed(),
338 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
341 DOMTimeMilliSec DomComplete() const {
342 if (!StaticPrefs::dom_enable_performance()) {
343 return 0;
345 return nsRFPService::ReduceTimePrecisionAsMSecs(
346 GetDOMTiming()->GetDomComplete(), mPerformance->GetRandomTimelineSeed(),
347 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
350 DOMTimeMilliSec LoadEventStart() const {
351 if (!StaticPrefs::dom_enable_performance()) {
352 return 0;
354 return nsRFPService::ReduceTimePrecisionAsMSecs(
355 GetDOMTiming()->GetLoadEventStart(),
356 mPerformance->GetRandomTimelineSeed(),
357 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
360 DOMTimeMilliSec LoadEventEnd() const {
361 if (!StaticPrefs::dom_enable_performance()) {
362 return 0;
364 return nsRFPService::ReduceTimePrecisionAsMSecs(
365 GetDOMTiming()->GetLoadEventEnd(),
366 mPerformance->GetRandomTimelineSeed(),
367 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
370 DOMTimeMilliSec TimeToNonBlankPaint() const {
371 if (!StaticPrefs::dom_enable_performance()) {
372 return 0;
374 return nsRFPService::ReduceTimePrecisionAsMSecs(
375 GetDOMTiming()->GetTimeToNonBlankPaint(),
376 mPerformance->GetRandomTimelineSeed(),
377 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
380 DOMTimeMilliSec TimeToContentfulPaint() const {
381 if (!StaticPrefs::dom_enable_performance()) {
382 return 0;
384 return nsRFPService::ReduceTimePrecisionAsMSecs(
385 GetDOMTiming()->GetTimeToContentfulComposite(),
386 mPerformance->GetRandomTimelineSeed(),
387 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
390 DOMTimeMilliSec TimeToDOMContentFlushed() const {
391 if (!StaticPrefs::dom_enable_performance()) {
392 return 0;
394 return nsRFPService::ReduceTimePrecisionAsMSecs(
395 GetDOMTiming()->GetTimeToDOMContentFlushed(),
396 mPerformance->GetRandomTimelineSeed(),
397 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
400 DOMTimeMilliSec TimeToFirstInteractive() const {
401 if (!StaticPrefs::dom_enable_performance()) {
402 return 0;
404 return nsRFPService::ReduceTimePrecisionAsMSecs(
405 GetDOMTiming()->GetTimeToTTFI(), mPerformance->GetRandomTimelineSeed(),
406 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
409 PerformanceTimingData* Data() const { return mTimingData.get(); }
411 private:
412 ~PerformanceTiming();
414 bool IsTopLevelContentDocument() const;
416 RefPtr<Performance> mPerformance;
418 UniquePtr<PerformanceTimingData> mTimingData;
421 } // namespace mozilla::dom
423 namespace mozilla::ipc {
425 template <>
426 struct IPDLParamTraits<mozilla::dom::PerformanceTimingData> {
427 using paramType = mozilla::dom::PerformanceTimingData;
428 static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
429 const paramType& aParam) {
430 WriteIPDLParam(aWriter, aActor, aParam.mServerTiming);
431 WriteIPDLParam(aWriter, aActor, aParam.mNextHopProtocol);
432 WriteIPDLParam(aWriter, aActor, aParam.mAsyncOpen);
433 WriteIPDLParam(aWriter, aActor, aParam.mRedirectStart);
434 WriteIPDLParam(aWriter, aActor, aParam.mRedirectEnd);
435 WriteIPDLParam(aWriter, aActor, aParam.mDomainLookupStart);
436 WriteIPDLParam(aWriter, aActor, aParam.mDomainLookupEnd);
437 WriteIPDLParam(aWriter, aActor, aParam.mConnectStart);
438 WriteIPDLParam(aWriter, aActor, aParam.mSecureConnectionStart);
439 WriteIPDLParam(aWriter, aActor, aParam.mConnectEnd);
440 WriteIPDLParam(aWriter, aActor, aParam.mRequestStart);
441 WriteIPDLParam(aWriter, aActor, aParam.mResponseStart);
442 WriteIPDLParam(aWriter, aActor, aParam.mCacheReadStart);
443 WriteIPDLParam(aWriter, aActor, aParam.mResponseEnd);
444 WriteIPDLParam(aWriter, aActor, aParam.mCacheReadEnd);
445 WriteIPDLParam(aWriter, aActor, aParam.mWorkerStart);
446 WriteIPDLParam(aWriter, aActor, aParam.mWorkerRequestStart);
447 WriteIPDLParam(aWriter, aActor, aParam.mWorkerResponseEnd);
448 WriteIPDLParam(aWriter, aActor, aParam.mZeroTime);
449 WriteIPDLParam(aWriter, aActor, aParam.mFetchStart);
450 WriteIPDLParam(aWriter, aActor, aParam.mEncodedBodySize);
451 WriteIPDLParam(aWriter, aActor, aParam.mTransferSize);
452 WriteIPDLParam(aWriter, aActor, aParam.mDecodedBodySize);
453 WriteIPDLParam(aWriter, aActor, aParam.mRedirectCount);
454 WriteIPDLParam(aWriter, aActor, aParam.mAllRedirectsSameOrigin);
455 WriteIPDLParam(aWriter, aActor, aParam.mAllRedirectsPassTAO);
456 WriteIPDLParam(aWriter, aActor, aParam.mSecureConnection);
457 WriteIPDLParam(aWriter, aActor, aParam.mTimingAllowed);
458 WriteIPDLParam(aWriter, aActor, aParam.mInitialized);
461 static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
462 paramType* aResult) {
463 if (!ReadIPDLParam(aReader, aActor, &aResult->mServerTiming)) {
464 return false;
466 if (!ReadIPDLParam(aReader, aActor, &aResult->mNextHopProtocol)) {
467 return false;
469 if (!ReadIPDLParam(aReader, aActor, &aResult->mAsyncOpen)) {
470 return false;
472 if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectStart)) {
473 return false;
475 if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectEnd)) {
476 return false;
478 if (!ReadIPDLParam(aReader, aActor, &aResult->mDomainLookupStart)) {
479 return false;
481 if (!ReadIPDLParam(aReader, aActor, &aResult->mDomainLookupEnd)) {
482 return false;
484 if (!ReadIPDLParam(aReader, aActor, &aResult->mConnectStart)) {
485 return false;
487 if (!ReadIPDLParam(aReader, aActor, &aResult->mSecureConnectionStart)) {
488 return false;
490 if (!ReadIPDLParam(aReader, aActor, &aResult->mConnectEnd)) {
491 return false;
493 if (!ReadIPDLParam(aReader, aActor, &aResult->mRequestStart)) {
494 return false;
496 if (!ReadIPDLParam(aReader, aActor, &aResult->mResponseStart)) {
497 return false;
499 if (!ReadIPDLParam(aReader, aActor, &aResult->mCacheReadStart)) {
500 return false;
502 if (!ReadIPDLParam(aReader, aActor, &aResult->mResponseEnd)) {
503 return false;
505 if (!ReadIPDLParam(aReader, aActor, &aResult->mCacheReadEnd)) {
506 return false;
508 if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerStart)) {
509 return false;
511 if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerRequestStart)) {
512 return false;
514 if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerResponseEnd)) {
515 return false;
517 if (!ReadIPDLParam(aReader, aActor, &aResult->mZeroTime)) {
518 return false;
520 if (!ReadIPDLParam(aReader, aActor, &aResult->mFetchStart)) {
521 return false;
523 if (!ReadIPDLParam(aReader, aActor, &aResult->mEncodedBodySize)) {
524 return false;
526 if (!ReadIPDLParam(aReader, aActor, &aResult->mTransferSize)) {
527 return false;
529 if (!ReadIPDLParam(aReader, aActor, &aResult->mDecodedBodySize)) {
530 return false;
532 if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectCount)) {
533 return false;
535 if (!ReadIPDLParam(aReader, aActor, &aResult->mAllRedirectsSameOrigin)) {
536 return false;
538 if (!ReadIPDLParam(aReader, aActor, &aResult->mAllRedirectsPassTAO)) {
539 return false;
541 if (!ReadIPDLParam(aReader, aActor, &aResult->mSecureConnection)) {
542 return false;
544 if (!ReadIPDLParam(aReader, aActor, &aResult->mTimingAllowed)) {
545 return false;
547 if (!ReadIPDLParam(aReader, aActor, &aResult->mInitialized)) {
548 return false;
550 return true;
554 template <>
555 struct IPDLParamTraits<nsIServerTiming*> {
556 static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
557 nsIServerTiming* aParam) {
558 nsAutoCString name;
559 Unused << aParam->GetName(name);
560 double duration = 0;
561 Unused << aParam->GetDuration(&duration);
562 nsAutoCString description;
563 Unused << aParam->GetDescription(description);
564 WriteIPDLParam(aWriter, aActor, name);
565 WriteIPDLParam(aWriter, aActor, duration);
566 WriteIPDLParam(aWriter, aActor, description);
569 static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
570 RefPtr<nsIServerTiming>* aResult) {
571 nsAutoCString name;
572 double duration;
573 nsAutoCString description;
574 if (!ReadIPDLParam(aReader, aActor, &name)) {
575 return false;
577 if (!ReadIPDLParam(aReader, aActor, &duration)) {
578 return false;
580 if (!ReadIPDLParam(aReader, aActor, &description)) {
581 return false;
584 RefPtr<nsServerTiming> timing = new nsServerTiming();
585 timing->SetName(name);
586 timing->SetDuration(duration);
587 timing->SetDescription(description);
588 *aResult = timing.forget();
589 return true;
593 } // namespace mozilla::ipc
595 #endif // mozilla_dom_PerformanceTiming_h