OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 double DocumentLoadTiming::pseudoWallTimeToMonotonicTime(double pseudoWallTime)
const | 81 double DocumentLoadTiming::pseudoWallTimeToMonotonicTime(double pseudoWallTime)
const |
82 { | 82 { |
83 if (!pseudoWallTime) | 83 if (!pseudoWallTime) |
84 return 0.0; | 84 return 0.0; |
85 return m_referenceMonotonicTime + pseudoWallTime - m_referenceWallTime; | 85 return m_referenceMonotonicTime + pseudoWallTime - m_referenceWallTime; |
86 } | 86 } |
87 | 87 |
88 void DocumentLoadTiming::markNavigationStart() | 88 void DocumentLoadTiming::markNavigationStart() |
89 { | 89 { |
| 90 // Allow the embedder to override navigationStart before we record it if |
| 91 // they have a more accurate timestamp. |
| 92 if (m_navigationStart) { |
| 93 ASSERT(m_referenceMonotonicTime && m_referenceWallTime); |
| 94 return; |
| 95 } |
90 TRACE_EVENT_MARK("blink.user_timing", "navigationStart"); | 96 TRACE_EVENT_MARK("blink.user_timing", "navigationStart"); |
91 ASSERT(!m_navigationStart && !m_referenceMonotonicTime && !m_referenceWallTi
me); | 97 ASSERT(!m_navigationStart && !m_referenceMonotonicTime && !m_referenceWallTi
me); |
92 | 98 |
93 m_navigationStart = m_referenceMonotonicTime = monotonicallyIncreasingTime()
; | 99 m_navigationStart = m_referenceMonotonicTime = monotonicallyIncreasingTime()
; |
94 m_referenceWallTime = currentTime(); | 100 m_referenceWallTime = currentTime(); |
95 notifyDocumentTimingChanged(); | 101 notifyDocumentTimingChanged(); |
96 } | 102 } |
97 | 103 |
98 void DocumentLoadTiming::setNavigationStart(double navigationStart) | 104 void DocumentLoadTiming::setNavigationStart(double navigationStart) |
99 { | 105 { |
100 TRACE_EVENT_MARK_WITH_TIMESTAMP("blink.user_timing", "navigationStart", navi
gationStart); | 106 TRACE_EVENT_MARK_WITH_TIMESTAMP("blink.user_timing", "navigationStart", navi
gationStart); |
101 ASSERT(m_referenceMonotonicTime && m_referenceWallTime); | |
102 m_navigationStart = navigationStart; | 107 m_navigationStart = navigationStart; |
103 | 108 |
104 // |m_referenceMonotonicTime| and |m_referenceWallTime| represent | 109 // |m_referenceMonotonicTime| and |m_referenceWallTime| represent |
105 // navigationStart. When the embedder sets navigationStart (because the | 110 // navigationStart. When the embedder sets navigationStart (because the |
106 // navigation started earlied on the browser side), we need to adjust these | 111 // navigation started earlied on the browser side), we need to adjust these |
107 // as well. | 112 // as well. |
108 m_referenceWallTime = monotonicTimeToPseudoWallTime(navigationStart); | 113 if (!m_referenceWallTime) |
| 114 m_referenceWallTime = currentTime(); |
| 115 else |
| 116 m_referenceWallTime = monotonicTimeToPseudoWallTime(navigationStart); |
109 m_referenceMonotonicTime = navigationStart; | 117 m_referenceMonotonicTime = navigationStart; |
110 notifyDocumentTimingChanged(); | 118 notifyDocumentTimingChanged(); |
111 } | 119 } |
112 | 120 |
113 void DocumentLoadTiming::addRedirect(const KURL& redirectingUrl, const KURL& red
irectedUrl) | 121 void DocumentLoadTiming::addRedirect(const KURL& redirectingUrl, const KURL& red
irectedUrl) |
114 { | 122 { |
115 m_redirectCount++; | 123 m_redirectCount++; |
116 if (!m_redirectStart) { | 124 if (!m_redirectStart) { |
117 setRedirectStart(m_fetchStart); | 125 setRedirectStart(m_fetchStart); |
118 } | 126 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 182 } |
175 | 183 |
176 void DocumentLoadTiming::markRedirectEnd() | 184 void DocumentLoadTiming::markRedirectEnd() |
177 { | 185 { |
178 TRACE_EVENT_MARK("blink.user_timing", "redirectEnd"); | 186 TRACE_EVENT_MARK("blink.user_timing", "redirectEnd"); |
179 m_redirectEnd = monotonicallyIncreasingTime(); | 187 m_redirectEnd = monotonicallyIncreasingTime(); |
180 notifyDocumentTimingChanged(); | 188 notifyDocumentTimingChanged(); |
181 } | 189 } |
182 | 190 |
183 } // namespace blink | 191 } // namespace blink |
OLD | NEW |