blob: 1d0888126546f254c584d4020bef4143f676ff9d [file] [log] [blame]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +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 are
6 * met:
7 *
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
13 * distribution.
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.
17 *
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.
29 */
30
31#include "config.h"
32#include "WebPerformance.h"
33
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010034#include "core/timing/Performance.h"
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000035
36using namespace WebCore;
37
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000038namespace blink {
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000039
40static double millisecondsToSeconds(unsigned long long milliseconds)
41{
42 return static_cast<double>(milliseconds / 1000.0);
43}
44
45void WebPerformance::reset()
46{
47 m_private.reset();
48}
49
50void WebPerformance::assign(const WebPerformance& other)
51{
52 m_private = other.m_private;
53}
54
55WebNavigationType WebPerformance::navigationType() const
56{
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;
66 }
67 ASSERT_NOT_REACHED();
68 return WebNavigationTypeOther;
69}
70
71double WebPerformance::navigationStart() const
72{
73 return millisecondsToSeconds(m_private->timing()->navigationStart());
74}
75
76double WebPerformance::unloadEventEnd() const
77{
78 return millisecondsToSeconds(m_private->timing()->unloadEventEnd());
79}
80
81double WebPerformance::redirectStart() const
82{
83 return millisecondsToSeconds(m_private->timing()->redirectStart());
84}
85
86double WebPerformance::redirectEnd() const
87{
88 return millisecondsToSeconds(m_private->timing()->redirectEnd());
89}
90
91unsigned short WebPerformance::redirectCount() const
92{
93 return m_private->navigation()->redirectCount();
94}
95
96double WebPerformance::fetchStart() const
97{
98 return millisecondsToSeconds(m_private->timing()->fetchStart());
99}
100
101double WebPerformance::domainLookupStart() const
102{
103 return millisecondsToSeconds(m_private->timing()->domainLookupStart());
104}
105
106double WebPerformance::domainLookupEnd() const
107{
108 return millisecondsToSeconds(m_private->timing()->domainLookupEnd());
109}
110
111double WebPerformance::connectStart() const
112{
113 return millisecondsToSeconds(m_private->timing()->connectStart());
114}
115
116double WebPerformance::connectEnd() const
117{
118 return millisecondsToSeconds(m_private->timing()->connectEnd());
119}
120
121double WebPerformance::requestStart() const
122{
123 return millisecondsToSeconds(m_private->timing()->requestStart());
124}
125
126double WebPerformance::responseStart() const
127{
128 return millisecondsToSeconds(m_private->timing()->responseStart());
129}
130
131double WebPerformance::responseEnd() const
132{
133 return millisecondsToSeconds(m_private->timing()->responseEnd());
134}
135
136double WebPerformance::domLoading() const
137{
138 return millisecondsToSeconds(m_private->timing()->domLoading());
139}
140
141double WebPerformance::domInteractive() const
142{
143 return millisecondsToSeconds(m_private->timing()->domInteractive());
144}
145
146double WebPerformance::domContentLoadedEventStart() const
147{
148 return millisecondsToSeconds(m_private->timing()->domContentLoadedEventStart());
149}
150
151double WebPerformance::domContentLoadedEventEnd() const
152{
153 return millisecondsToSeconds(m_private->timing()->domContentLoadedEventEnd());
154}
155
156double WebPerformance::domComplete() const
157{
158 return millisecondsToSeconds(m_private->timing()->domComplete());
159}
160
161double WebPerformance::loadEventStart() const
162{
163 return millisecondsToSeconds(m_private->timing()->loadEventStart());
164}
165
166double WebPerformance::loadEventEnd() const
167{
168 return millisecondsToSeconds(m_private->timing()->loadEventEnd());
169}
170
Torne (Richard Coles)43e75022014-03-21 14:26:12 +0000171WebPerformance::WebPerformance(const PassRefPtrWillBeRawPtr<Performance>& performance)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000172 : m_private(performance)
173{
174}
175
Torne (Richard Coles)43e75022014-03-21 14:26:12 +0000176WebPerformance& WebPerformance::operator=(const PassRefPtrWillBeRawPtr<Performance>& performance)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000177{
178 m_private = performance;
179 return *this;
180}
181
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000182} // namespace blink