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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 } | 306 } |
| 307 | 307 |
| 308 const PageLoadExtraInfo | 308 const PageLoadExtraInfo |
| 309 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { | 309 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { |
| 310 DCHECK(committed_load_); | 310 DCHECK(committed_load_); |
| 311 return committed_load_->ComputePageLoadExtraInfo(); | 311 return committed_load_->ComputePageLoadExtraInfo(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void MetricsWebContentsObserver::DidFinishNavigation( | 314 void MetricsWebContentsObserver::DidFinishNavigation( |
| 315 content::NavigationHandle* navigation_handle) { | 315 content::NavigationHandle* navigation_handle) { |
| 316 if (GetMainFrame(navigation_handle->GetRenderFrameHost()) != | |
|
jkarlin
2017/05/08 13:00:41
I *think* that GetRFH will dcheck if the navigatio
Bryan McQuade
2017/05/08 15:26:31
ah, good catch, thanks! I moved this check into th
| |
| 317 web_contents()->GetMainFrame()) { | |
| 318 // Ignore navigations for a main frame that was navigated away from. | |
| 319 return; | |
| 320 } | |
| 316 if (!navigation_handle->IsInMainFrame() && committed_load_) { | 321 if (!navigation_handle->IsInMainFrame() && committed_load_) { |
| 317 committed_load_->DidFinishSubFrameNavigation(navigation_handle); | 322 committed_load_->DidFinishSubFrameNavigation(navigation_handle); |
| 318 return; | 323 return; |
| 319 } | 324 } |
| 320 | 325 |
| 321 std::unique_ptr<PageLoadTracker> finished_nav( | 326 std::unique_ptr<PageLoadTracker> finished_nav( |
| 322 std::move(provisional_loads_[navigation_handle])); | 327 std::move(provisional_loads_[navigation_handle])); |
| 323 provisional_loads_.erase(navigation_handle); | 328 provisional_loads_.erase(navigation_handle); |
| 324 | 329 |
| 325 // Ignore same-document navigations. | 330 // Ignore same-document navigations. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 } | 593 } |
| 589 | 594 |
| 590 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { | 595 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { |
| 591 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); | 596 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); |
| 592 error = true; | 597 error = true; |
| 593 } | 598 } |
| 594 | 599 |
| 595 if (error) | 600 if (error) |
| 596 return; | 601 return; |
| 597 | 602 |
| 598 if (render_frame_host->GetParent() != nullptr) { | 603 const bool is_main_frame = (render_frame_host->GetParent() == nullptr); |
| 599 // Child frames may send PageLoadMetadata updates, but not PageLoadTiming | 604 if (is_main_frame) { |
| 600 // updates. | 605 committed_load_->UpdateTiming(timing, metadata); |
| 601 if (!timing.IsEmpty()) | 606 } else { |
| 602 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME); | 607 committed_load_->UpdateSubFrameTiming(render_frame_host, timing, metadata); |
| 603 committed_load_->UpdateChildFrameMetadata(metadata); | |
| 604 return; | |
| 605 } | 608 } |
| 606 | 609 |
| 607 committed_load_->UpdateTiming(timing, metadata); | |
| 608 | |
| 609 for (auto& observer : testing_observers_) | 610 for (auto& observer : testing_observers_) |
| 610 observer.OnTimingUpdated(timing, metadata); | 611 observer.OnTimingUpdated(is_main_frame, timing, metadata); |
| 611 } | 612 } |
| 612 | 613 |
| 613 bool MetricsWebContentsObserver::ShouldTrackNavigation( | 614 bool MetricsWebContentsObserver::ShouldTrackNavigation( |
| 614 content::NavigationHandle* navigation_handle) const { | 615 content::NavigationHandle* navigation_handle) const { |
| 615 DCHECK(navigation_handle->IsInMainFrame()); | 616 DCHECK(navigation_handle->IsInMainFrame()); |
| 616 DCHECK(!navigation_handle->HasCommitted() || | 617 DCHECK(!navigation_handle->HasCommitted() || |
| 617 !navigation_handle->IsSameDocument()); | 618 !navigation_handle->IsSameDocument()); |
| 618 | 619 |
| 619 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 620 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 620 navigation_handle).ShouldTrack(); | 621 navigation_handle).ShouldTrack(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 642 observer_->RemoveTestingObserver(this); | 643 observer_->RemoveTestingObserver(this); |
| 643 observer_ = nullptr; | 644 observer_ = nullptr; |
| 644 } | 645 } |
| 645 } | 646 } |
| 646 | 647 |
| 647 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { | 648 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { |
| 648 observer_ = nullptr; | 649 observer_ = nullptr; |
| 649 } | 650 } |
| 650 | 651 |
| 651 } // namespace page_load_metrics | 652 } // namespace page_load_metrics |
| OLD | NEW |