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 "WebPerformance.h"
34 #include "Performance.h"
36 using namespace WebCore;
40 static double millisecondsToSeconds(unsigned long long milliseconds)
42 return static_cast<double>(milliseconds / 1000.0);
45 void WebPerformance::reset()
50 void WebPerformance::assign(const WebPerformance& other)
52 m_private = other.m_private;
55 WebNavigationType WebPerformance::navigationType() const
57 switch (m_private->navigation()->type()) {
58 case PerformanceNavigation::TYPE_NAVIGATE:
59 return WebNavigationTypeOther;
60 case PerformanceNavigation::TYPE_RELOAD:
61 return WebNavigationTypeReload;
62 case PerformanceNavigation::TYPE_BACK_FORWARD:
63 return WebNavigationTypeBackForward;
64 case PerformanceNavigation::TYPE_RESERVED:
65 return WebNavigationTypeOther;
68 return WebNavigationTypeOther;
71 double WebPerformance::navigationStart() const
73 return millisecondsToSeconds(m_private->timing()->navigationStart());
76 double WebPerformance::unloadEventEnd() const
78 return millisecondsToSeconds(m_private->timing()->unloadEventEnd());
81 double WebPerformance::redirectStart() const
83 return millisecondsToSeconds(m_private->timing()->redirectStart());
86 double WebPerformance::redirectEnd() const
88 return millisecondsToSeconds(m_private->timing()->redirectEnd());
91 unsigned short WebPerformance::redirectCount() const
93 return m_private->navigation()->redirectCount();
96 double WebPerformance::fetchStart() const
98 return millisecondsToSeconds(m_private->timing()->fetchStart());
101 double WebPerformance::domainLookupStart() const
103 return millisecondsToSeconds(m_private->timing()->domainLookupStart());
106 double WebPerformance::domainLookupEnd() const
108 return millisecondsToSeconds(m_private->timing()->domainLookupEnd());
111 double WebPerformance::connectStart() const
113 return millisecondsToSeconds(m_private->timing()->connectStart());
116 double WebPerformance::connectEnd() const
118 return millisecondsToSeconds(m_private->timing()->connectEnd());
121 double WebPerformance::requestStart() const
123 return millisecondsToSeconds(m_private->timing()->requestStart());
126 double WebPerformance::responseStart() const
128 return millisecondsToSeconds(m_private->timing()->responseStart());
131 double WebPerformance::responseEnd() const
133 return millisecondsToSeconds(m_private->timing()->responseEnd());
136 double WebPerformance::domLoading() const
138 return millisecondsToSeconds(m_private->timing()->domLoading());
141 double WebPerformance::domInteractive() const
143 return millisecondsToSeconds(m_private->timing()->domInteractive());
146 double WebPerformance::domContentLoadedEventStart() const
148 return millisecondsToSeconds(m_private->timing()->domContentLoadedEventStart());
151 double WebPerformance::domContentLoadedEventEnd() const
153 return millisecondsToSeconds(m_private->timing()->domContentLoadedEventEnd());
156 double WebPerformance::domComplete() const
158 return millisecondsToSeconds(m_private->timing()->domComplete());
161 double WebPerformance::loadEventStart() const
163 return millisecondsToSeconds(m_private->timing()->loadEventStart());
166 double WebPerformance::loadEventEnd() const
168 return millisecondsToSeconds(m_private->timing()->loadEventEnd());
171 WebPerformance::WebPerformance(const PassRefPtr<Performance>& performance)
172 : m_private(performance)
176 WebPerformance& WebPerformance::operator=(const PassRefPtr<Performance>& performance)
178 m_private = performance;
182 WebPerformance::operator PassRefPtr<Performance>() const
184 return m_private.get();
187 } // namespace WebKit