2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "public/web/WebPerformance.h"
34 #include "core/timing/Performance.h"
38 static double millisecondsToSeconds(unsigned long long milliseconds
)
40 return static_cast<double>(milliseconds
/ 1000.0);
43 void WebPerformance::reset()
48 void WebPerformance::assign(const WebPerformance
& other
)
50 m_private
= other
.m_private
;
53 WebNavigationType
WebPerformance::navigationType() const
55 switch (m_private
->navigation()->type()) {
56 case PerformanceNavigation::TYPE_NAVIGATE
:
57 return WebNavigationTypeOther
;
58 case PerformanceNavigation::TYPE_RELOAD
:
59 return WebNavigationTypeReload
;
60 case PerformanceNavigation::TYPE_BACK_FORWARD
:
61 return WebNavigationTypeBackForward
;
62 case PerformanceNavigation::TYPE_RESERVED
:
63 return WebNavigationTypeOther
;
66 return WebNavigationTypeOther
;
69 double WebPerformance::navigationStart() const
71 return millisecondsToSeconds(m_private
->timing()->navigationStart());
74 double WebPerformance::unloadEventEnd() const
76 return millisecondsToSeconds(m_private
->timing()->unloadEventEnd());
79 double WebPerformance::redirectStart() const
81 return millisecondsToSeconds(m_private
->timing()->redirectStart());
84 double WebPerformance::redirectEnd() const
86 return millisecondsToSeconds(m_private
->timing()->redirectEnd());
89 unsigned short WebPerformance::redirectCount() const
91 return m_private
->navigation()->redirectCount();
94 double WebPerformance::fetchStart() const
96 return millisecondsToSeconds(m_private
->timing()->fetchStart());
99 double WebPerformance::domainLookupStart() const
101 return millisecondsToSeconds(m_private
->timing()->domainLookupStart());
104 double WebPerformance::domainLookupEnd() const
106 return millisecondsToSeconds(m_private
->timing()->domainLookupEnd());
109 double WebPerformance::connectStart() const
111 return millisecondsToSeconds(m_private
->timing()->connectStart());
114 double WebPerformance::connectEnd() const
116 return millisecondsToSeconds(m_private
->timing()->connectEnd());
119 double WebPerformance::requestStart() const
121 return millisecondsToSeconds(m_private
->timing()->requestStart());
124 double WebPerformance::responseStart() const
126 return millisecondsToSeconds(m_private
->timing()->responseStart());
129 double WebPerformance::responseEnd() const
131 return millisecondsToSeconds(m_private
->timing()->responseEnd());
134 double WebPerformance::domLoading() const
136 return millisecondsToSeconds(m_private
->timing()->domLoading());
139 double WebPerformance::domInteractive() const
141 return millisecondsToSeconds(m_private
->timing()->domInteractive());
144 double WebPerformance::domContentLoadedEventStart() const
146 return millisecondsToSeconds(m_private
->timing()->domContentLoadedEventStart());
149 double WebPerformance::domContentLoadedEventEnd() const
151 return millisecondsToSeconds(m_private
->timing()->domContentLoadedEventEnd());
154 double WebPerformance::domComplete() const
156 return millisecondsToSeconds(m_private
->timing()->domComplete());
159 double WebPerformance::loadEventStart() const
161 return millisecondsToSeconds(m_private
->timing()->loadEventStart());
164 double WebPerformance::loadEventEnd() const
166 return millisecondsToSeconds(m_private
->timing()->loadEventEnd());
169 double WebPerformance::firstLayout() const
171 return millisecondsToSeconds(m_private
->timing()->firstLayout());
174 WebPerformance::WebPerformance(const PassRefPtrWillBeRawPtr
<Performance
>& performance
)
175 : m_private(performance
)
179 WebPerformance
& WebPerformance::operator=(const PassRefPtrWillBeRawPtr
<Performance
>& performance
)
181 m_private
= performance
;