OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/feature_list.h" | 6 #include "base/feature_list.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Clears all bits set in the |other| bitset. | 128 // Clears all bits set in the |other| bitset. |
129 void ClearMatching(const TimingFieldBitSet& other) { | 129 void ClearMatching(const TimingFieldBitSet& other) { |
130 bitmask_ &= ~other.bitmask_; | 130 bitmask_ &= ~other.bitmask_; |
131 } | 131 } |
132 | 132 |
133 private: | 133 private: |
134 int bitmask_ = 0; | 134 int bitmask_ = 0; |
135 }; | 135 }; |
136 | 136 |
137 static TimingFieldBitSet GetMatchedBits( | 137 static TimingFieldBitSet GetMatchedBits( |
138 const page_load_metrics::PageLoadTiming& timing, | 138 const page_load_metrics::mojom::PageLoadTiming& timing, |
139 const page_load_metrics::PageLoadMetadata& metadata) { | 139 const page_load_metrics::mojom::PageLoadMetadata& metadata) { |
140 TimingFieldBitSet matched_bits; | 140 TimingFieldBitSet matched_bits; |
141 if (timing.document_timing.first_layout) | 141 if (timing.document_timing->first_layout) |
142 matched_bits.Set(TimingField::FIRST_LAYOUT); | 142 matched_bits.Set(TimingField::FIRST_LAYOUT); |
143 if (timing.document_timing.load_event_start) | 143 if (timing.document_timing->load_event_start) |
144 matched_bits.Set(TimingField::LOAD_EVENT); | 144 matched_bits.Set(TimingField::LOAD_EVENT); |
145 if (timing.paint_timing.first_paint) | 145 if (timing.paint_timing->first_paint) |
146 matched_bits.Set(TimingField::FIRST_PAINT); | 146 matched_bits.Set(TimingField::FIRST_PAINT); |
147 if (timing.paint_timing.first_contentful_paint) | 147 if (timing.paint_timing->first_contentful_paint) |
148 matched_bits.Set(TimingField::FIRST_CONTENTFUL_PAINT); | 148 matched_bits.Set(TimingField::FIRST_CONTENTFUL_PAINT); |
149 if (timing.paint_timing.first_meaningful_paint) | 149 if (timing.paint_timing->first_meaningful_paint) |
150 matched_bits.Set(TimingField::FIRST_MEANINGFUL_PAINT); | 150 matched_bits.Set(TimingField::FIRST_MEANINGFUL_PAINT); |
151 if (timing.style_sheet_timing.update_style_duration_before_fcp) | 151 if (timing.style_sheet_timing->update_style_duration_before_fcp) |
152 matched_bits.Set(TimingField::STYLE_UPDATE_BEFORE_FCP); | 152 matched_bits.Set(TimingField::STYLE_UPDATE_BEFORE_FCP); |
153 if (metadata.behavior_flags & | 153 if (metadata.behavior_flags & |
154 blink::WebLoadingBehaviorFlag:: | 154 blink::WebLoadingBehaviorFlag:: |
155 kWebLoadingBehaviorDocumentWriteBlockReload) | 155 kWebLoadingBehaviorDocumentWriteBlockReload) |
156 matched_bits.Set(TimingField::DOCUMENT_WRITE_BLOCK_RELOAD); | 156 matched_bits.Set(TimingField::DOCUMENT_WRITE_BLOCK_RELOAD); |
157 | 157 |
158 return matched_bits; | 158 return matched_bits; |
159 } | 159 } |
160 | 160 |
161 void OnTimingUpdated( | 161 void OnTimingUpdated( |
162 bool is_main_frame, | 162 bool is_main_frame, |
163 const page_load_metrics::PageLoadTiming& timing, | 163 const page_load_metrics::mojom::PageLoadTiming& timing, |
164 const page_load_metrics::PageLoadMetadata& metadata) override { | 164 const page_load_metrics::mojom::PageLoadMetadata& metadata) override { |
165 if (expectations_satisfied()) | 165 if (expectations_satisfied()) |
166 return; | 166 return; |
167 | 167 |
168 TimingFieldBitSet matched_bits = GetMatchedBits(timing, metadata); | 168 TimingFieldBitSet matched_bits = GetMatchedBits(timing, metadata); |
169 if (is_main_frame) { | 169 if (is_main_frame) { |
170 main_frame_expected_fields_.ClearMatching(matched_bits); | 170 main_frame_expected_fields_.ClearMatching(matched_bits); |
171 observed_main_frame_fields_.Merge(matched_bits); | 171 observed_main_frame_fields_.Merge(matched_bits); |
172 } else { | 172 } else { |
173 child_frame_expected_fields_.ClearMatching(matched_bits); | 173 child_frame_expected_fields_.ClearMatching(matched_bits); |
174 } | 174 } |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 // Payload histograms are only logged when a page load terminates, so force | 946 // Payload histograms are only logged when a page load terminates, so force |
947 // navigation to another page. | 947 // navigation to another page. |
948 NavigateToUntrackedUrl(); | 948 NavigateToUntrackedUrl(); |
949 | 949 |
950 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); | 950 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); |
951 | 951 |
952 // Verify that there is a single sample recorded in the 10kB bucket (the size | 952 // Verify that there is a single sample recorded in the 10kB bucket (the size |
953 // of the main HTML response). | 953 // of the main HTML response). |
954 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); | 954 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); |
955 } | 955 } |
OLD | NEW |