blob: 6e664b68b27b606ba75023486c84aa48605dd089 [file] [log] [blame]
tonyg@chromium.org064638a2010-07-26 17:03:35 +00001/*
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#ifndef DocumentLoadTiming_h
27#define DocumentLoadTiming_h
28
simonjam@chromium.orgdfab5cf2011-12-15 18:45:29 +000029#include <wtf/CurrentTime.h>
30
tonyg@chromium.org064638a2010-07-26 17:03:35 +000031namespace WebCore {
32
simonjam@chromium.orgdfab5cf2011-12-15 18:45:29 +000033class Frame;
34class KURL;
tonyg@chromium.org064638a2010-07-26 17:03:35 +000035
simonjam@chromium.orgdfab5cf2011-12-15 18:45:29 +000036class DocumentLoadTiming {
37public:
38 DocumentLoadTiming();
39
40 void markNavigationStart(Frame*);
simonjam@chromium.org112b47e2012-03-01 04:08:54 +000041 void setNavigationStart(double);
simonjam@chromium.orgdfab5cf2011-12-15 18:45:29 +000042 void addRedirect(const KURL& redirectingUrl, const KURL& redirectedUrl);
43 double convertMonotonicTimeToDocumentTime(double monotonicTime) const;
44
45 void markUnloadEventStart() { m_unloadEventStart = monotonicallyIncreasingTime(); }
46 void markUnloadEventEnd() { m_unloadEventEnd = monotonicallyIncreasingTime(); }
47 void markRedirectStart() { m_redirectStart = monotonicallyIncreasingTime(); }
48 void markRedirectEnd() { m_redirectEnd = monotonicallyIncreasingTime(); }
49 void markFetchStart() { m_fetchStart = monotonicallyIncreasingTime(); }
50 void setResponseEnd(double monotonicTime) { m_responseEnd = monotonicTime; }
51 void markLoadEventStart() { m_loadEventStart = monotonicallyIncreasingTime(); }
52 void markLoadEventEnd() { m_loadEventEnd = monotonicallyIncreasingTime(); }
53
54 void setHasSameOriginAsPreviousDocument(bool value) { m_hasSameOriginAsPreviousDocument = value; }
55
56 double navigationStart() const { return convertMonotonicTimeToDocumentTime(m_navigationStart); }
57 double unloadEventStart() const { return convertMonotonicTimeToDocumentTime(m_unloadEventStart); }
58 double unloadEventEnd() const { return convertMonotonicTimeToDocumentTime(m_unloadEventEnd); }
59 double redirectStart() const { return convertMonotonicTimeToDocumentTime(m_redirectStart); }
60 double redirectEnd() const { return convertMonotonicTimeToDocumentTime(m_redirectEnd); }
61 short redirectCount() const { return m_redirectCount; }
62 double fetchStart() const { return convertMonotonicTimeToDocumentTime(m_fetchStart); }
63 double responseEnd() const { return convertMonotonicTimeToDocumentTime(m_responseEnd); }
64 double loadEventStart() const { return convertMonotonicTimeToDocumentTime(m_loadEventStart); }
65 double loadEventEnd() const { return convertMonotonicTimeToDocumentTime(m_loadEventEnd); }
66 bool hasCrossOriginRedirect() const { return m_hasCrossOriginRedirect; }
67 bool hasSameOriginAsPreviousDocument() const { return m_hasSameOriginAsPreviousDocument; }
68
69private:
70 double m_referenceMonotonicTime;
71 double m_referenceWallTime;
72 double m_navigationStart;
73 double m_unloadEventStart;
74 double m_unloadEventEnd;
75 double m_redirectStart;
76 double m_redirectEnd;
77 short m_redirectCount;
78 double m_fetchStart;
79 double m_responseEnd;
80 double m_loadEventStart;
81 double m_loadEventEnd;
82 bool m_hasCrossOriginRedirect;
83 bool m_hasSameOriginAsPreviousDocument;
tonyg@chromium.org064638a2010-07-26 17:03:35 +000084};
85
simonjam@chromium.orgdfab5cf2011-12-15 18:45:29 +000086} // namespace WebCore
tonyg@chromium.org064638a2010-07-26 17:03:35 +000087
88#endif