1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "nsISupports.idl"
6interface nsIArray;
7interface nsIPrincipal;
8%{C++
9namespace mozilla {
10class TimeStamp;
11}
12#include "nsTArrayForwardDeclare.h"
13#include "nsCOMPtr.h"
14%}
15
16native TimeStamp(mozilla::TimeStamp);
17
18[scriptable, uuid(c2d9e95b-9cc9-4f47-9ef6-1de0cf7ebc75)]
19interface nsIServerTiming : nsISupports {
20  [must_use] readonly attribute ACString name;
21  [must_use] readonly attribute double duration;
22  [must_use] readonly attribute ACString description;
23};
24
25[ref] native nsServerTimingArrayRef(nsTArray<nsCOMPtr<nsIServerTiming>>);
26
27// All properties return zero if the value is not available
28[scriptable, uuid(ca63784d-959c-4c3a-9a59-234a2a520de0)]
29interface nsITimedChannel : nsISupports {
30  // Set this attribute to true to enable collection of timing data.
31  // channelCreationTime will be available even with this attribute set to
32  // false.
33  attribute boolean timingEnabled;
34
35  // The number of redirects
36  attribute uint8_t redirectCount;
37  attribute uint8_t internalRedirectCount;
38
39  // These properties should only be written externally when they must be
40  // propagated across an internal redirect.  For example, when a service
41  // worker interception falls back to network we need to copy the original
42  // timing values to the new nsHttpChannel.
43  [noscript] attribute TimeStamp channelCreation;
44  [noscript] attribute TimeStamp asyncOpen;
45
46  // The following are only set when the request is intercepted by a service
47  // worker no matter the response is synthesized.
48  [noscript] attribute TimeStamp launchServiceWorkerStart;
49  [noscript] attribute TimeStamp launchServiceWorkerEnd;
50  [noscript] attribute TimeStamp dispatchFetchEventStart;
51  [noscript] attribute TimeStamp dispatchFetchEventEnd;
52  [noscript] attribute TimeStamp handleFetchEventStart;
53  [noscript] attribute TimeStamp handleFetchEventEnd;
54
55  // The following are only set when the document is not (only) read from the
56  // cache
57  [noscript] readonly attribute TimeStamp domainLookupStart;
58  [noscript] readonly attribute TimeStamp domainLookupEnd;
59  [noscript] readonly attribute TimeStamp connectStart;
60  [noscript] readonly attribute TimeStamp tcpConnectEnd;
61  [noscript] readonly attribute TimeStamp secureConnectionStart;
62  [noscript] readonly attribute TimeStamp connectEnd;
63  [noscript] readonly attribute TimeStamp requestStart;
64  [noscript] readonly attribute TimeStamp responseStart;
65  [noscript] readonly attribute TimeStamp responseEnd;
66
67  // The redirect attributes timings must be writeble, se we can transfer
68  // the data from one channel to the redirected channel.
69  [noscript] attribute TimeStamp redirectStart;
70  [noscript] attribute TimeStamp redirectEnd;
71
72  // The initiator type
73  [noscript] attribute AString initiatorType;
74
75  // This flag should be set to false only if a cross-domain redirect occurred
76  [noscript] attribute boolean allRedirectsSameOrigin;
77  // This flag is set to false if the timing allow check fails
78  [noscript] attribute boolean allRedirectsPassTimingAllowCheck;
79  // Implements the timing-allow-check to determine if we should report
80  // timing info for the resourceTiming object.
81  [noscript] boolean timingAllowCheck(in nsIPrincipal origin);
82  %{C++
83  inline bool TimingAllowCheck(nsIPrincipal* aOrigin) {
84    bool allowed = false;
85    return NS_SUCCEEDED(TimingAllowCheck(aOrigin, &allowed)) && allowed;
86  }
87  %}
88
89  // The following are only set if the document is (partially) read from the
90  // cache
91  [noscript] readonly attribute TimeStamp cacheReadStart;
92  [noscript] readonly attribute TimeStamp cacheReadEnd;
93
94  // All following are PRTime versions of the above.
95  readonly attribute PRTime channelCreationTime;
96  readonly attribute PRTime asyncOpenTime;
97  readonly attribute PRTime launchServiceWorkerStartTime;
98  readonly attribute PRTime launchServiceWorkerEndTime;
99  readonly attribute PRTime dispatchFetchEventStartTime;
100  readonly attribute PRTime dispatchFetchEventEndTime;
101  readonly attribute PRTime handleFetchEventStartTime;
102  readonly attribute PRTime handleFetchEventEndTime;
103  readonly attribute PRTime domainLookupStartTime;
104  readonly attribute PRTime domainLookupEndTime;
105  readonly attribute PRTime connectStartTime;
106  readonly attribute PRTime tcpConnectEndTime;
107  readonly attribute PRTime secureConnectionStartTime;
108  readonly attribute PRTime connectEndTime;
109  readonly attribute PRTime requestStartTime;
110  readonly attribute PRTime responseStartTime;
111  readonly attribute PRTime responseEndTime;
112  readonly attribute PRTime cacheReadStartTime;
113  readonly attribute PRTime cacheReadEndTime;
114  readonly attribute PRTime redirectStartTime;
115  readonly attribute PRTime redirectEndTime;
116
117  // If this attribute is false, this resource MUST NOT be reported in resource timing.
118  [noscript] attribute boolean reportResourceTiming;
119
120  readonly attribute nsIArray serverTiming;
121  nsServerTimingArrayRef getNativeServerTiming();
122};
123