Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import...
[gecko.git] / dom / performance / PerformanceTiming.h
blob4f832cca78ccba0c4f2c0ea30e8b99fa77e636ca
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/ipc/IPDLParamTraits.h"
20 #include "ipc/IPCMessageUtils.h"
21 #include "ipc/IPCMessageUtilsSpecializations.h"
22 #include "mozilla/net/nsServerTiming.h"
24 class nsIHttpChannel;
26 namespace mozilla {
27 namespace 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 void SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
49 nsITimedChannel* aChannel);
51 bool IsInitialized() const { return mInitialized; }
53 const nsString& NextHopProtocol() const { return mNextHopProtocol; }
55 uint64_t TransferSize() const { return mTransferSize; }
57 uint64_t EncodedBodySize() const { return mEncodedBodySize; }
59 uint64_t DecodedBodySize() const { return mDecodedBodySize; }
61 /**
62 * @param aStamp
63 * The TimeStamp recorded for a specific event. This TimeStamp can
64 * be null.
65 * @return the duration of an event with a given TimeStamp, relative to the
66 * navigationStart TimeStamp (the moment the user landed on the
67 * page), if the given TimeStamp is valid. Otherwise, it will return
68 * the FetchStart timing value.
70 inline DOMHighResTimeStamp TimeStampToReducedDOMHighResOrFetchStart(
71 Performance* aPerformance, TimeStamp aStamp) {
72 MOZ_ASSERT(aPerformance);
74 if (aStamp.IsNull()) {
75 return FetchStartHighRes(aPerformance);
78 DOMHighResTimeStamp rawTimestamp =
79 TimeStampToDOMHighRes(aPerformance, aStamp);
81 return nsRFPService::ReduceTimePrecisionAsMSecs(
82 rawTimestamp, aPerformance->GetRandomTimelineSeed(),
83 aPerformance->IsSystemPrincipal(), aPerformance->CrossOriginIsolated());
86 /**
87 * The nsITimedChannel records an absolute timestamp for each event.
88 * The nsDOMNavigationTiming will record the moment when the user landed on
89 * the page. This is a window.performance unique timestamp, so it can be used
90 * for all the events (navigation timing and resource timing events).
92 * The algorithm operates in 2 steps:
93 * 1. The first step is to subtract the two timestamps: the argument (the
94 * event's timestamp) and the navigation start timestamp. This will result in
95 * a relative timestamp of the event (relative to the navigation start -
96 * window.performance.timing.navigationStart).
97 * 2. The second step is to add any required offset (the mZeroTime). For now,
98 * this offset value is either 0 (for the resource timing), or equal to
99 * "performance.navigationStart" (for navigation timing).
100 * For the resource timing, mZeroTime is set to 0, causing the result to be a
101 * relative time.
102 * For the navigation timing, mZeroTime is set to
103 * "performance.navigationStart" causing the result be an absolute time.
105 * @param aStamp
106 * The TimeStamp recorded for a specific event. This TimeStamp can't
107 * be null.
108 * @return number of milliseconds value as one of:
109 * - relative to the navigation start time, time the user has landed on the
110 * page
111 * - an absolute wall clock time since the unix epoch
113 inline DOMHighResTimeStamp TimeStampToDOMHighRes(Performance* aPerformance,
114 TimeStamp aStamp) const {
115 MOZ_ASSERT(aPerformance);
116 MOZ_ASSERT(!aStamp.IsNull());
118 TimeDuration duration = aStamp - aPerformance->CreationTimeStamp();
119 return duration.ToMilliseconds() + mZeroTime;
122 // The last channel's AsyncOpen time. This may occur before the FetchStart
123 // in some cases.
124 DOMHighResTimeStamp AsyncOpenHighRes(Performance* aPerformance);
126 // High resolution (used by resource timing)
127 DOMHighResTimeStamp WorkerStartHighRes(Performance* aPerformance);
128 DOMHighResTimeStamp FetchStartHighRes(Performance* aPerformance);
129 DOMHighResTimeStamp RedirectStartHighRes(Performance* aPerformance);
130 DOMHighResTimeStamp RedirectEndHighRes(Performance* aPerformance);
131 DOMHighResTimeStamp DomainLookupStartHighRes(Performance* aPerformance);
132 DOMHighResTimeStamp DomainLookupEndHighRes(Performance* aPerformance);
133 DOMHighResTimeStamp ConnectStartHighRes(Performance* aPerformance);
134 DOMHighResTimeStamp SecureConnectionStartHighRes(Performance* aPerformance);
135 DOMHighResTimeStamp ConnectEndHighRes(Performance* aPerformance);
136 DOMHighResTimeStamp RequestStartHighRes(Performance* aPerformance);
137 DOMHighResTimeStamp ResponseStartHighRes(Performance* aPerformance);
138 DOMHighResTimeStamp ResponseEndHighRes(Performance* aPerformance);
140 DOMHighResTimeStamp ZeroTime() const { return mZeroTime; }
142 uint8_t RedirectCountReal() const { return mRedirectCount; }
143 uint8_t GetRedirectCount() const;
145 bool AllRedirectsSameOrigin() const { return mAllRedirectsSameOrigin; }
147 // If this is false the values of redirectStart/End will be 0 This is false if
148 // no redirects occured, or if any of the responses failed the
149 // timing-allow-origin check in HttpBaseChannel::TimingAllowCheck
150 bool ShouldReportCrossOriginRedirect() const;
152 // Cached result of CheckAllowedOrigin. If false, security sensitive
153 // attributes of the resourceTiming object will be set to 0
154 bool TimingAllowed() const { return mTimingAllowed; }
156 nsTArray<nsCOMPtr<nsIServerTiming>> GetServerTiming();
158 private:
159 // Checks if the resource is either same origin as the page that started
160 // the load, or if the response contains the Timing-Allow-Origin header
161 // with a value of * or matching the domain of the loading Principal
162 bool CheckAllowedOrigin(nsIHttpChannel* aResourceChannel,
163 nsITimedChannel* aChannel);
165 nsTArray<nsCOMPtr<nsIServerTiming>> mServerTiming;
166 nsString mNextHopProtocol;
168 TimeStamp mAsyncOpen;
169 TimeStamp mRedirectStart;
170 TimeStamp mRedirectEnd;
171 TimeStamp mDomainLookupStart;
172 TimeStamp mDomainLookupEnd;
173 TimeStamp mConnectStart;
174 TimeStamp mSecureConnectionStart;
175 TimeStamp mConnectEnd;
176 TimeStamp mRequestStart;
177 TimeStamp mResponseStart;
178 TimeStamp mCacheReadStart;
179 TimeStamp mResponseEnd;
180 TimeStamp mCacheReadEnd;
182 // ServiceWorker interception timing information
183 TimeStamp mWorkerStart;
184 TimeStamp mWorkerRequestStart;
185 TimeStamp mWorkerResponseEnd;
187 // This is an offset that will be added to each timing ([ms] resolution).
188 // There are only 2 possible values: (1) logicaly equal to navigationStart
189 // TimeStamp (results are absolute timstamps - wallclock); (2) "0" (results
190 // are relative to the navigation start).
191 DOMHighResTimeStamp mZeroTime = 0;
193 DOMHighResTimeStamp mFetchStart = 0;
195 uint64_t mEncodedBodySize = 0;
196 uint64_t mTransferSize = 0;
197 uint64_t mDecodedBodySize = 0;
199 uint8_t mRedirectCount = 0;
201 bool mAllRedirectsSameOrigin = false;
203 // If the resourceTiming object should have non-zero redirectStart and
204 // redirectEnd attributes. It is false if there were no redirects, or if any
205 // of the responses didn't pass the timing-allow-check
206 bool mReportCrossOriginRedirect = false;
208 bool mSecureConnection = false;
210 bool mTimingAllowed = false;
212 bool mInitialized = false;
215 // Script "performance.timing" object
216 class PerformanceTiming final : public nsWrapperCache {
217 public:
219 * @param aPerformance
220 * The performance object (the JS parent).
221 * This will allow access to "window.performance.timing" attribute
222 * for the navigation timing (can't be null).
223 * @param aChannel
224 * An nsITimedChannel used to gather all the networking timings by
225 * both the navigation timing and the resource timing (can't be null).
226 * @param aHttpChannel
227 * An nsIHttpChannel (the resource's http channel).
228 * This will be used by the resource timing cross-domain check
229 * algorithm.
230 * Argument is null for the navigation timing (navigation timing uses
231 * another algorithm for the cross-domain redirects).
232 * @param aZeroTime
233 * The offset that will be added to the timestamp of each event. This
234 * argument should be equal to performance.navigationStart for
235 * navigation timing and "0" for the resource timing.
237 PerformanceTiming(Performance* aPerformance, nsITimedChannel* aChannel,
238 nsIHttpChannel* aHttpChannel,
239 DOMHighResTimeStamp aZeroTime);
240 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PerformanceTiming)
241 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PerformanceTiming)
243 nsDOMNavigationTiming* GetDOMTiming() const {
244 return mPerformance->GetDOMTiming();
247 Performance* GetParentObject() const { return mPerformance; }
249 virtual JSObject* WrapObject(JSContext* cx,
250 JS::Handle<JSObject*> aGivenProto) override;
252 // PerformanceNavigation WebIDL methods
253 DOMTimeMilliSec NavigationStart() const {
254 if (!StaticPrefs::dom_enable_performance()) {
255 return 0;
257 return nsRFPService::ReduceTimePrecisionAsMSecs(
258 GetDOMTiming()->GetNavigationStart(),
259 mPerformance->GetRandomTimelineSeed(),
260 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
263 DOMTimeMilliSec UnloadEventStart() {
264 if (!StaticPrefs::dom_enable_performance()) {
265 return 0;
267 return nsRFPService::ReduceTimePrecisionAsMSecs(
268 GetDOMTiming()->GetUnloadEventStart(),
269 mPerformance->GetRandomTimelineSeed(),
270 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
273 DOMTimeMilliSec UnloadEventEnd() {
274 if (!StaticPrefs::dom_enable_performance()) {
275 return 0;
277 return nsRFPService::ReduceTimePrecisionAsMSecs(
278 GetDOMTiming()->GetUnloadEventEnd(),
279 mPerformance->GetRandomTimelineSeed(),
280 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
283 // Low resolution (used by navigation timing)
284 DOMTimeMilliSec FetchStart();
285 DOMTimeMilliSec RedirectStart();
286 DOMTimeMilliSec RedirectEnd();
287 DOMTimeMilliSec DomainLookupStart();
288 DOMTimeMilliSec DomainLookupEnd();
289 DOMTimeMilliSec ConnectStart();
290 DOMTimeMilliSec SecureConnectionStart();
291 DOMTimeMilliSec ConnectEnd();
292 DOMTimeMilliSec RequestStart();
293 DOMTimeMilliSec ResponseStart();
294 DOMTimeMilliSec ResponseEnd();
296 DOMTimeMilliSec DomLoading() {
297 if (!StaticPrefs::dom_enable_performance()) {
298 return 0;
300 return nsRFPService::ReduceTimePrecisionAsMSecs(
301 GetDOMTiming()->GetDomLoading(), mPerformance->GetRandomTimelineSeed(),
302 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
305 DOMTimeMilliSec DomInteractive() const {
306 if (!StaticPrefs::dom_enable_performance()) {
307 return 0;
309 return nsRFPService::ReduceTimePrecisionAsMSecs(
310 GetDOMTiming()->GetDomInteractive(),
311 mPerformance->GetRandomTimelineSeed(),
312 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
315 DOMTimeMilliSec DomContentLoadedEventStart() const {
316 if (!StaticPrefs::dom_enable_performance()) {
317 return 0;
319 return nsRFPService::ReduceTimePrecisionAsMSecs(
320 GetDOMTiming()->GetDomContentLoadedEventStart(),
321 mPerformance->GetRandomTimelineSeed(),
322 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
325 DOMTimeMilliSec DomContentLoadedEventEnd() const {
326 if (!StaticPrefs::dom_enable_performance()) {
327 return 0;
329 return nsRFPService::ReduceTimePrecisionAsMSecs(
330 GetDOMTiming()->GetDomContentLoadedEventEnd(),
331 mPerformance->GetRandomTimelineSeed(),
332 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
335 DOMTimeMilliSec DomComplete() const {
336 if (!StaticPrefs::dom_enable_performance()) {
337 return 0;
339 return nsRFPService::ReduceTimePrecisionAsMSecs(
340 GetDOMTiming()->GetDomComplete(), mPerformance->GetRandomTimelineSeed(),
341 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
344 DOMTimeMilliSec LoadEventStart() const {
345 if (!StaticPrefs::dom_enable_performance()) {
346 return 0;
348 return nsRFPService::ReduceTimePrecisionAsMSecs(
349 GetDOMTiming()->GetLoadEventStart(),
350 mPerformance->GetRandomTimelineSeed(),
351 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
354 DOMTimeMilliSec LoadEventEnd() const {
355 if (!StaticPrefs::dom_enable_performance()) {
356 return 0;
358 return nsRFPService::ReduceTimePrecisionAsMSecs(
359 GetDOMTiming()->GetLoadEventEnd(),
360 mPerformance->GetRandomTimelineSeed(),
361 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
364 DOMTimeMilliSec TimeToNonBlankPaint() const {
365 if (!StaticPrefs::dom_enable_performance()) {
366 return 0;
368 return nsRFPService::ReduceTimePrecisionAsMSecs(
369 GetDOMTiming()->GetTimeToNonBlankPaint(),
370 mPerformance->GetRandomTimelineSeed(),
371 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
374 DOMTimeMilliSec TimeToContentfulPaint() const {
375 if (!StaticPrefs::dom_enable_performance()) {
376 return 0;
378 return nsRFPService::ReduceTimePrecisionAsMSecs(
379 GetDOMTiming()->GetTimeToContentfulPaint(),
380 mPerformance->GetRandomTimelineSeed(),
381 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
384 DOMTimeMilliSec TimeToDOMContentFlushed() const {
385 if (!StaticPrefs::dom_enable_performance()) {
386 return 0;
388 return nsRFPService::ReduceTimePrecisionAsMSecs(
389 GetDOMTiming()->GetTimeToDOMContentFlushed(),
390 mPerformance->GetRandomTimelineSeed(),
391 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
394 DOMTimeMilliSec TimeToFirstInteractive() const {
395 if (!StaticPrefs::dom_enable_performance()) {
396 return 0;
398 return nsRFPService::ReduceTimePrecisionAsMSecs(
399 GetDOMTiming()->GetTimeToTTFI(), mPerformance->GetRandomTimelineSeed(),
400 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
403 PerformanceTimingData* Data() const { return mTimingData.get(); }
405 private:
406 ~PerformanceTiming();
408 bool IsTopLevelContentDocument() const;
410 RefPtr<Performance> mPerformance;
412 UniquePtr<PerformanceTimingData> mTimingData;
415 } // namespace dom
416 } // namespace mozilla
418 namespace mozilla {
419 namespace ipc {
421 template <>
422 struct IPDLParamTraits<mozilla::dom::PerformanceTimingData> {
423 typedef mozilla::dom::PerformanceTimingData paramType;
424 static void Write(IPC::Message* aMsg, IProtocol* aActor,
425 const paramType& aParam) {
426 WriteIPDLParam(aMsg, aActor, aParam.mServerTiming);
427 WriteIPDLParam(aMsg, aActor, aParam.mNextHopProtocol);
428 WriteIPDLParam(aMsg, aActor, aParam.mAsyncOpen);
429 WriteIPDLParam(aMsg, aActor, aParam.mRedirectStart);
430 WriteIPDLParam(aMsg, aActor, aParam.mRedirectEnd);
431 WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupStart);
432 WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupEnd);
433 WriteIPDLParam(aMsg, aActor, aParam.mConnectStart);
434 WriteIPDLParam(aMsg, aActor, aParam.mSecureConnectionStart);
435 WriteIPDLParam(aMsg, aActor, aParam.mConnectEnd);
436 WriteIPDLParam(aMsg, aActor, aParam.mRequestStart);
437 WriteIPDLParam(aMsg, aActor, aParam.mResponseStart);
438 WriteIPDLParam(aMsg, aActor, aParam.mCacheReadStart);
439 WriteIPDLParam(aMsg, aActor, aParam.mResponseEnd);
440 WriteIPDLParam(aMsg, aActor, aParam.mCacheReadEnd);
441 WriteIPDLParam(aMsg, aActor, aParam.mWorkerStart);
442 WriteIPDLParam(aMsg, aActor, aParam.mWorkerRequestStart);
443 WriteIPDLParam(aMsg, aActor, aParam.mWorkerResponseEnd);
444 WriteIPDLParam(aMsg, aActor, aParam.mZeroTime);
445 WriteIPDLParam(aMsg, aActor, aParam.mFetchStart);
446 WriteIPDLParam(aMsg, aActor, aParam.mEncodedBodySize);
447 WriteIPDLParam(aMsg, aActor, aParam.mTransferSize);
448 WriteIPDLParam(aMsg, aActor, aParam.mDecodedBodySize);
449 WriteIPDLParam(aMsg, aActor, aParam.mRedirectCount);
450 WriteIPDLParam(aMsg, aActor, aParam.mAllRedirectsSameOrigin);
451 WriteIPDLParam(aMsg, aActor, aParam.mReportCrossOriginRedirect);
452 WriteIPDLParam(aMsg, aActor, aParam.mSecureConnection);
453 WriteIPDLParam(aMsg, aActor, aParam.mTimingAllowed);
454 WriteIPDLParam(aMsg, aActor, aParam.mInitialized);
457 static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
458 IProtocol* aActor, paramType* aResult) {
459 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mServerTiming)) {
460 return false;
462 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mNextHopProtocol)) {
463 return false;
465 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mAsyncOpen)) {
466 return false;
468 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectStart)) {
469 return false;
471 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectEnd)) {
472 return false;
474 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupStart)) {
475 return false;
477 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupEnd)) {
478 return false;
480 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectStart)) {
481 return false;
483 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnectionStart)) {
484 return false;
486 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectEnd)) {
487 return false;
489 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRequestStart)) {
490 return false;
492 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseStart)) {
493 return false;
495 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadStart)) {
496 return false;
498 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseEnd)) {
499 return false;
501 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadEnd)) {
502 return false;
504 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerStart)) {
505 return false;
507 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerRequestStart)) {
508 return false;
510 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerResponseEnd)) {
511 return false;
513 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mZeroTime)) {
514 return false;
516 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mFetchStart)) {
517 return false;
519 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mEncodedBodySize)) {
520 return false;
522 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTransferSize)) {
523 return false;
525 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDecodedBodySize)) {
526 return false;
528 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectCount)) {
529 return false;
531 if (!ReadIPDLParam(aMsg, aIter, aActor,
532 &aResult->mAllRedirectsSameOrigin)) {
533 return false;
535 if (!ReadIPDLParam(aMsg, aIter, aActor,
536 &aResult->mReportCrossOriginRedirect)) {
537 return false;
539 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnection)) {
540 return false;
542 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTimingAllowed)) {
543 return false;
545 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mInitialized)) {
546 return false;
548 return true;
552 template <>
553 struct IPDLParamTraits<nsCOMPtr<nsIServerTiming>> {
554 typedef nsCOMPtr<nsIServerTiming> paramType;
555 static void Write(IPC::Message* aMsg, IProtocol* aActor,
556 const paramType& aParam) {
557 nsAutoCString name;
558 Unused << aParam->GetName(name);
559 double duration = 0;
560 Unused << aParam->GetDuration(&duration);
561 nsAutoCString description;
562 Unused << aParam->GetDescription(description);
563 WriteIPDLParam(aMsg, aActor, name);
564 WriteIPDLParam(aMsg, aActor, duration);
565 WriteIPDLParam(aMsg, aActor, description);
568 static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
569 IProtocol* aActor, paramType* aResult) {
570 nsAutoCString name;
571 double duration;
572 nsAutoCString description;
573 if (!ReadIPDLParam(aMsg, aIter, aActor, &name)) {
574 return false;
576 if (!ReadIPDLParam(aMsg, aIter, aActor, &duration)) {
577 return false;
579 if (!ReadIPDLParam(aMsg, aIter, aActor, &description)) {
580 return false;
583 RefPtr<nsServerTiming> timing = new nsServerTiming();
584 timing->SetName(name);
585 timing->SetDuration(duration);
586 timing->SetDescription(description);
587 *aResult = timing;
588 return true;
592 } // namespace ipc
593 } // namespace mozilla
595 #endif // mozilla_dom_PerformanceTiming_h