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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2750553002: Add support for tracking loading behavior of child frames. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 aborted_provisional_loads_.clear(); 503 aborted_provisional_loads_.clear();
504 return last_aborted_load; 504 return last_aborted_load;
505 } 505 }
506 506
507 void MetricsWebContentsObserver::OnTimingUpdated( 507 void MetricsWebContentsObserver::OnTimingUpdated(
508 content::RenderFrameHost* render_frame_host, 508 content::RenderFrameHost* render_frame_host,
509 const PageLoadTiming& timing, 509 const PageLoadTiming& timing,
510 const PageLoadMetadata& metadata) { 510 const PageLoadMetadata& metadata) {
511 // We may receive notifications from frames that have been navigated away 511 // We may receive notifications from frames that have been navigated away
512 // from. We simply ignore them. 512 // from. We simply ignore them.
513 if (render_frame_host != web_contents()->GetMainFrame()) { 513 if (!render_frame_host->GetRenderViewHost() ||
514 render_frame_host->GetRenderViewHost()->GetMainFrame() !=
515 web_contents()->GetMainFrame()) {
514 RecordInternalError(ERR_IPC_FROM_WRONG_FRAME); 516 RecordInternalError(ERR_IPC_FROM_WRONG_FRAME);
515 return; 517 return;
516 } 518 }
517 519
518 // While timings arriving for the wrong frame are expected, we do not expect 520 // While timings arriving for the wrong frame are expected, we do not expect
519 // any of the errors below. Thus, we track occurrences of all errors below, 521 // any of the errors below. Thus, we track occurrences of all errors below,
520 // rather than returning early after encountering an error. 522 // rather than returning early after encountering an error.
521 523
522 bool error = false; 524 bool error = false;
523 if (!committed_load_) { 525 if (!committed_load_) {
524 RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD); 526 RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD);
525 error = true; 527 error = true;
526 } 528 }
527 529
528 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { 530 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
529 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); 531 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME);
530 error = true; 532 error = true;
531 } 533 }
532 534
533 if (error) 535 if (error)
534 return; 536 return;
535 537
538 if (render_frame_host->GetParent() != nullptr) {
539 // Child frames may send PageLoadMetadata updates, but not PageLoadTiming
540 // updates.
541 if (!timing.IsEmpty())
542 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME);
543 committed_load_->UpdateChildFrameMetadata(metadata);
544 return;
545 }
546
536 if (!committed_load_->UpdateTiming(timing, metadata)) { 547 if (!committed_load_->UpdateTiming(timing, metadata)) {
537 // If the page load tracker cannot update its timing, something is wrong 548 // If the page load tracker cannot update its timing, something is wrong
538 // with the IPC (it's from another load, or it's invalid in some other way). 549 // with the IPC (it's from another load, or it's invalid in some other way).
539 // We expect this to be a rare occurrence. 550 // We expect this to be a rare occurrence.
540 RecordInternalError(ERR_BAD_TIMING_IPC); 551 RecordInternalError(ERR_BAD_TIMING_IPC);
541 } 552 }
542 } 553 }
543 554
544 bool MetricsWebContentsObserver::ShouldTrackNavigation( 555 bool MetricsWebContentsObserver::ShouldTrackNavigation(
545 content::NavigationHandle* navigation_handle) const { 556 content::NavigationHandle* navigation_handle) const {
546 DCHECK(navigation_handle->IsInMainFrame()); 557 DCHECK(navigation_handle->IsInMainFrame());
547 DCHECK(!navigation_handle->HasCommitted() || 558 DCHECK(!navigation_handle->HasCommitted() ||
548 !navigation_handle->IsSamePage()); 559 !navigation_handle->IsSamePage());
549 560
550 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 561 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
551 navigation_handle).ShouldTrack(); 562 navigation_handle).ShouldTrack();
552 } 563 }
553 564
554 } // namespace page_load_metrics 565 } // namespace page_load_metrics
OLDNEW
« 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