| 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 "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // investigation is needed to confirm that all cases would be handled | 245 // investigation is needed to confirm that all cases would be handled |
| 246 // correctly (for example Link: preloads). | 246 // correctly (for example Link: preloads). |
| 247 if (committed_load_ && | 247 if (committed_load_ && |
| 248 creation_time >= committed_load_->navigation_start()) { | 248 creation_time >= committed_load_->navigation_start()) { |
| 249 return committed_load_.get(); | 249 return committed_load_.get(); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 return nullptr; | 252 return nullptr; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void MetricsWebContentsObserver::OnRequestStarted( |
| 256 const content::GlobalRequestID& request_id, |
| 257 content::ResourceType resource_type, |
| 258 base::TimeTicks creation_time) { |
| 259 // Note for the main HTML page, the tracker may not exist yet, so |
| 260 // OnStartedResource will not be called for the main page. While the main |
| 261 // page is not being tracked today, if we do decide to track it, we will need |
| 262 // to first make sure that GlobalRequestID is set in an earlier callback. |
| 263 // TODO(bmcquade): Evaluate whether moving tracker creation to |
| 264 // DidStartNavigation would address this. |
| 265 PageLoadTracker* tracker = |
| 266 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); |
| 267 if (tracker) { |
| 268 ExtraRequestStartInfo extra_request_start_info(resource_type); |
| 269 tracker->OnStartedResource(extra_request_start_info); |
| 270 } |
| 271 } |
| 272 |
| 255 void MetricsWebContentsObserver::OnRequestComplete( | 273 void MetricsWebContentsObserver::OnRequestComplete( |
| 256 const content::GlobalRequestID& request_id, | 274 const content::GlobalRequestID& request_id, |
| 257 content::ResourceType resource_type, | 275 content::ResourceType resource_type, |
| 258 bool was_cached, | 276 bool was_cached, |
| 259 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 277 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 260 data_reduction_proxy_data, | 278 data_reduction_proxy_data, |
| 261 int64_t raw_body_bytes, | 279 int64_t raw_body_bytes, |
| 262 int64_t original_content_length, | 280 int64_t original_content_length, |
| 263 base::TimeTicks creation_time) { | 281 base::TimeTicks creation_time) { |
| 264 PageLoadTracker* tracker = | 282 PageLoadTracker* tracker = |
| 265 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); | 283 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); |
| 266 if (tracker) { | 284 if (tracker) { |
| 267 ExtraRequestInfo extra_request_info( | 285 ExtraRequestCompleteInfo extra_request_complete_info( |
| 268 was_cached, raw_body_bytes, was_cached ? 0 : original_content_length, | 286 was_cached, raw_body_bytes, was_cached ? 0 : original_content_length, |
| 269 std::move(data_reduction_proxy_data)); | 287 std::move(data_reduction_proxy_data), resource_type); |
| 270 tracker->OnLoadedResource(extra_request_info); | 288 tracker->OnLoadedResource(extra_request_complete_info); |
| 271 } | 289 } |
| 272 } | 290 } |
| 273 | 291 |
| 274 void MetricsWebContentsObserver::OnNavigationDelayComplete( | 292 void MetricsWebContentsObserver::OnNavigationDelayComplete( |
| 275 content::NavigationHandle* navigation_handle, | 293 content::NavigationHandle* navigation_handle, |
| 276 base::TimeDelta scheduled_delay, | 294 base::TimeDelta scheduled_delay, |
| 277 base::TimeDelta actual_delay) { | 295 base::TimeDelta actual_delay) { |
| 278 auto it = provisional_loads_.find(navigation_handle); | 296 auto it = provisional_loads_.find(navigation_handle); |
| 279 if (it == provisional_loads_.end()) | 297 if (it == provisional_loads_.end()) |
| 280 return; | 298 return; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 content::NavigationHandle* navigation_handle) const { | 603 content::NavigationHandle* navigation_handle) const { |
| 586 DCHECK(navigation_handle->IsInMainFrame()); | 604 DCHECK(navigation_handle->IsInMainFrame()); |
| 587 DCHECK(!navigation_handle->HasCommitted() || | 605 DCHECK(!navigation_handle->HasCommitted() || |
| 588 !navigation_handle->IsSameDocument()); | 606 !navigation_handle->IsSameDocument()); |
| 589 | 607 |
| 590 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 608 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 591 navigation_handle).ShouldTrack(); | 609 navigation_handle).ShouldTrack(); |
| 592 } | 610 } |
| 593 | 611 |
| 594 } // namespace page_load_metrics | 612 } // namespace page_load_metrics |
| OLD | NEW |