| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 ad_frames_data_[frame_tree_node_id] = ad_data; | 134 ad_frames_data_[frame_tree_node_id] = ad_data; |
| 135 | 135 |
| 136 ProcessOngoingNavigationResource(frame_tree_node_id); | 136 ProcessOngoingNavigationResource(frame_tree_node_id); |
| 137 return CONTINUE_OBSERVING; | 137 return CONTINUE_OBSERVING; |
| 138 } | 138 } |
| 139 | 139 |
| 140 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 140 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 141 AdsPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( | 141 AdsPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( |
| 142 const page_load_metrics::PageLoadTiming& timing, | 142 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 143 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 143 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 144 // The browser may come back, but there is no guarantee. To be safe, record | 144 // The browser may come back, but there is no guarantee. To be safe, record |
| 145 // what we have now and ignore future changes to this navigation. | 145 // what we have now and ignore future changes to this navigation. |
| 146 if (extra_info.did_commit) | 146 if (extra_info.did_commit) |
| 147 RecordHistograms(); | 147 RecordHistograms(); |
| 148 | 148 |
| 149 return STOP_OBSERVING; | 149 return STOP_OBSERVING; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void AdsPageLoadMetricsObserver::OnLoadedResource( | 152 void AdsPageLoadMetricsObserver::OnLoadedResource( |
| 153 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { | 153 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { |
| 154 ProcessLoadedResource(extra_request_info); | 154 ProcessLoadedResource(extra_request_info); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void AdsPageLoadMetricsObserver::OnComplete( | 157 void AdsPageLoadMetricsObserver::OnComplete( |
| 158 const page_load_metrics::PageLoadTiming& timing, | 158 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 159 const page_load_metrics::PageLoadExtraInfo& info) { | 159 const page_load_metrics::PageLoadExtraInfo& info) { |
| 160 RecordHistograms(); | 160 RecordHistograms(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void AdsPageLoadMetricsObserver::ProcessLoadedResource( | 163 void AdsPageLoadMetricsObserver::ProcessLoadedResource( |
| 164 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { | 164 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { |
| 165 if (!extra_request_info.url.SchemeIsHTTPOrHTTPS()) { | 165 if (!extra_request_info.url.SchemeIsHTTPOrHTTPS()) { |
| 166 // Data uris should be accounted for in the generating resource, not | 166 // Data uris should be accounted for in the generating resource, not |
| 167 // here. Blobs for PlzNavigate shouldn't be counted as the http resource | 167 // here. Blobs for PlzNavigate shouldn't be counted as the http resource |
| 168 // was already counted. Blobs for other things like CacheStorage or | 168 // was already counted. Blobs for other things like CacheStorage or |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 277 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
| 278 FrameTreeNodeId frame_tree_node_id) { | 278 FrameTreeNodeId frame_tree_node_id) { |
| 279 const auto& frame_id_and_request = | 279 const auto& frame_id_and_request = |
| 280 ongoing_navigation_resources_.find(frame_tree_node_id); | 280 ongoing_navigation_resources_.find(frame_tree_node_id); |
| 281 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 281 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 ProcessLoadedResource(frame_id_and_request->second); | 284 ProcessLoadedResource(frame_id_and_request->second); |
| 285 ongoing_navigation_resources_.erase(frame_id_and_request); | 285 ongoing_navigation_resources_.erase(frame_id_and_request); |
| 286 } | 286 } |
| OLD | NEW |