Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2506)

Unified Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2804093002: Various page_load_metrics cleanups and improvements (Closed)
Patch Set: address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
index e3f51bf4946a1b2cc9437a0e973f4b77a78e5325..018fb614306215aeae09d16c6090b8926a411234 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -39,6 +39,16 @@ namespace page_load_metrics {
namespace {
+content::RenderFrameHost* GetMainFrame(content::RenderFrameHost* rfh) {
+ // Don't use rfh->GetRenderViewHost()->GetMainFrame() here because
+ // RenderViewHost is being deprecated and because in OOPIF,
+ // RenderViewHost::GetMainFrame() returns nullptr for child frames hosted in a
+ // different process from the main frame.
+ while (rfh->GetParent() != nullptr)
+ rfh = rfh->GetParent();
+ return rfh;
+}
+
UserInitiatedInfo CreateUserInitiatedInfo(
content::NavigationHandle* navigation_handle,
PageLoadTracker* committed_load) {
@@ -107,9 +117,7 @@ void MetricsWebContentsObserver::MediaStartedPlaying(
const content::WebContentsObserver::MediaPlayerInfo& video_type,
const content::WebContentsObserver::MediaPlayerId& id) {
content::RenderFrameHost* render_frame_host = id.first;
- if (!render_frame_host->GetRenderViewHost() ||
- render_frame_host->GetRenderViewHost()->GetMainFrame() !=
- web_contents()->GetMainFrame()) {
+ if (GetMainFrame(render_frame_host) != web_contents()->GetMainFrame()) {
// Ignore media that starts playing in a document that was navigated away
// from.
return;
@@ -527,9 +535,7 @@ void MetricsWebContentsObserver::OnTimingUpdated(
const PageLoadMetadata& metadata) {
// We may receive notifications from frames that have been navigated away
// from. We simply ignore them.
- if (!render_frame_host->GetRenderViewHost() ||
- render_frame_host->GetRenderViewHost()->GetMainFrame() !=
- web_contents()->GetMainFrame()) {
+ if (GetMainFrame(render_frame_host) != web_contents()->GetMainFrame()) {
RecordInternalError(ERR_IPC_FROM_WRONG_FRAME);
return;
}
@@ -561,12 +567,7 @@ void MetricsWebContentsObserver::OnTimingUpdated(
return;
}
- if (!committed_load_->UpdateTiming(timing, metadata)) {
- // If the page load tracker cannot update its timing, something is wrong
- // with the IPC (it's from another load, or it's invalid in some other way).
- // We expect this to be a rare occurrence.
- RecordInternalError(ERR_BAD_TIMING_IPC);
- }
+ committed_load_->UpdateTiming(timing, metadata);
}
bool MetricsWebContentsObserver::ShouldTrackNavigation(
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698