| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prerender/prerender_histograms.h" | 5 #include "chrome/browser/prerender/prerender_histograms.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/histogram_functions.h" | 12 #include "base/metrics/histogram_functions.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "chrome/browser/prerender/prerender_manager.h" | 15 #include "chrome/browser/prerender/prerender_manager.h" |
| 16 #include "chrome/browser/prerender/prerender_util.h" | 16 #include "components/google/core/browser/google_util.h" |
| 17 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
| 18 | 18 |
| 19 namespace prerender { | 19 namespace prerender { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // This enum is used to define the buckets for the | 23 // This enum is used to define the buckets for the |
| 24 // "Prerender.NoStatePrefetchResourceCount" histogram family. | 24 // "Prerender.NoStatePrefetchResourceCount" histogram family. |
| 25 // Hence, existing enumerated constants should never be deleted or reordered, | 25 // Hence, existing enumerated constants should never be deleted or reordered, |
| 26 // and new constants should only be appended at the end of the enumeration. | 26 // and new constants should only be appended at the end of the enumeration. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // FirstAfterMissNonOverlapping but NOT FirstAfterMiss | 259 // FirstAfterMissNonOverlapping but NOT FirstAfterMiss |
| 260 | 260 |
| 261 void PrerenderHistograms::RecordPerceivedPageLoadTime( | 261 void PrerenderHistograms::RecordPerceivedPageLoadTime( |
| 262 Origin origin, | 262 Origin origin, |
| 263 base::TimeDelta perceived_page_load_time, | 263 base::TimeDelta perceived_page_load_time, |
| 264 NavigationType navigation_type, | 264 NavigationType navigation_type, |
| 265 const GURL& url) { | 265 const GURL& url) { |
| 266 if (!url.SchemeIsHTTPOrHTTPS()) | 266 if (!url.SchemeIsHTTPOrHTTPS()) |
| 267 return; | 267 return; |
| 268 bool within_window = WithinWindow(); | 268 bool within_window = WithinWindow(); |
| 269 bool is_google_url = IsGoogleDomain(url); | 269 bool is_google_url = |
| 270 google_util::IsGoogleDomainUrl(url, google_util::DISALLOW_SUBDOMAIN, |
| 271 google_util::ALLOW_NON_STANDARD_PORTS); |
| 270 RECORD_PLT("PerceivedPLT", perceived_page_load_time); | 272 RECORD_PLT("PerceivedPLT", perceived_page_load_time); |
| 271 if (within_window) | 273 if (within_window) |
| 272 RECORD_PLT("PerceivedPLTWindowed", perceived_page_load_time); | 274 RECORD_PLT("PerceivedPLTWindowed", perceived_page_load_time); |
| 273 if (navigation_type != NAVIGATION_TYPE_NORMAL) { | 275 if (navigation_type != NAVIGATION_TYPE_NORMAL) { |
| 274 DCHECK(navigation_type == NAVIGATION_TYPE_PRERENDERED); | 276 DCHECK(navigation_type == NAVIGATION_TYPE_PRERENDERED); |
| 275 seen_any_pageload_ = true; | 277 seen_any_pageload_ = true; |
| 276 seen_pageload_started_after_prerender_ = true; | 278 seen_pageload_started_after_prerender_ = true; |
| 277 } else if (within_window) { | 279 } else if (within_window) { |
| 278 if (!is_google_url) { | 280 if (!is_google_url) { |
| 279 bool recorded_any = false; | 281 bool recorded_any = false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 FirstContentfulPaintHiddenName(was_hidden), | 317 FirstContentfulPaintHiddenName(was_hidden), |
| 316 successful); | 318 successful); |
| 317 } | 319 } |
| 318 | 320 |
| 319 void PrerenderHistograms::RecordPageLoadTimeNotSwappedIn( | 321 void PrerenderHistograms::RecordPageLoadTimeNotSwappedIn( |
| 320 Origin origin, | 322 Origin origin, |
| 321 base::TimeDelta page_load_time, | 323 base::TimeDelta page_load_time, |
| 322 const GURL& url) const { | 324 const GURL& url) const { |
| 323 // If the URL to be prerendered is not a http[s] URL, or is a Google URL, | 325 // If the URL to be prerendered is not a http[s] URL, or is a Google URL, |
| 324 // do not record. | 326 // do not record. |
| 325 if (!url.SchemeIsHTTPOrHTTPS() || IsGoogleDomain(url)) | 327 if (!url.SchemeIsHTTPOrHTTPS() || |
| 328 google_util::IsGoogleDomainUrl(url, google_util::DISALLOW_SUBDOMAIN, |
| 329 google_util::ALLOW_NON_STANDARD_PORTS)) { |
| 326 return; | 330 return; |
| 331 } |
| 327 RECORD_PLT("PrerenderNotSwappedInPLT", page_load_time); | 332 RECORD_PLT("PrerenderNotSwappedInPLT", page_load_time); |
| 328 } | 333 } |
| 329 | 334 |
| 330 void PrerenderHistograms::RecordPercentLoadDoneAtSwapin(Origin origin, | 335 void PrerenderHistograms::RecordPercentLoadDoneAtSwapin(Origin origin, |
| 331 double fraction) const { | 336 double fraction) const { |
| 332 if (fraction < 0.0 || fraction > 1.0) | 337 if (fraction < 0.0 || fraction > 1.0) |
| 333 return; | 338 return; |
| 334 int percentage = static_cast<int>(fraction * 100); | 339 int percentage = static_cast<int>(fraction * 100); |
| 335 if (percentage < 0 || percentage > 100) | 340 if (percentage < 0 || percentage > 100) |
| 336 return; | 341 return; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 base::TimeDelta::FromMinutes(2), time, 50); | 497 base::TimeDelta::FromMinutes(2), time, 50); |
| 493 } | 498 } |
| 494 | 499 |
| 495 bool PrerenderHistograms::IsOriginWash() const { | 500 bool PrerenderHistograms::IsOriginWash() const { |
| 496 if (!WithinWindow()) | 501 if (!WithinWindow()) |
| 497 return false; | 502 return false; |
| 498 return origin_wash_; | 503 return origin_wash_; |
| 499 } | 504 } |
| 500 | 505 |
| 501 } // namespace prerender | 506 } // namespace prerender |
| OLD | NEW |