Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/FrameSerializer.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/FrameSerializer.cpp b/third_party/WebKit/Source/core/frame/FrameSerializer.cpp |
| index a2258654313ad94f65350fda26b7e48f38c62b14..684c4c8e12b3996000f7bacc515226d6722e6507 100644 |
| --- a/third_party/WebKit/Source/core/frame/FrameSerializer.cpp |
| +++ b/third_party/WebKit/Source/core/frame/FrameSerializer.cpp |
| @@ -299,6 +299,12 @@ void FrameSerializer::SerializeFrame(const LocalFrame& frame) { |
| SharedBuffer::Create(frame_html.data(), frame_html.length()))); |
| } |
| + int total_image_count = 0; |
| + int loaded_image_count = 0; |
| + int total_css_count = 0; |
| + int loaded_css_count = 0; |
| + bool should_collect_problem_metric = |
| + delegate_.ShouldCollectProblemMetric() && frame.IsMainFrame(); |
|
Łukasz Anforowicz
2017/06/07 21:11:35
You are obviously in a better position than me to
romax
2017/06/08 02:25:22
I think it was mainly because in the offline page
Łukasz Anforowicz
2017/06/08 16:08:45
Sounds good. One final thought - how would the na
romax
2017/06/08 20:02:07
Adding suffixes sounds good to me, and it is somet
Łukasz Anforowicz
2017/06/08 20:48:53
I don't have a strong opinion - I am fine with wha
|
| for (Node* node : serialized_nodes) { |
| DCHECK(node); |
| if (!node->IsElementNode()) |
| @@ -317,6 +323,11 @@ void FrameSerializer::SerializeFrame(const LocalFrame& frame) { |
| HTMLImageElement& image_element = toHTMLImageElement(element); |
| KURL url = |
| document.CompleteURL(image_element.getAttribute(HTMLNames::srcAttr)); |
| + if (should_collect_problem_metric) { |
| + total_image_count++; |
| + if (image_element.complete()) |
|
Łukasz Anforowicz
2017/06/07 21:11:35
I see that FrameSerializer::AddImageToResources ch
romax
2017/06/08 02:25:22
Done.
Your mental model is correct. And I wasn't s
|
| + loaded_image_count++; |
| + } |
|
Łukasz Anforowicz
2017/06/07 21:11:35
Have you thought about avoiding counting resources
romax
2017/06/08 02:25:22
I didn't think about it before seeing comments. An
|
| ImageResourceContent* cached_image = image_element.CachedImage(); |
| AddImageToResources(cached_image, url); |
| } else if (isHTMLInputElement(element)) { |
| @@ -337,10 +348,35 @@ void FrameSerializer::SerializeFrame(const LocalFrame& frame) { |
| } |
| } else if (isHTMLStyleElement(element)) { |
| HTMLStyleElement& style_element = toHTMLStyleElement(element); |
| - if (CSSStyleSheet* sheet = style_element.sheet()) |
| + CSSStyleSheet* sheet = style_element.sheet(); |
| + if (sheet) |
| SerializeCSSStyleSheet(*sheet, KURL()); |
| + if (should_collect_problem_metric) { |
| + total_css_count++; |
| + if (sheet && sheet->IsLoading()) |
| + loaded_css_count++; |
|
Łukasz Anforowicz
2017/06/07 21:11:35
"loading" vs "loaded" seems out of sync - can you
romax
2017/06/08 02:25:22
Done.
|
| + } |
| } |
| } |
| + if (should_collect_problem_metric) { |
| + // Report detectors through UMA. |
| + // We're having exact 21 buckets for percentage because we want to have 5% |
| + // in each bucket to avoid potential spikes in the distribution. |
| + DCHECK_LE(loaded_image_count, total_image_count); |
| + UMA_HISTOGRAM_EXACT_LINEAR( |
| + "PageSerialization.ProblemDetection.LoadedImagePercentage", |
| + static_cast<int64_t>(loaded_image_count * 100 / total_image_count), 21); |
|
Steven Holte
2017/06/07 22:36:42
You are using 21 buckets, but these buckets are no
romax
2017/06/08 02:25:22
Done.
Changed to CustomCountHistogram in Blink, si
Steven Holte
2017/06/08 20:43:00
CustomCountHistogram is also not going to give you
romax
2017/06/08 23:30:46
I've added the LinearHistogram in Webkit/Platforms
|
| + UMA_HISTOGRAM_COUNTS_100( |
| + "PageSerialization.ProblemDetection.TotalImageCount", |
| + static_cast<int64_t>(total_image_count)); |
| + |
| + DCHECK_LE(loaded_css_count, total_css_count); |
| + UMA_HISTOGRAM_EXACT_LINEAR( |
| + "PageSerialization.ProblemDetection.LoadedCSSPercentage", |
| + static_cast<int64_t>(loaded_css_count * 100 / total_css_count), 21); |
| + UMA_HISTOGRAM_COUNTS_100("PageSerialization.ProblemDetection.TotalCSSCount", |
| + static_cast<int64_t>(total_css_count)); |
| + } |
| } |
| void FrameSerializer::SerializeCSSStyleSheet(CSSStyleSheet& style_sheet, |