Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc

Issue 2874663005: [Page Load Metrics] Add mojom file to page load metrics. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 10 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Clears all bits set in the |other| bitset. 123 // Clears all bits set in the |other| bitset.
124 void ClearMatching(const TimingFieldBitSet& other) { 124 void ClearMatching(const TimingFieldBitSet& other) {
125 bitmask_ &= ~other.bitmask_; 125 bitmask_ &= ~other.bitmask_;
126 } 126 }
127 127
128 private: 128 private:
129 int bitmask_ = 0; 129 int bitmask_ = 0;
130 }; 130 };
131 131
132 static TimingFieldBitSet GetMatchedBits( 132 static TimingFieldBitSet GetMatchedBits(
133 const page_load_metrics::PageLoadTiming& timing, 133 const page_load_metrics::mojom::PageLoadTiming& timing,
134 const page_load_metrics::PageLoadMetadata& metadata) { 134 const page_load_metrics::mojom::PageLoadMetadata& metadata) {
135 TimingFieldBitSet matched_bits; 135 TimingFieldBitSet matched_bits;
136 if (timing.document_timing.first_layout) 136 if (timing.document_timing->first_layout)
137 matched_bits.Set(TimingField::FIRST_LAYOUT); 137 matched_bits.Set(TimingField::FIRST_LAYOUT);
138 if (timing.document_timing.load_event_start) 138 if (timing.document_timing->load_event_start)
139 matched_bits.Set(TimingField::LOAD_EVENT); 139 matched_bits.Set(TimingField::LOAD_EVENT);
140 if (timing.paint_timing.first_paint) 140 if (timing.paint_timing->first_paint)
141 matched_bits.Set(TimingField::FIRST_PAINT); 141 matched_bits.Set(TimingField::FIRST_PAINT);
142 if (timing.paint_timing.first_contentful_paint) 142 if (timing.paint_timing->first_contentful_paint)
143 matched_bits.Set(TimingField::FIRST_CONTENTFUL_PAINT); 143 matched_bits.Set(TimingField::FIRST_CONTENTFUL_PAINT);
144 if (timing.paint_timing.first_meaningful_paint) 144 if (timing.paint_timing->first_meaningful_paint)
145 matched_bits.Set(TimingField::FIRST_MEANINGFUL_PAINT); 145 matched_bits.Set(TimingField::FIRST_MEANINGFUL_PAINT);
146 if (timing.style_sheet_timing.update_style_duration_before_fcp) 146 if (timing.style_sheet_timing->update_style_duration_before_fcp)
147 matched_bits.Set(TimingField::STYLE_UPDATE_BEFORE_FCP); 147 matched_bits.Set(TimingField::STYLE_UPDATE_BEFORE_FCP);
148 if (metadata.behavior_flags & 148 if (metadata.behavior_flags &
149 blink::WebLoadingBehaviorFlag:: 149 blink::WebLoadingBehaviorFlag::
150 kWebLoadingBehaviorDocumentWriteBlockReload) 150 kWebLoadingBehaviorDocumentWriteBlockReload)
151 matched_bits.Set(TimingField::DOCUMENT_WRITE_BLOCK_RELOAD); 151 matched_bits.Set(TimingField::DOCUMENT_WRITE_BLOCK_RELOAD);
152 152
153 return matched_bits; 153 return matched_bits;
154 } 154 }
155 155
156 void OnTimingUpdated( 156 void OnTimingUpdated(
157 bool is_main_frame, 157 bool is_main_frame,
158 const page_load_metrics::PageLoadTiming& timing, 158 const page_load_metrics::mojom::PageLoadTiming& timing,
159 const page_load_metrics::PageLoadMetadata& metadata) override { 159 const page_load_metrics::mojom::PageLoadMetadata& metadata) override {
160 if (expectations_satisfied()) 160 if (expectations_satisfied())
161 return; 161 return;
162 162
163 TimingFieldBitSet matched_bits = GetMatchedBits(timing, metadata); 163 TimingFieldBitSet matched_bits = GetMatchedBits(timing, metadata);
164 if (is_main_frame) { 164 if (is_main_frame) {
165 main_frame_expected_fields_.ClearMatching(matched_bits); 165 main_frame_expected_fields_.ClearMatching(matched_bits);
166 observed_main_frame_fields_.Merge(matched_bits); 166 observed_main_frame_fields_.Merge(matched_bits);
167 } else { 167 } else {
168 child_frame_expected_fields_.ClearMatching(matched_bits); 168 child_frame_expected_fields_.ClearMatching(matched_bits);
169 } 169 }
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // Payload histograms are only logged when a page load terminates, so force 862 // Payload histograms are only logged when a page load terminates, so force
863 // navigation to another page. 863 // navigation to another page.
864 NavigateToUntrackedUrl(); 864 NavigateToUntrackedUrl();
865 865
866 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); 866 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1);
867 867
868 // Verify that there is a single sample recorded in the 10kB bucket (the size 868 // Verify that there is a single sample recorded in the 10kB bucket (the size
869 // of the main HTML response). 869 // of the main HTML response).
870 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); 870 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1);
871 } 871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698