OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/page_load_metrics/observers/ads_page_load_metrics_obser ver.h" | 5 #include "chrome/browser/page_load_metrics/observers/ads_page_load_metrics_obser ver.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // This frame was previously not an ad, process it as usual. If it had | 115 // This frame was previously not an ad, process it as usual. If it had |
116 // any child frames that were ads, those will still be recorded. | 116 // any child frames that were ads, those will still be recorded. |
117 UMA_HISTOGRAM_BOOLEAN( | 117 UMA_HISTOGRAM_BOOLEAN( |
118 "PageLoad.Clients.Ads.Google.Navigations.NonAdFrameRenavigatedToAd", | 118 "PageLoad.Clients.Ads.Google.Navigations.NonAdFrameRenavigatedToAd", |
119 FrameIsAd(navigation_handle)); | 119 FrameIsAd(navigation_handle)); |
120 } | 120 } |
121 | 121 |
122 // Determine who the parent frame's ad ancestor is. | 122 // Determine who the parent frame's ad ancestor is. |
123 const auto& parent_id_and_data = | 123 const auto& parent_id_and_data = |
124 ad_frames_data_.find(parent_frame_host->GetFrameTreeNodeId()); | 124 ad_frames_data_.find(parent_frame_host->GetFrameTreeNodeId()); |
125 DCHECK(parent_id_and_data != ad_frames_data_.end()); | 125 if (parent_id_and_data == ad_frames_data_.end()) { |
126 // We don't know who the parent for this frame is. One possibility is that | |
127 // it's a frame from a previous navigation. | |
128 UMA_HISTOGRAM_BOOLEAN("PageLoad.Clients.Ads.Google.ParentExistsForSubFrame", | |
Bryan McQuade
2017/05/16 16:22:36
histogram reviewers typically ask me to factor thi
jkarlin
2017/05/16 17:16:09
Done.
| |
129 false); | |
130 return CONTINUE_OBSERVING; | |
131 } | |
132 UMA_HISTOGRAM_BOOLEAN("PageLoad.Clients.Ads.Google.ParentExistsForSubFrame", | |
133 true); | |
134 | |
126 AdFrameData* ad_data = parent_id_and_data->second; | 135 AdFrameData* ad_data = parent_id_and_data->second; |
127 | 136 |
128 if (!ad_data && FrameIsAd(navigation_handle)) { | 137 if (!ad_data && FrameIsAd(navigation_handle)) { |
129 // This frame is not nested within an ad frame but is itself an ad. | 138 // This frame is not nested within an ad frame but is itself an ad. |
130 ad_frames_data_storage_.emplace_back(frame_tree_node_id); | 139 ad_frames_data_storage_.emplace_back(frame_tree_node_id); |
131 ad_data = &ad_frames_data_storage_.back(); | 140 ad_data = &ad_frames_data_storage_.back(); |
132 } | 141 } |
133 | 142 |
134 ad_frames_data_[frame_tree_node_id] = ad_data; | 143 ad_frames_data_[frame_tree_node_id] = ad_data; |
135 | 144 |
(...skipping 30 matching lines...) Expand all Loading... | |
166 // Data uris should be accounted for in the generating resource, not | 175 // Data uris should be accounted for in the generating resource, not |
167 // here. Blobs for PlzNavigate shouldn't be counted as the http resource | 176 // here. Blobs for PlzNavigate shouldn't be counted as the http resource |
168 // was already counted. Blobs for other things like CacheStorage or | 177 // was already counted. Blobs for other things like CacheStorage or |
169 // IndexedDB are also ignored for now, as they're not normal HTTP loads. | 178 // IndexedDB are also ignored for now, as they're not normal HTTP loads. |
170 return; | 179 return; |
171 } | 180 } |
172 | 181 |
173 const auto& id_and_data = | 182 const auto& id_and_data = |
174 ad_frames_data_.find(extra_request_info.frame_tree_node_id); | 183 ad_frames_data_.find(extra_request_info.frame_tree_node_id); |
175 if (id_and_data == ad_frames_data_.end()) { | 184 if (id_and_data == ad_frames_data_.end()) { |
176 // This resource is for a frame that hasn't ever finished a navigation. We | 185 if (extra_request_info.resource_type == content::RESOURCE_TYPE_MAIN_FRAME || |
177 // expect it to be the frame's main resource but don't have enough | 186 extra_request_info.resource_type == content::RESOURCE_TYPE_SUB_FRAME) { |
178 // confidence in that to dcheck it. For example, there might be races | 187 // This resource request is the primary resource load for a frame that |
179 // between doc.written resources and navigation failure. | 188 // hasn't yet finished navigating. Hang onto the request info and replay |
180 // TODO(jkarlin): Add UMA to measure how often we see multiple resources | 189 // it once the frame finishes navigating. |
181 // for a frame before navigation finishes. | 190 ongoing_navigation_resources_.emplace( |
182 ongoing_navigation_resources_.emplace( | 191 std::piecewise_construct, |
183 std::piecewise_construct, | 192 std::forward_as_tuple(extra_request_info.frame_tree_node_id), |
184 std::forward_as_tuple(extra_request_info.frame_tree_node_id), | 193 std::forward_as_tuple( |
185 std::forward_as_tuple( | 194 extra_request_info.url, extra_request_info.frame_tree_node_id, |
186 extra_request_info.url, extra_request_info.frame_tree_node_id, | 195 extra_request_info.was_cached, extra_request_info.raw_body_bytes, |
187 extra_request_info.was_cached, extra_request_info.raw_body_bytes, | 196 extra_request_info.original_network_content_length, nullptr, |
188 extra_request_info.original_network_content_length, nullptr, | 197 extra_request_info.resource_type)); |
189 extra_request_info.resource_type)); | 198 UMA_HISTOGRAM_ENUMERATION( |
199 "PageLoad.Clients.Ads.Google.ResourceTypeWhenNoFrameFound", | |
200 extra_request_info.resource_type, content::RESOURCE_TYPE_LAST_TYPE); | |
201 } else { | |
202 // This is unexpected, it could be: | |
203 // 1. a resource from a previous navigation that started its resource | |
204 // load after this page started navigation. | |
205 // 2. possibly a resource from a document.written frame whose frame | |
206 // failure message has yet to arrive. (uncertain of this) | |
207 UMA_HISTOGRAM_ENUMERATION( | |
208 "PageLoad.Clients.Ads.Google.ResourceTypeWhenNoFrameFound", | |
Bryan McQuade
2017/05/16 16:22:36
can we use a different histogram name here, to dis
jkarlin
2017/05/16 17:16:09
They'll be different, as the case above will have
| |
209 extra_request_info.resource_type, content::RESOURCE_TYPE_LAST_TYPE); | |
210 } | |
190 return; | 211 return; |
191 } | 212 } |
192 | 213 |
193 page_bytes_ += extra_request_info.raw_body_bytes; | 214 page_bytes_ += extra_request_info.raw_body_bytes; |
194 if (!extra_request_info.was_cached) | 215 if (!extra_request_info.was_cached) |
195 uncached_page_bytes_ += extra_request_info.raw_body_bytes; | 216 uncached_page_bytes_ += extra_request_info.raw_body_bytes; |
196 | 217 |
197 // Determine if the frame (or its ancestor) is an ad, if so attribute the | 218 // Determine if the frame (or its ancestor) is an ad, if so attribute the |
198 // bytes to the highest ad ancestor. | 219 // bytes to the highest ad ancestor. |
199 AdFrameData* ancestor_data = id_and_data->second; | 220 AdFrameData* ancestor_data = id_and_data->second; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 298 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
278 FrameTreeNodeId frame_tree_node_id) { | 299 FrameTreeNodeId frame_tree_node_id) { |
279 const auto& frame_id_and_request = | 300 const auto& frame_id_and_request = |
280 ongoing_navigation_resources_.find(frame_tree_node_id); | 301 ongoing_navigation_resources_.find(frame_tree_node_id); |
281 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 302 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
282 return; | 303 return; |
283 | 304 |
284 ProcessLoadedResource(frame_id_and_request->second); | 305 ProcessLoadedResource(frame_id_and_request->second); |
285 ongoing_navigation_resources_.erase(frame_id_and_request); | 306 ongoing_navigation_resources_.erase(frame_id_and_request); |
286 } | 307 } |
OLD | NEW |