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

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

Issue 2802693002: Revert of Simplify MetricsWebContentsObserver::OnTimingUpdated (Closed)
Patch Set: 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 | no next file » | 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 5d59ba4efb20d98dee6b7f252aa3806e3fb9cdda..e3f51bf4946a1b2cc9437a0e973f4b77a78e5325 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -525,6 +525,33 @@
content::RenderFrameHost* render_frame_host,
const PageLoadTiming& timing,
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()) {
+ RecordInternalError(ERR_IPC_FROM_WRONG_FRAME);
+ return;
+ }
+
+ // While timings arriving for the wrong frame are expected, we do not expect
+ // any of the errors below. Thus, we track occurrences of all errors below,
+ // rather than returning early after encountering an error.
+
+ bool error = false;
+ if (!committed_load_) {
+ RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD);
+ error = true;
+ }
+
+ if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
+ RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME);
+ error = true;
+ }
+
+ if (error)
+ return;
+
if (render_frame_host->GetParent() != nullptr) {
// Child frames may send PageLoadMetadata updates, but not PageLoadTiming
// updates.
@@ -534,31 +561,6 @@
return;
}
- // We may receive notifications from frames that have been navigated away
- // from. We simply ignore them.
- if (render_frame_host != web_contents()->GetMainFrame()) {
- RecordInternalError(ERR_IPC_FROM_WRONG_FRAME);
- return;
- }
-
- // While timings arriving for the wrong frame are expected, we do not expect
- // any of the errors below. Thus, we track occurrences of all errors below,
- // rather than returning early after encountering an error.
-
- bool error = false;
- if (!committed_load_) {
- RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD);
- error = true;
- }
-
- if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
- RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME);
- error = true;
- }
-
- if (error)
- 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).
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698