1 | /* |
2 | * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include <wtf/Forward.h> |
29 | #include <wtf/MonotonicTime.h> |
30 | #include <wtf/WallTime.h> |
31 | |
32 | namespace WebCore { |
33 | |
34 | class LoadTiming { |
35 | public: |
36 | Seconds secondsSinceStartTime(MonotonicTime) const; |
37 | WallTime monotonicTimeToPseudoWallTime(MonotonicTime) const; |
38 | |
39 | void markStartTime(); |
40 | void addRedirect(const URL& redirectingUrl, const URL& redirectedUrl); |
41 | |
42 | void markStartTimeAndFetchStart() { markStartTime(); m_fetchStart = m_startTime; } |
43 | |
44 | void markUnloadEventStart() { m_unloadEventStart = MonotonicTime::now(); } |
45 | void markUnloadEventEnd() { m_unloadEventEnd = MonotonicTime::now(); } |
46 | void markRedirectStart() { m_redirectStart = MonotonicTime::now(); } |
47 | void markRedirectEnd() { m_redirectEnd = MonotonicTime::now(); } |
48 | void markFetchStart() { m_fetchStart = MonotonicTime::now(); } |
49 | void setResponseEnd(MonotonicTime time) { m_responseEnd = time; } |
50 | void markLoadEventStart() { m_loadEventStart = MonotonicTime::now(); } |
51 | void markLoadEventEnd() { m_loadEventEnd = MonotonicTime::now(); } |
52 | |
53 | void setHasSameOriginAsPreviousDocument(bool value) { m_hasSameOriginAsPreviousDocument = value; } |
54 | |
55 | MonotonicTime startTime() const { return m_startTime; } |
56 | MonotonicTime unloadEventStart() const { return m_unloadEventStart; } |
57 | MonotonicTime unloadEventEnd() const { return m_unloadEventEnd; } |
58 | MonotonicTime redirectStart() const { return m_redirectStart; } |
59 | MonotonicTime redirectEnd() const { return m_redirectEnd; } |
60 | MonotonicTime fetchStart() const { return m_fetchStart; } |
61 | MonotonicTime responseEnd() const { return m_responseEnd; } |
62 | MonotonicTime loadEventStart() const { return m_loadEventStart; } |
63 | MonotonicTime loadEventEnd() const { return m_loadEventEnd; } |
64 | short redirectCount() const { return m_redirectCount; } |
65 | bool hasCrossOriginRedirect() const { return m_hasCrossOriginRedirect; } |
66 | bool hasSameOriginAsPreviousDocument() const { return m_hasSameOriginAsPreviousDocument; } |
67 | |
68 | MonotonicTime referenceMonotonicTime() const { return m_referenceMonotonicTime; } |
69 | WallTime referenceWallTime() const { return m_referenceWallTime; } |
70 | |
71 | LoadTiming isolatedCopy() const; |
72 | |
73 | private: |
74 | WallTime m_referenceWallTime; |
75 | MonotonicTime m_referenceMonotonicTime; |
76 | MonotonicTime m_startTime; |
77 | MonotonicTime m_unloadEventStart; |
78 | MonotonicTime m_unloadEventEnd; |
79 | MonotonicTime m_redirectStart; |
80 | MonotonicTime m_redirectEnd; |
81 | MonotonicTime m_fetchStart; |
82 | MonotonicTime m_responseEnd; |
83 | MonotonicTime m_loadEventStart; |
84 | MonotonicTime m_loadEventEnd; |
85 | short m_redirectCount { 0 }; |
86 | bool m_hasCrossOriginRedirect { false }; |
87 | bool m_hasSameOriginAsPreviousDocument { false }; |
88 | }; |
89 | |
90 | } // namespace WebCore |
91 | |