Commit 273fa0ab authored by rajendrant's avatar rajendrant Committed by Commit Bot

Fix media bytes ukm

This CL changes media bytes to be recorded on every delta update,
instead of at response completion (which may miss some responses that
have not completed by pageload end). Also changes logic to treat all
video/*, audio/* mimetypes as video responses.

Change-Id: Ib78861227147978c34ed1d28dd7b24fc63600253
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079513Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarMichael Crouse <mcrouse@chromium.org>
Commit-Queue: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745537}
parent 4105e713
......@@ -258,6 +258,18 @@ void UkmPageLoadMetricsObserver::OnResourceDataUseObserved(
for (auto const& resource : resources) {
network_bytes_ += resource->delta_bytes;
if (blink::IsSupportedImageMimeType(resource->mime_type)) {
image_total_bytes_ += resource->delta_bytes;
if (!resource->is_main_frame_resource)
image_subframe_bytes_ += resource->delta_bytes;
} else if (media::IsSupportedMediaMimeType(resource->mime_type) ||
base::StartsWith(resource->mime_type, "audio/",
base::CompareCase::SENSITIVE) ||
base::StartsWith(resource->mime_type, "video/",
base::CompareCase::SENSITIVE)) {
media_bytes_ += resource->delta_bytes;
}
// Only sum body lengths for completed resources.
if (!resource->is_complete)
continue;
......@@ -265,12 +277,6 @@ void UkmPageLoadMetricsObserver::OnResourceDataUseObserved(
js_decoded_bytes_ += resource->decoded_body_length;
if (resource->decoded_body_length > js_max_decoded_bytes_)
js_max_decoded_bytes_ = resource->decoded_body_length;
} else if (blink::IsSupportedImageMimeType(resource->mime_type)) {
image_total_bytes_ += resource->received_data_length;
if (!resource->is_main_frame_resource)
image_subframe_bytes_ += resource->received_data_length;
} else if (media::IsSupportedMediaMimeType(resource->mime_type)) {
media_bytes_ += resource->received_data_length;
}
if (resource->cache_type !=
page_load_metrics::mojom::CacheType::kNotCached) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment