| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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 "public/web/WebPerformance.h" | |
| 32 | |
| 33 #include "core/timing/Performance.h" | |
| 34 | |
| 35 namespace blink { | |
| 36 | |
| 37 static double MillisecondsToSeconds(unsigned long long milliseconds) { | |
| 38 return static_cast<double>(milliseconds / 1000.0); | |
| 39 } | |
| 40 | |
| 41 void WebPerformance::Reset() { | |
| 42 private_.Reset(); | |
| 43 } | |
| 44 | |
| 45 void WebPerformance::Assign(const WebPerformance& other) { | |
| 46 private_ = other.private_; | |
| 47 } | |
| 48 | |
| 49 WebNavigationType WebPerformance::GetNavigationType() const { | |
| 50 switch (private_->navigation()->type()) { | |
| 51 case PerformanceNavigation::kTypeNavigate: | |
| 52 return kWebNavigationTypeOther; | |
| 53 case PerformanceNavigation::kTypeReload: | |
| 54 return kWebNavigationTypeReload; | |
| 55 case PerformanceNavigation::kTypeBackForward: | |
| 56 return kWebNavigationTypeBackForward; | |
| 57 case PerformanceNavigation::kTypeReserved: | |
| 58 return kWebNavigationTypeOther; | |
| 59 } | |
| 60 NOTREACHED(); | |
| 61 return kWebNavigationTypeOther; | |
| 62 } | |
| 63 | |
| 64 double WebPerformance::NavigationStart() const { | |
| 65 return MillisecondsToSeconds(private_->timing()->navigationStart()); | |
| 66 } | |
| 67 | |
| 68 double WebPerformance::UnloadEventEnd() const { | |
| 69 return MillisecondsToSeconds(private_->timing()->unloadEventEnd()); | |
| 70 } | |
| 71 | |
| 72 double WebPerformance::RedirectStart() const { | |
| 73 return MillisecondsToSeconds(private_->timing()->redirectStart()); | |
| 74 } | |
| 75 | |
| 76 double WebPerformance::RedirectEnd() const { | |
| 77 return MillisecondsToSeconds(private_->timing()->redirectEnd()); | |
| 78 } | |
| 79 | |
| 80 unsigned short WebPerformance::RedirectCount() const { | |
| 81 return private_->navigation()->redirectCount(); | |
| 82 } | |
| 83 | |
| 84 double WebPerformance::FetchStart() const { | |
| 85 return MillisecondsToSeconds(private_->timing()->fetchStart()); | |
| 86 } | |
| 87 | |
| 88 double WebPerformance::DomainLookupStart() const { | |
| 89 return MillisecondsToSeconds(private_->timing()->domainLookupStart()); | |
| 90 } | |
| 91 | |
| 92 double WebPerformance::DomainLookupEnd() const { | |
| 93 return MillisecondsToSeconds(private_->timing()->domainLookupEnd()); | |
| 94 } | |
| 95 | |
| 96 double WebPerformance::ConnectStart() const { | |
| 97 return MillisecondsToSeconds(private_->timing()->connectStart()); | |
| 98 } | |
| 99 | |
| 100 double WebPerformance::ConnectEnd() const { | |
| 101 return MillisecondsToSeconds(private_->timing()->connectEnd()); | |
| 102 } | |
| 103 | |
| 104 double WebPerformance::RequestStart() const { | |
| 105 return MillisecondsToSeconds(private_->timing()->requestStart()); | |
| 106 } | |
| 107 | |
| 108 double WebPerformance::ResponseStart() const { | |
| 109 return MillisecondsToSeconds(private_->timing()->responseStart()); | |
| 110 } | |
| 111 | |
| 112 double WebPerformance::ResponseEnd() const { | |
| 113 return MillisecondsToSeconds(private_->timing()->responseEnd()); | |
| 114 } | |
| 115 | |
| 116 double WebPerformance::DomLoading() const { | |
| 117 return MillisecondsToSeconds(private_->timing()->domLoading()); | |
| 118 } | |
| 119 | |
| 120 double WebPerformance::DomInteractive() const { | |
| 121 return MillisecondsToSeconds(private_->timing()->domInteractive()); | |
| 122 } | |
| 123 | |
| 124 double WebPerformance::DomContentLoadedEventStart() const { | |
| 125 return MillisecondsToSeconds( | |
| 126 private_->timing()->domContentLoadedEventStart()); | |
| 127 } | |
| 128 | |
| 129 double WebPerformance::DomContentLoadedEventEnd() const { | |
| 130 return MillisecondsToSeconds(private_->timing()->domContentLoadedEventEnd()); | |
| 131 } | |
| 132 | |
| 133 double WebPerformance::DomComplete() const { | |
| 134 return MillisecondsToSeconds(private_->timing()->domComplete()); | |
| 135 } | |
| 136 | |
| 137 double WebPerformance::LoadEventStart() const { | |
| 138 return MillisecondsToSeconds(private_->timing()->loadEventStart()); | |
| 139 } | |
| 140 | |
| 141 double WebPerformance::LoadEventEnd() const { | |
| 142 return MillisecondsToSeconds(private_->timing()->loadEventEnd()); | |
| 143 } | |
| 144 | |
| 145 double WebPerformance::FirstLayout() const { | |
| 146 return MillisecondsToSeconds(private_->timing()->FirstLayout()); | |
| 147 } | |
| 148 | |
| 149 double WebPerformance::FirstPaint() const { | |
| 150 return MillisecondsToSeconds(private_->timing()->FirstPaint()); | |
| 151 } | |
| 152 | |
| 153 double WebPerformance::FirstTextPaint() const { | |
| 154 return MillisecondsToSeconds(private_->timing()->FirstTextPaint()); | |
| 155 } | |
| 156 | |
| 157 double WebPerformance::FirstImagePaint() const { | |
| 158 return MillisecondsToSeconds(private_->timing()->FirstImagePaint()); | |
| 159 } | |
| 160 | |
| 161 double WebPerformance::FirstContentfulPaint() const { | |
| 162 return MillisecondsToSeconds(private_->timing()->FirstContentfulPaint()); | |
| 163 } | |
| 164 | |
| 165 double WebPerformance::FirstMeaningfulPaint() const { | |
| 166 return MillisecondsToSeconds(private_->timing()->FirstMeaningfulPaint()); | |
| 167 } | |
| 168 | |
| 169 double WebPerformance::ParseStart() const { | |
| 170 return MillisecondsToSeconds(private_->timing()->ParseStart()); | |
| 171 } | |
| 172 | |
| 173 double WebPerformance::ParseStop() const { | |
| 174 return MillisecondsToSeconds(private_->timing()->ParseStop()); | |
| 175 } | |
| 176 | |
| 177 double WebPerformance::ParseBlockedOnScriptLoadDuration() const { | |
| 178 return MillisecondsToSeconds( | |
| 179 private_->timing()->ParseBlockedOnScriptLoadDuration()); | |
| 180 } | |
| 181 | |
| 182 double WebPerformance::ParseBlockedOnScriptLoadFromDocumentWriteDuration() | |
| 183 const { | |
| 184 return MillisecondsToSeconds( | |
| 185 private_->timing()->ParseBlockedOnScriptLoadFromDocumentWriteDuration()); | |
| 186 } | |
| 187 | |
| 188 double WebPerformance::ParseBlockedOnScriptExecutionDuration() const { | |
| 189 return MillisecondsToSeconds( | |
| 190 private_->timing()->ParseBlockedOnScriptExecutionDuration()); | |
| 191 } | |
| 192 | |
| 193 double WebPerformance::ParseBlockedOnScriptExecutionFromDocumentWriteDuration() | |
| 194 const { | |
| 195 return MillisecondsToSeconds( | |
| 196 private_->timing() | |
| 197 ->ParseBlockedOnScriptExecutionFromDocumentWriteDuration()); | |
| 198 } | |
| 199 | |
| 200 double WebPerformance::AuthorStyleSheetParseDurationBeforeFCP() const { | |
| 201 return MillisecondsToSeconds( | |
| 202 private_->timing()->AuthorStyleSheetParseDurationBeforeFCP()); | |
| 203 } | |
| 204 | |
| 205 double WebPerformance::UpdateStyleDurationBeforeFCP() const { | |
| 206 return MillisecondsToSeconds( | |
| 207 private_->timing()->UpdateStyleDurationBeforeFCP()); | |
| 208 } | |
| 209 | |
| 210 WebPerformance::WebPerformance(Performance* performance) | |
| 211 : private_(performance) {} | |
| 212 | |
| 213 WebPerformance& WebPerformance::operator=(Performance* performance) { | |
| 214 private_ = performance; | |
| 215 return *this; | |
| 216 } | |
| 217 | |
| 218 } // namespace blink | |
| OLD | NEW |