summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc b/chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc
index 9ebbcba427a..2f10b829b71 100644
--- a/chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc
+++ b/chromium/third_party/blink/renderer/core/html/lazy_load_image_observer.cc
@@ -245,6 +245,35 @@ void LazyLoadImageObserver::OnVisibilityChanged(
if (entry->isIntersecting()) {
DCHECK(visible_load_time_metrics.time_when_first_visible.is_null());
visible_load_time_metrics.time_when_first_visible = CurrentTimeTicks();
+
+ if (visible_load_time_metrics.record_visibility_metrics &&
+ image_element->GetDocument().GetFrame()) {
+ // Since the visibility metrics are recorded when the image finishes
+ // loading, this means that the image became visible before it
+ // finished loading.
+
+ // Note: If the WebEffectiveConnectionType enum ever gets out of sync
+ // with net::EffectiveConnectionType, then both the AboveTheFold and
+ // BelowTheFold histograms here will have to be updated to record the
+ // sample in terms of net::EffectiveConnectionType instead of
+ // WebEffectiveConnectionType.
+ if (visible_load_time_metrics.is_initially_intersecting) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Blink.VisibleBeforeLoaded.LazyLoadImages.AboveTheFold",
+ image_element->GetDocument()
+ .GetFrame()
+ ->Client()
+ ->GetEffectiveConnectionType());
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold",
+ image_element->GetDocument()
+ .GetFrame()
+ ->Client()
+ ->GetEffectiveConnectionType());
+ }
+ }
+
visibility_metrics_observer_->unobserve(image_element);
}
}