Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / performance / PerformanceTiming.h
blobbc0de40ab44024759eee37c3b98574da3214954d
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
151 // If aEnsureSameOriginAndIgnoreTAO is false, it checks if all redirects pass
152 // TAO. When it is true, it checks if all redirects are same-origin and
153 // ignores the result of TAO.
154 bool ShouldReportCrossOriginRedirect(
155 bool aEnsureSameOriginAndIgnoreTAO) const;
157 // Cached result of CheckAllowedOrigin. If false, security sensitive
158 // attributes of the resourceTiming object will be set to 0
159 bool TimingAllowed() const { return mTimingAllowed; }
161 nsTArray<nsCOMPtr<nsIServerTiming>> GetServerTiming();
163 private:
164 // Checks if the resource is either same origin as the page that started
165 // the load, or if the response contains the Timing-Allow-Origin header
166 // with a value of * or matching the domain of the loading Principal
167 bool CheckAllowedOrigin(nsIHttpChannel* aResourceChannel,
168 nsITimedChannel* aChannel);
170 nsTArray<nsCOMPtr<nsIServerTiming>> mServerTiming;
171 nsString mNextHopProtocol;
173 TimeStamp mAsyncOpen;
174 TimeStamp mRedirectStart;
175 TimeStamp mRedirectEnd;
176 TimeStamp mDomainLookupStart;
177 TimeStamp mDomainLookupEnd;
178 TimeStamp mConnectStart;
179 TimeStamp mSecureConnectionStart;
180 TimeStamp mConnectEnd;
181 TimeStamp mRequestStart;
182 TimeStamp mResponseStart;
183 TimeStamp mCacheReadStart;
184 TimeStamp mResponseEnd;
185 TimeStamp mCacheReadEnd;
187 // ServiceWorker interception timing information
188 TimeStamp mWorkerStart;
189 TimeStamp mWorkerRequestStart;
190 TimeStamp mWorkerResponseEnd;
192 // This is an offset that will be added to each timing ([ms] resolution).
193 // There are only 2 possible values: (1) logicaly equal to navigationStart
194 // TimeStamp (results are absolute timstamps - wallclock); (2) "0" (results
195 // are relative to the navigation start).
196 DOMHighResTimeStamp mZeroTime = 0;
198 DOMHighResTimeStamp mFetchStart = 0;
200 uint64_t mEncodedBodySize = 0;
201 uint64_t mTransferSize = 0;
202 uint64_t mDecodedBodySize = 0;
204 uint8_t mRedirectCount = 0;
206 bool mAllRedirectsSameOrigin = false;
208 bool mAllRedirectsPassTAO = false;
210 bool mSecureConnection = false;
212 bool mTimingAllowed = false;
214 bool mInitialized = false;
217 // Script "performance.timing" object
218 class PerformanceTiming final : public nsWrapperCache {
219 public:
221 * @param aPerformance
222 * The performance object (the JS parent).
223 * This will allow access to "window.performance.timing" attribute
224 * for the navigation timing (can't be null).
225 * @param aChannel
226 * An nsITimedChannel used to gather all the networking timings by
227 * both the navigation timing and the resource timing (can't be null).
228 * @param aHttpChannel
229 * An nsIHttpChannel (the resource's http channel).
230 * This will be used by the resource timing cross-domain check
231 * algorithm.
232 * Argument is null for the navigation timing (navigation timing uses
233 * another algorithm for the cross-domain redirects).
234 * @param aZeroTime
235 * The offset that will be added to the timestamp of each event. This
236 * argument should be equal to performance.navigationStart for
237 * navigation timing and "0" for the resource timing.
239 PerformanceTiming(Performance* aPerformance, nsITimedChannel* aChannel,
240 nsIHttpChannel* aHttpChannel,
241 DOMHighResTimeStamp aZeroTime);
242 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PerformanceTiming)
243 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PerformanceTiming)
245 nsDOMNavigationTiming* GetDOMTiming() const {
246 return mPerformance->GetDOMTiming();
249 Performance* GetParentObject() const { return mPerformance; }
251 virtual JSObject* WrapObject(JSContext* cx,
252 JS::Handle<JSObject*> aGivenProto) override;
254 // PerformanceNavigation WebIDL methods
255 DOMTimeMilliSec NavigationStart() const {
256 if (!StaticPrefs::dom_enable_performance()) {
257 return 0;
259 return nsRFPService::ReduceTimePrecisionAsMSecs(
260 GetDOMTiming()->GetNavigationStart(),
261 mPerformance->GetRandomTimelineSeed(),
262 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
265 DOMTimeMilliSec UnloadEventStart() {
266 if (!StaticPrefs::dom_enable_performance()) {
267 return 0;
269 return nsRFPService::ReduceTimePrecisionAsMSecs(
270 GetDOMTiming()->GetUnloadEventStart(),
271 mPerformance->GetRandomTimelineSeed(),
272 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
275 DOMTimeMilliSec UnloadEventEnd() {
276 if (!StaticPrefs::dom_enable_performance()) {
277 return 0;
279 return nsRFPService::ReduceTimePrecisionAsMSecs(
280 GetDOMTiming()->GetUnloadEventEnd(),
281 mPerformance->GetRandomTimelineSeed(),
282 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
285 // Low resolution (used by navigation timing)
286 DOMTimeMilliSec FetchStart();
287 DOMTimeMilliSec RedirectStart();
288 DOMTimeMilliSec RedirectEnd();
289 DOMTimeMilliSec DomainLookupStart();
290 DOMTimeMilliSec DomainLookupEnd();
291 DOMTimeMilliSec ConnectStart();
292 DOMTimeMilliSec SecureConnectionStart();
293 DOMTimeMilliSec ConnectEnd();
294 DOMTimeMilliSec RequestStart();
295 DOMTimeMilliSec ResponseStart();
296 DOMTimeMilliSec ResponseEnd();
298 DOMTimeMilliSec DomLoading() {
299 if (!StaticPrefs::dom_enable_performance()) {
300 return 0;
302 return nsRFPService::ReduceTimePrecisionAsMSecs(
303 GetDOMTiming()->GetDomLoading(), mPerformance->GetRandomTimelineSeed(),
304 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
307 DOMTimeMilliSec DomInteractive() const {
308 if (!StaticPrefs::dom_enable_performance()) {
309 return 0;
311 return nsRFPService::ReduceTimePrecisionAsMSecs(
312 GetDOMTiming()->GetDomInteractive(),
313 mPerformance->GetRandomTimelineSeed(),
314 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
317 DOMTimeMilliSec DomContentLoadedEventStart() const {
318 if (!StaticPrefs::dom_enable_performance()) {
319 return 0;
321 return nsRFPService::ReduceTimePrecisionAsMSecs(
322 GetDOMTiming()->GetDomContentLoadedEventStart(),
323 mPerformance->GetRandomTimelineSeed(),
324 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
327 DOMTimeMilliSec DomContentLoadedEventEnd() const {
328 if (!StaticPrefs::dom_enable_performance()) {
329 return 0;
331 return nsRFPService::ReduceTimePrecisionAsMSecs(
332 GetDOMTiming()->GetDomContentLoadedEventEnd(),
333 mPerformance->GetRandomTimelineSeed(),
334 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
337 DOMTimeMilliSec DomComplete() const {
338 if (!StaticPrefs::dom_enable_performance()) {
339 return 0;
341 return nsRFPService::ReduceTimePrecisionAsMSecs(
342 GetDOMTiming()->GetDomComplete(), mPerformance->GetRandomTimelineSeed(),
343 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
346 DOMTimeMilliSec LoadEventStart() const {
347 if (!StaticPrefs::dom_enable_performance()) {
348 return 0;
350 return nsRFPService::ReduceTimePrecisionAsMSecs(
351 GetDOMTiming()->GetLoadEventStart(),
352 mPerformance->GetRandomTimelineSeed(),
353 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
356 DOMTimeMilliSec LoadEventEnd() const {
357 if (!StaticPrefs::dom_enable_performance()) {
358 return 0;
360 return nsRFPService::ReduceTimePrecisionAsMSecs(
361 GetDOMTiming()->GetLoadEventEnd(),
362 mPerformance->GetRandomTimelineSeed(),
363 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
366 DOMTimeMilliSec TimeToNonBlankPaint() const {
367 if (!StaticPrefs::dom_enable_performance()) {
368 return 0;
370 return nsRFPService::ReduceTimePrecisionAsMSecs(
371 GetDOMTiming()->GetTimeToNonBlankPaint(),
372 mPerformance->GetRandomTimelineSeed(),
373 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
376 DOMTimeMilliSec TimeToContentfulPaint() const {
377 if (!StaticPrefs::dom_enable_performance()) {
378 return 0;
380 return nsRFPService::ReduceTimePrecisionAsMSecs(
381 GetDOMTiming()->GetTimeToContentfulComposite(),
382 mPerformance->GetRandomTimelineSeed(),
383 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
386 DOMTimeMilliSec TimeToDOMContentFlushed() const {
387 if (!StaticPrefs::dom_enable_performance()) {
388 return 0;
390 return nsRFPService::ReduceTimePrecisionAsMSecs(
391 GetDOMTiming()->GetTimeToDOMContentFlushed(),
392 mPerformance->GetRandomTimelineSeed(),
393 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
396 DOMTimeMilliSec TimeToFirstInteractive() const {
397 if (!StaticPrefs::dom_enable_performance()) {
398 return 0;
400 return nsRFPService::ReduceTimePrecisionAsMSecs(
401 GetDOMTiming()->GetTimeToTTFI(), mPerformance->GetRandomTimelineSeed(),
402 mPerformance->IsSystemPrincipal(), mPerformance->CrossOriginIsolated());
405 PerformanceTimingData* Data() const { return mTimingData.get(); }
407 private:
408 ~PerformanceTiming();
410 bool IsTopLevelContentDocument() const;
412 RefPtr<Performance> mPerformance;
414 UniquePtr<PerformanceTimingData> mTimingData;
417 } // namespace dom
418 } // namespace mozilla
420 namespace mozilla {
421 namespace ipc {
423 template <>
424 struct IPDLParamTraits<mozilla::dom::PerformanceTimingData> {
425 using paramType = mozilla::dom::PerformanceTimingData;
426 static void Write(IPC::Message* aMsg, IProtocol* aActor,
427 const paramType& aParam) {
428 WriteIPDLParam(aMsg, aActor, aParam.mServerTiming);
429 WriteIPDLParam(aMsg, aActor, aParam.mNextHopProtocol);
430 WriteIPDLParam(aMsg, aActor, aParam.mAsyncOpen);
431 WriteIPDLParam(aMsg, aActor, aParam.mRedirectStart);
432 WriteIPDLParam(aMsg, aActor, aParam.mRedirectEnd);
433 WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupStart);
434 WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupEnd);
435 WriteIPDLParam(aMsg, aActor, aParam.mConnectStart);
436 WriteIPDLParam(aMsg, aActor, aParam.mSecureConnectionStart);
437 WriteIPDLParam(aMsg, aActor, aParam.mConnectEnd);
438 WriteIPDLParam(aMsg, aActor, aParam.mRequestStart);
439 WriteIPDLParam(aMsg, aActor, aParam.mResponseStart);
440 WriteIPDLParam(aMsg, aActor, aParam.mCacheReadStart);
441 WriteIPDLParam(aMsg, aActor, aParam.mResponseEnd);
442 WriteIPDLParam(aMsg, aActor, aParam.mCacheReadEnd);
443 WriteIPDLParam(aMsg, aActor, aParam.mWorkerStart);
444 WriteIPDLParam(aMsg, aActor, aParam.mWorkerRequestStart);
445 WriteIPDLParam(aMsg, aActor, aParam.mWorkerResponseEnd);
446 WriteIPDLParam(aMsg, aActor, aParam.mZeroTime);
447 WriteIPDLParam(aMsg, aActor, aParam.mFetchStart);
448 WriteIPDLParam(aMsg, aActor, aParam.mEncodedBodySize);
449 WriteIPDLParam(aMsg, aActor, aParam.mTransferSize);
450 WriteIPDLParam(aMsg, aActor, aParam.mDecodedBodySize);
451 WriteIPDLParam(aMsg, aActor, aParam.mRedirectCount);
452 WriteIPDLParam(aMsg, aActor, aParam.mAllRedirectsSameOrigin);
453 WriteIPDLParam(aMsg, aActor, aParam.mAllRedirectsPassTAO);
454 WriteIPDLParam(aMsg, aActor, aParam.mSecureConnection);
455 WriteIPDLParam(aMsg, aActor, aParam.mTimingAllowed);
456 WriteIPDLParam(aMsg, aActor, aParam.mInitialized);
459 static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
460 IProtocol* aActor, paramType* aResult) {
461 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mServerTiming)) {
462 return false;
464 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mNextHopProtocol)) {
465 return false;
467 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mAsyncOpen)) {
468 return false;
470 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectStart)) {
471 return false;
473 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectEnd)) {
474 return false;
476 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupStart)) {
477 return false;
479 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupEnd)) {
480 return false;
482 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectStart)) {
483 return false;
485 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnectionStart)) {
486 return false;
488 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectEnd)) {
489 return false;
491 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRequestStart)) {
492 return false;
494 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseStart)) {
495 return false;
497 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadStart)) {
498 return false;
500 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseEnd)) {
501 return false;
503 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadEnd)) {
504 return false;
506 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerStart)) {
507 return false;
509 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerRequestStart)) {
510 return false;
512 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerResponseEnd)) {
513 return false;
515 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mZeroTime)) {
516 return false;
518 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mFetchStart)) {
519 return false;
521 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mEncodedBodySize)) {
522 return false;
524 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTransferSize)) {
525 return false;
527 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDecodedBodySize)) {
528 return false;
530 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectCount)) {
531 return false;
533 if (!ReadIPDLParam(aMsg, aIter, aActor,
534 &aResult->mAllRedirectsSameOrigin)) {
535 return false;
537 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mAllRedirectsPassTAO)) {
538 return false;
540 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnection)) {
541 return false;
543 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTimingAllowed)) {
544 return false;
546 if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mInitialized)) {
547 return false;
549 return true;
553 template <>
554 struct IPDLParamTraits<nsCOMPtr<nsIServerTiming>> {
555 using paramType = nsCOMPtr<nsIServerTiming>;
556 static void Write(IPC::Message* aMsg, IProtocol* aActor,
557 const paramType& 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(aMsg, aActor, name);
565 WriteIPDLParam(aMsg, aActor, duration);
566 WriteIPDLParam(aMsg, aActor, description);
569 static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
570 IProtocol* aActor, paramType* aResult) {
571 nsAutoCString name;
572 double duration;
573 nsAutoCString description;
574 if (!ReadIPDLParam(aMsg, aIter, aActor, &name)) {
575 return false;
577 if (!ReadIPDLParam(aMsg, aIter, aActor, &duration)) {
578 return false;
580 if (!ReadIPDLParam(aMsg, aIter, 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;
589 return true;
593 } // namespace ipc
594 } // namespace mozilla
596 #endif // mozilla_dom_PerformanceTiming_h