Chromium Code Reviews| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::OnRequestComplete( | 255 void MetricsWebContentsObserver::OnRequestComplete( |
| 256 const GURL& url, | |
| 257 int frame_tree_node_id, | |
| 256 const content::GlobalRequestID& request_id, | 258 const content::GlobalRequestID& request_id, |
| 257 content::ResourceType resource_type, | 259 content::ResourceType resource_type, |
| 258 bool was_cached, | 260 bool was_cached, |
| 259 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 261 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 260 data_reduction_proxy_data, | 262 data_reduction_proxy_data, |
| 261 int64_t raw_body_bytes, | 263 int64_t raw_body_bytes, |
| 262 int64_t original_content_length, | 264 int64_t original_content_length, |
| 263 base::TimeTicks creation_time) { | 265 base::TimeTicks creation_time) { |
| 264 PageLoadTracker* tracker = | 266 PageLoadTracker* tracker = |
| 265 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); | 267 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); |
| 266 if (tracker) { | 268 if (tracker) { |
| 267 ExtraRequestInfo extra_request_info( | 269 ExtraRequestInfo extra_request_info( |
| 268 was_cached, raw_body_bytes, was_cached ? 0 : original_content_length, | 270 url, frame_tree_node_id, was_cached, raw_body_bytes, |
| 271 was_cached ? 0 : original_content_length, | |
| 269 std::move(data_reduction_proxy_data)); | 272 std::move(data_reduction_proxy_data)); |
| 270 tracker->OnLoadedResource(extra_request_info); | 273 tracker->OnLoadedResource(extra_request_info); |
| 271 } | 274 } |
| 272 } | 275 } |
| 273 | 276 |
| 274 void MetricsWebContentsObserver::OnNavigationDelayComplete( | 277 void MetricsWebContentsObserver::OnNavigationDelayComplete( |
| 275 content::NavigationHandle* navigation_handle, | 278 content::NavigationHandle* navigation_handle, |
| 276 base::TimeDelta scheduled_delay, | 279 base::TimeDelta scheduled_delay, |
| 277 base::TimeDelta actual_delay) { | 280 base::TimeDelta actual_delay) { |
| 278 auto it = provisional_loads_.find(navigation_handle); | 281 auto it = provisional_loads_.find(navigation_handle); |
| 279 if (it == provisional_loads_.end()) | 282 if (it == provisional_loads_.end()) |
| 280 return; | 283 return; |
| 281 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay); | 284 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay); |
| 282 } | 285 } |
| 283 | 286 |
| 284 const PageLoadExtraInfo | 287 const PageLoadExtraInfo |
| 285 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { | 288 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { |
| 286 DCHECK(committed_load_); | 289 DCHECK(committed_load_); |
| 287 return committed_load_->ComputePageLoadExtraInfo(); | 290 return committed_load_->ComputePageLoadExtraInfo(); |
| 288 } | 291 } |
| 289 | 292 |
| 290 void MetricsWebContentsObserver::DidFinishNavigation( | 293 void MetricsWebContentsObserver::DidFinishNavigation( |
| 291 content::NavigationHandle* navigation_handle) { | 294 content::NavigationHandle* navigation_handle) { |
| 292 if (!navigation_handle->IsInMainFrame()) | 295 if (!navigation_handle->IsInMainFrame() && committed_load_) { |
|
Bryan McQuade
2017/04/25 16:36:44
i think we should still return early if it's not a
Bryan McQuade
2017/04/25 16:37:59
sorry, my brain has apparently not fired up yet. p
| |
| 296 committed_load_->DidFinishSubFrameNavigation(navigation_handle); | |
| 293 return; | 297 return; |
| 298 } | |
| 294 | 299 |
| 295 std::unique_ptr<PageLoadTracker> finished_nav( | 300 std::unique_ptr<PageLoadTracker> finished_nav( |
| 296 std::move(provisional_loads_[navigation_handle])); | 301 std::move(provisional_loads_[navigation_handle])); |
| 297 provisional_loads_.erase(navigation_handle); | 302 provisional_loads_.erase(navigation_handle); |
| 298 | 303 |
| 299 // Ignore same-document navigations. | 304 // Ignore same-document navigations. |
| 300 if (navigation_handle->HasCommitted() && | 305 if (navigation_handle->HasCommitted() && |
| 301 navigation_handle->IsSameDocument()) { | 306 navigation_handle->IsSameDocument()) { |
| 302 if (finished_nav) | 307 if (finished_nav) |
| 303 finished_nav->StopTracking(); | 308 finished_nav->StopTracking(); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 content::NavigationHandle* navigation_handle) const { | 590 content::NavigationHandle* navigation_handle) const { |
| 586 DCHECK(navigation_handle->IsInMainFrame()); | 591 DCHECK(navigation_handle->IsInMainFrame()); |
| 587 DCHECK(!navigation_handle->HasCommitted() || | 592 DCHECK(!navigation_handle->HasCommitted() || |
| 588 !navigation_handle->IsSameDocument()); | 593 !navigation_handle->IsSameDocument()); |
| 589 | 594 |
| 590 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 595 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 591 navigation_handle).ShouldTrack(); | 596 navigation_handle).ShouldTrack(); |
| 592 } | 597 } |
| 593 | 598 |
| 594 } // namespace page_load_metrics | 599 } // namespace page_load_metrics |
| OLD | NEW |