| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 ad_frames_data_[frame_tree_node_id] = ad_data; | 147 ad_frames_data_[frame_tree_node_id] = ad_data; |
| 148 | 148 |
| 149 ProcessOngoingNavigationResource(frame_tree_node_id); | 149 ProcessOngoingNavigationResource(frame_tree_node_id); |
| 150 return CONTINUE_OBSERVING; | 150 return CONTINUE_OBSERVING; |
| 151 } | 151 } |
| 152 | 152 |
| 153 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 153 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 154 AdsPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( | 154 AdsPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( |
| 155 const page_load_metrics::PageLoadTiming& timing, | 155 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 156 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 156 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 157 // The browser may come back, but there is no guarantee. To be safe, record | 157 // The browser may come back, but there is no guarantee. To be safe, record |
| 158 // what we have now and ignore future changes to this navigation. | 158 // what we have now and ignore future changes to this navigation. |
| 159 if (extra_info.did_commit) | 159 if (extra_info.did_commit) |
| 160 RecordHistograms(); | 160 RecordHistograms(); |
| 161 | 161 |
| 162 return STOP_OBSERVING; | 162 return STOP_OBSERVING; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void AdsPageLoadMetricsObserver::OnLoadedResource( | 165 void AdsPageLoadMetricsObserver::OnLoadedResource( |
| 166 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { | 166 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { |
| 167 ProcessLoadedResource(extra_request_info); | 167 ProcessLoadedResource(extra_request_info); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void AdsPageLoadMetricsObserver::OnComplete( | 170 void AdsPageLoadMetricsObserver::OnComplete( |
| 171 const page_load_metrics::PageLoadTiming& timing, | 171 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 172 const page_load_metrics::PageLoadExtraInfo& info) { | 172 const page_load_metrics::PageLoadExtraInfo& info) { |
| 173 RecordHistograms(); | 173 RecordHistograms(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void AdsPageLoadMetricsObserver::ProcessLoadedResource( | 176 void AdsPageLoadMetricsObserver::ProcessLoadedResource( |
| 177 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { | 177 const page_load_metrics::ExtraRequestCompleteInfo& extra_request_info) { |
| 178 if (!extra_request_info.url.SchemeIsHTTPOrHTTPS()) { | 178 if (!extra_request_info.url.SchemeIsHTTPOrHTTPS()) { |
| 179 // Data uris should be accounted for in the generating resource, not | 179 // Data uris should be accounted for in the generating resource, not |
| 180 // here. Blobs for PlzNavigate shouldn't be counted as the http resource | 180 // here. Blobs for PlzNavigate shouldn't be counted as the http resource |
| 181 // was already counted. Blobs for other things like CacheStorage or | 181 // was already counted. Blobs for other things like CacheStorage or |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 300 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
| 301 FrameTreeNodeId frame_tree_node_id) { | 301 FrameTreeNodeId frame_tree_node_id) { |
| 302 const auto& frame_id_and_request = | 302 const auto& frame_id_and_request = |
| 303 ongoing_navigation_resources_.find(frame_tree_node_id); | 303 ongoing_navigation_resources_.find(frame_tree_node_id); |
| 304 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 304 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
| 305 return; | 305 return; |
| 306 | 306 |
| 307 ProcessLoadedResource(frame_id_and_request->second); | 307 ProcessLoadedResource(frame_id_and_request->second); |
| 308 ongoing_navigation_resources_.erase(frame_id_and_request); | 308 ongoing_navigation_resources_.erase(frame_id_and_request); |
| 309 } | 309 } |
| OLD | NEW |