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

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

Issue 2223453003: Thread user gesture through page_load_metrics abort pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: thread user gesture through page_load_metrics Created 4 years, 4 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
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (new_timing.first_contentful_paint && !last_timing.first_contentful_paint) 236 if (new_timing.first_contentful_paint && !last_timing.first_contentful_paint)
237 observer->OnFirstContentfulPaint(new_timing, extra_info); 237 observer->OnFirstContentfulPaint(new_timing, extra_info);
238 if (new_timing.parse_start && !last_timing.parse_start) 238 if (new_timing.parse_start && !last_timing.parse_start)
239 observer->OnParseStart(new_timing, extra_info); 239 observer->OnParseStart(new_timing, extra_info);
240 if (new_timing.parse_stop && !last_timing.parse_stop) 240 if (new_timing.parse_stop && !last_timing.parse_stop)
241 observer->OnParseStop(new_timing, extra_info); 241 observer->OnParseStop(new_timing, extra_info);
242 if (extra_info.metadata.behavior_flags != last_metadata.behavior_flags) 242 if (extra_info.metadata.behavior_flags != last_metadata.behavior_flags)
243 observer->OnLoadingBehaviorObserved(extra_info); 243 observer->OnLoadingBehaviorObserved(extra_info);
244 } 244 }
245 245
246 // TODO(crbug.com/617904): Browser initiated navigations should have
shivanisha 2016/08/11 19:23:00 todo (csharrison) for consistency of style?
Charlie Harrison 2016/08/12 17:51:30 TODOs with crbugs are also ok style. I don't have
247 // HasUserGesture() set to true.
shivanisha 2016/08/11 19:23:00 do we want to add a dcheck here to assert this?
Charlie Harrison 2016/08/12 17:51:30 No, because they don't currently have it set to tr
248 bool IsNavigationUserInitiated(content::NavigationHandle* handle) {
249 return handle->HasUserGesture() || !handle->IsRendererInitiated();
250 }
251
246 } // namespace 252 } // namespace
247 253
248 PageLoadTracker::PageLoadTracker( 254 PageLoadTracker::PageLoadTracker(
249 bool in_foreground, 255 bool in_foreground,
250 PageLoadMetricsEmbedderInterface* embedder_interface, 256 PageLoadMetricsEmbedderInterface* embedder_interface,
251 const GURL& currently_committed_url, 257 const GURL& currently_committed_url,
252 content::NavigationHandle* navigation_handle, 258 content::NavigationHandle* navigation_handle,
253 int aborted_chain_size, 259 int aborted_chain_size,
254 int aborted_chain_size_same_url) 260 int aborted_chain_size_same_url)
255 : did_stop_tracking_(false), 261 : did_stop_tracking_(false),
256 app_entered_background_(false), 262 app_entered_background_(false),
257 navigation_start_(navigation_handle->NavigationStart()), 263 navigation_start_(navigation_handle->NavigationStart()),
258 url_(navigation_handle->GetURL()), 264 url_(navigation_handle->GetURL()),
259 abort_type_(ABORT_NONE), 265 abort_type_(ABORT_NONE),
266 abort_user_initiated_(false),
260 started_in_foreground_(in_foreground), 267 started_in_foreground_(in_foreground),
261 page_transition_(navigation_handle->GetPageTransition()), 268 page_transition_(navigation_handle->GetPageTransition()),
269 user_gesture_(navigation_handle->HasUserGesture() ||
270 !navigation_handle->IsRendererInitiated()),
shivanisha 2016/08/11 19:23:01 call IsNavigationUserInitiated here?
Charlie Harrison 2016/08/12 17:51:30 Done.
262 aborted_chain_size_(aborted_chain_size), 271 aborted_chain_size_(aborted_chain_size),
263 aborted_chain_size_same_url_(aborted_chain_size_same_url), 272 aborted_chain_size_same_url_(aborted_chain_size_same_url),
264 embedder_interface_(embedder_interface) { 273 embedder_interface_(embedder_interface) {
265 DCHECK(!navigation_handle->HasCommitted()); 274 DCHECK(!navigation_handle->HasCommitted());
266 embedder_interface_->RegisterObservers(this); 275 embedder_interface_->RegisterObservers(this);
267 for (const auto& observer : observers_) { 276 for (const auto& observer : observers_) {
268 observer->OnStart(navigation_handle, currently_committed_url, 277 observer->OnStart(navigation_handle, currently_committed_url,
269 started_in_foreground_); 278 started_in_foreground_);
270 } 279 }
271 } 280 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 395 }
387 396
388 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { 397 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) {
389 // TODO(bmcquade): To improve accuracy, consider adding commit time to 398 // TODO(bmcquade): To improve accuracy, consider adding commit time to
390 // NavigationHandle. Taking a timestamp here should be close enough for now. 399 // NavigationHandle. Taking a timestamp here should be close enough for now.
391 commit_time_ = base::TimeTicks::Now(); 400 commit_time_ = base::TimeTicks::Now();
392 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); 401 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_);
393 url_ = navigation_handle->GetURL(); 402 url_ = navigation_handle->GetURL();
394 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. 403 // Some transitions (like CLIENT_REDIRECT) are only known at commit time.
395 page_transition_ = navigation_handle->GetPageTransition(); 404 page_transition_ = navigation_handle->GetPageTransition();
405 user_gesture_ = navigation_handle->HasUserGesture();
396 for (const auto& observer : observers_) { 406 for (const auto& observer : observers_) {
397 observer->OnCommit(navigation_handle); 407 observer->OnCommit(navigation_handle);
398 } 408 }
399 LogAbortChainHistograms(navigation_handle); 409 LogAbortChainHistograms(navigation_handle);
400 } 410 }
401 411
402 void PageLoadTracker::FailedProvisionalLoad( 412 void PageLoadTracker::FailedProvisionalLoad(
403 content::NavigationHandle* navigation_handle) { 413 content::NavigationHandle* navigation_handle) {
404 DCHECK(!failed_provisional_load_info_); 414 DCHECK(!failed_provisional_load_info_);
405 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( 415 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 time_to_abort = abort_time_ - navigation_start_; 545 time_to_abort = abort_time_ - navigation_start_;
536 } else { 546 } else {
537 DCHECK(abort_time_.is_null()); 547 DCHECK(abort_time_.is_null());
538 } 548 }
539 549
540 if (!commit_time_.is_null()) { 550 if (!commit_time_.is_null()) {
541 DCHECK_GE(commit_time_, navigation_start_); 551 DCHECK_GE(commit_time_, navigation_start_);
542 time_to_commit = commit_time_ - navigation_start_; 552 time_to_commit = commit_time_ - navigation_start_;
543 } 553 }
544 554
555 // abort_type_ == ABORT_NONE implies !abort_user_initiated_.
556 DCHECK(abort_type_ != ABORT_NONE || !abort_user_initiated_);
545 return PageLoadExtraInfo( 557 return PageLoadExtraInfo(
546 first_background_time, first_foreground_time, started_in_foreground_, 558 first_background_time, first_foreground_time, started_in_foreground_,
547 commit_time_.is_null() ? GURL() : url_, time_to_commit, abort_type_, 559 user_gesture_, commit_time_.is_null() ? GURL() : url_, time_to_commit,
548 time_to_abort, metadata_); 560 abort_type_, abort_user_initiated_, time_to_abort, metadata_);
549 } 561 }
550 562
551 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, 563 void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
564 bool user_initiated,
552 base::TimeTicks timestamp, 565 base::TimeTicks timestamp,
553 bool is_certainly_browser_timestamp) { 566 bool is_certainly_browser_timestamp) {
554 DCHECK_NE(abort_type, ABORT_NONE); 567 DCHECK_NE(abort_type, ABORT_NONE);
555 // Use UpdateAbort to update an already notified PageLoadTracker. 568 // Use UpdateAbort to update an already notified PageLoadTracker.
556 if (abort_type_ != ABORT_NONE) 569 if (abort_type_ != ABORT_NONE)
557 return; 570 return;
558 571
559 UpdateAbortInternal(abort_type, timestamp, is_certainly_browser_timestamp); 572 UpdateAbortInternal(abort_type, user_initiated, timestamp,
573 is_certainly_browser_timestamp);
560 } 574 }
561 575
562 void PageLoadTracker::UpdateAbort(UserAbortType abort_type, 576 void PageLoadTracker::UpdateAbort(UserAbortType abort_type,
577 bool user_initiated,
563 base::TimeTicks timestamp, 578 base::TimeTicks timestamp,
564 bool is_certainly_browser_timestamp) { 579 bool is_certainly_browser_timestamp) {
565 DCHECK_NE(abort_type, ABORT_NONE); 580 DCHECK_NE(abort_type, ABORT_NONE);
566 DCHECK_NE(abort_type, ABORT_OTHER); 581 DCHECK_NE(abort_type, ABORT_OTHER);
567 DCHECK_EQ(abort_type_, ABORT_OTHER); 582 DCHECK_EQ(abort_type_, ABORT_OTHER);
568 583
569 // For some aborts (e.g. navigations), the initiated timestamp can be earlier 584 // For some aborts (e.g. navigations), the initiated timestamp can be earlier
570 // than the timestamp that aborted the load. Taking the minimum gives the 585 // than the timestamp that aborted the load. Taking the minimum gives the
571 // closest user initiated time known. 586 // closest user initiated time known.
572 UpdateAbortInternal(abort_type, std::min(abort_time_, timestamp), 587 UpdateAbortInternal(abort_type, user_initiated,
588 std::min(abort_time_, timestamp),
573 is_certainly_browser_timestamp); 589 is_certainly_browser_timestamp);
574 } 590 }
575 591
576 bool PageLoadTracker::IsLikelyProvisionalAbort( 592 bool PageLoadTracker::IsLikelyProvisionalAbort(
577 base::TimeTicks abort_cause_time) const { 593 base::TimeTicks abort_cause_time) const {
578 // Note that |abort_cause_time - abort_time| can be negative. 594 // Note that |abort_cause_time - abort_time| can be negative.
579 return abort_type_ == ABORT_OTHER && 595 return abort_type_ == ABORT_OTHER &&
580 (abort_cause_time - abort_time_).InMilliseconds() < 100; 596 (abort_cause_time - abort_time_).InMilliseconds() < 100;
581 } 597 }
582 598
583 bool PageLoadTracker::MatchesOriginalNavigation( 599 bool PageLoadTracker::MatchesOriginalNavigation(
584 content::NavigationHandle* navigation_handle) { 600 content::NavigationHandle* navigation_handle) {
585 // Neither navigation should have committed. 601 // Neither navigation should have committed.
586 DCHECK(!navigation_handle->HasCommitted()); 602 DCHECK(!navigation_handle->HasCommitted());
587 DCHECK(commit_time_.is_null()); 603 DCHECK(commit_time_.is_null());
588 return navigation_handle->GetURL() == url_; 604 return navigation_handle->GetURL() == url_;
589 } 605 }
590 606
591 void PageLoadTracker::UpdateAbortInternal(UserAbortType abort_type, 607 void PageLoadTracker::UpdateAbortInternal(UserAbortType abort_type,
608 bool user_initiated,
592 base::TimeTicks timestamp, 609 base::TimeTicks timestamp,
593 bool is_certainly_browser_timestamp) { 610 bool is_certainly_browser_timestamp) {
594 // When a provisional navigation commits, that navigation's start time is 611 // When a provisional navigation commits, that navigation's start time is
595 // interpreted as the abort time for other provisional loads in the tab. 612 // interpreted as the abort time for other provisional loads in the tab.
596 // However, this only makes sense if the committed load started after the 613 // However, this only makes sense if the committed load started after the
597 // aborted provisional loads started. Thus we ignore cases where the committed 614 // aborted provisional loads started. Thus we ignore cases where the committed
598 // load started before the aborted provisional load, as this would result in 615 // load started before the aborted provisional load, as this would result in
599 // recording a negative time-to-abort. The real issue here is that we have to 616 // recording a negative time-to-abort. The real issue here is that we have to
600 // infer the cause of aborts. It would be better if the navigation code could 617 // infer the cause of aborts. It would be better if the navigation code could
601 // instead report the actual cause of an aborted navigation. See crbug/571647 618 // instead report the actual cause of an aborted navigation. See crbug/571647
602 // for details. 619 // for details.
603 if (timestamp < navigation_start_) { 620 if (timestamp < navigation_start_) {
604 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START); 621 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START);
605 abort_type_ = ABORT_NONE; 622 abort_type_ = ABORT_NONE;
606 abort_time_ = base::TimeTicks(); 623 abort_time_ = base::TimeTicks();
607 return; 624 return;
608 } 625 }
609 abort_type_ = abort_type; 626 abort_type_ = abort_type;
610 abort_time_ = timestamp; 627 abort_time_ = timestamp;
628 abort_user_initiated_ = user_initiated && abort_type != ABORT_CLIENT_REDIRECT;
611 629
612 if (is_certainly_browser_timestamp) { 630 if (is_certainly_browser_timestamp) {
613 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); 631 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_);
614 } 632 }
615 } 633 }
616 634
617 // static 635 // static
618 MetricsWebContentsObserver::MetricsWebContentsObserver( 636 MetricsWebContentsObserver::MetricsWebContentsObserver(
619 content::WebContents* web_contents, 637 content::WebContents* web_contents,
620 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) 638 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
(...skipping 12 matching lines...) Expand all
633 MetricsWebContentsObserver* metrics = FromWebContents(web_contents); 651 MetricsWebContentsObserver* metrics = FromWebContents(web_contents);
634 if (!metrics) { 652 if (!metrics) {
635 metrics = new MetricsWebContentsObserver(web_contents, 653 metrics = new MetricsWebContentsObserver(web_contents,
636 std::move(embedder_interface)); 654 std::move(embedder_interface));
637 web_contents->SetUserData(UserDataKey(), metrics); 655 web_contents->SetUserData(UserDataKey(), metrics);
638 } 656 }
639 return metrics; 657 return metrics;
640 } 658 }
641 659
642 MetricsWebContentsObserver::~MetricsWebContentsObserver() { 660 MetricsWebContentsObserver::~MetricsWebContentsObserver() {
643 NotifyAbortAllLoads(ABORT_CLOSE); 661 // TODO(csharrison): Use a more user-initiated signal for CLOSE.
662 NotifyAbortAllLoads(ABORT_CLOSE, false);
644 } 663 }
645 664
646 void MetricsWebContentsObserver::RegisterInputEventObserver( 665 void MetricsWebContentsObserver::RegisterInputEventObserver(
647 content::RenderViewHost* host) { 666 content::RenderViewHost* host) {
648 if (host != nullptr) 667 if (host != nullptr)
649 host->GetWidget()->AddInputEventObserver(this); 668 host->GetWidget()->AddInputEventObserver(this);
650 } 669 }
651 670
652 void MetricsWebContentsObserver::UnregisterInputEventObserver( 671 void MetricsWebContentsObserver::UnregisterInputEventObserver(
653 content::RenderViewHost* host) { 672 content::RenderViewHost* host) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 771
753 if (finished_nav && !should_track) 772 if (finished_nav && !should_track)
754 finished_nav->StopTracking(); 773 finished_nav->StopTracking();
755 774
756 if (navigation_handle->HasCommitted()) { 775 if (navigation_handle->HasCommitted()) {
757 // Ignore same-page navigations. 776 // Ignore same-page navigations.
758 if (navigation_handle->IsSamePage()) 777 if (navigation_handle->IsSamePage())
759 return; 778 return;
760 779
761 // Notify other loads that they may have been aborted by this committed 780 // Notify other loads that they may have been aborted by this committed
762 // load. Note that by using the committed navigation start as the abort 781 // load. is_certainly_browser_timestamp is set to false because
763 // cause, we lose data on provisional loads that were aborted by other 782 // NavigationStart() could be set in either the renderer or browser process.
764 // provisional loads. Those will either be listed as ABORT_OTHER or as being
765 // aborted by this load.
766 // is_certainly_browser_timestamp is set to false because NavigationStart()
767 // could be set in either the renderer or browser process.
768 NotifyAbortAllLoadsWithTimestamp( 783 NotifyAbortAllLoadsWithTimestamp(
769 AbortTypeForPageTransition(navigation_handle->GetPageTransition()), 784 AbortTypeForPageTransition(navigation_handle->GetPageTransition()),
785 IsNavigationUserInitiated(navigation_handle),
770 navigation_handle->NavigationStart(), false); 786 navigation_handle->NavigationStart(), false);
771 787
772 if (should_track) { 788 if (should_track) {
773 HandleCommittedNavigationForTrackedLoad(navigation_handle, 789 HandleCommittedNavigationForTrackedLoad(navigation_handle,
774 std::move(finished_nav)); 790 std::move(finished_nav));
775 } else { 791 } else {
776 committed_load_.reset(); 792 committed_load_.reset();
777 } 793 }
778 } else if (should_track) { 794 } else if (should_track) {
779 HandleFailedNavigationForTrackedLoad(navigation_handle, 795 HandleFailedNavigationForTrackedLoad(navigation_handle,
(...skipping 14 matching lines...) Expand all
794 net::Error error = navigation_handle->GetNetErrorCode(); 810 net::Error error = navigation_handle->GetNetErrorCode();
795 811
796 // net::OK: This case occurs when the NavigationHandle finishes and reports 812 // net::OK: This case occurs when the NavigationHandle finishes and reports
797 // !HasCommitted(), but reports no net::Error. This should not occur 813 // !HasCommitted(), but reports no net::Error. This should not occur
798 // pre-PlzNavigate, but afterwards it should represent the navigation stopped 814 // pre-PlzNavigate, but afterwards it should represent the navigation stopped
799 // by the user before it was ready to commit. 815 // by the user before it was ready to commit.
800 // net::ERR_ABORTED: An aborted provisional load has error 816 // net::ERR_ABORTED: An aborted provisional load has error
801 // net::ERR_ABORTED. Note that this can come from some non user-initiated 817 // net::ERR_ABORTED. Note that this can come from some non user-initiated
802 // errors, such as downloads, or 204 responses. See crbug.com/542369. 818 // errors, such as downloads, or 204 responses. See crbug.com/542369.
803 if ((error == net::OK) || (error == net::ERR_ABORTED)) { 819 if ((error == net::OK) || (error == net::ERR_ABORTED)) {
804 tracker->NotifyAbort(ABORT_OTHER, base::TimeTicks::Now(), true); 820 tracker->NotifyAbort(ABORT_OTHER, false, base::TimeTicks::Now(), true);
805 aborted_provisional_loads_.push_back(std::move(tracker)); 821 aborted_provisional_loads_.push_back(std::move(tracker));
806 } 822 }
807 } 823 }
808 824
809 void MetricsWebContentsObserver::HandleCommittedNavigationForTrackedLoad( 825 void MetricsWebContentsObserver::HandleCommittedNavigationForTrackedLoad(
810 content::NavigationHandle* navigation_handle, 826 content::NavigationHandle* navigation_handle,
811 std::unique_ptr<PageLoadTracker> tracker) { 827 std::unique_ptr<PageLoadTracker> tracker) {
812 if (!navigation_handle->HasUserGesture() && 828 if (!navigation_handle->HasUserGesture() &&
813 (navigation_handle->GetPageTransition() & 829 (navigation_handle->GetPageTransition() &
814 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 && 830 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
815 committed_load_) 831 committed_load_)
816 committed_load_->NotifyClientRedirectTo(*tracker); 832 committed_load_->NotifyClientRedirectTo(*tracker);
817 833
818 committed_load_ = std::move(tracker); 834 committed_load_ = std::move(tracker);
819 committed_load_->Commit(navigation_handle); 835 committed_load_->Commit(navigation_handle);
820 } 836 }
821 837
822 void MetricsWebContentsObserver::NavigationStopped() { 838 void MetricsWebContentsObserver::NavigationStopped() {
823 NotifyAbortAllLoads(ABORT_STOP); 839 // TODO(csharrison): Use a more user-initiated signal for STOP.
840 NotifyAbortAllLoads(ABORT_STOP, false);
824 } 841 }
825 842
826 void MetricsWebContentsObserver::OnInputEvent( 843 void MetricsWebContentsObserver::OnInputEvent(
827 const blink::WebInputEvent& event) { 844 const blink::WebInputEvent& event) {
828 // Ignore browser navigation or reload which comes with type Undefined. 845 // Ignore browser navigation or reload which comes with type Undefined.
829 if (event.type == blink::WebInputEvent::Type::Undefined) 846 if (event.type == blink::WebInputEvent::Type::Undefined)
830 return; 847 return;
831 848
832 if (committed_load_) 849 if (committed_load_)
833 committed_load_->OnInputEvent(event); 850 committed_load_->OnInputEvent(event);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 return; 907 return;
891 } 908 }
892 909
893 // If this is a crash, eagerly log the aborted provisional loads and the 910 // If this is a crash, eagerly log the aborted provisional loads and the
894 // committed load. |provisional_loads_| don't need to be destroyed here 911 // committed load. |provisional_loads_| don't need to be destroyed here
895 // because their lifetime is tied to the NavigationHandle. 912 // because their lifetime is tied to the NavigationHandle.
896 committed_load_.reset(); 913 committed_load_.reset();
897 aborted_provisional_loads_.clear(); 914 aborted_provisional_loads_.clear();
898 } 915 }
899 916
900 void MetricsWebContentsObserver::NotifyAbortAllLoads(UserAbortType abort_type) { 917 void MetricsWebContentsObserver::NotifyAbortAllLoads(UserAbortType abort_type,
901 NotifyAbortAllLoadsWithTimestamp(abort_type, base::TimeTicks::Now(), true); 918 bool user_initiated) {
919 NotifyAbortAllLoadsWithTimestamp(abort_type, user_initiated,
920 base::TimeTicks::Now(), true);
902 } 921 }
903 922
904 void MetricsWebContentsObserver::NotifyAbortAllLoadsWithTimestamp( 923 void MetricsWebContentsObserver::NotifyAbortAllLoadsWithTimestamp(
905 UserAbortType abort_type, 924 UserAbortType abort_type,
925 bool user_initiated,
906 base::TimeTicks timestamp, 926 base::TimeTicks timestamp,
907 bool is_certainly_browser_timestamp) { 927 bool is_certainly_browser_timestamp) {
908 if (committed_load_) { 928 if (committed_load_) {
909 committed_load_->NotifyAbort(abort_type, timestamp, 929 committed_load_->NotifyAbort(abort_type, user_initiated, timestamp,
910 is_certainly_browser_timestamp); 930 is_certainly_browser_timestamp);
911 } 931 }
912 for (const auto& kv : provisional_loads_) { 932 for (const auto& kv : provisional_loads_) {
913 kv.second->NotifyAbort(abort_type, timestamp, 933 kv.second->NotifyAbort(abort_type, user_initiated, timestamp,
914 is_certainly_browser_timestamp); 934 is_certainly_browser_timestamp);
915 } 935 }
916 for (const auto& tracker : aborted_provisional_loads_) { 936 for (const auto& tracker : aborted_provisional_loads_) {
917 if (tracker->IsLikelyProvisionalAbort(timestamp)) { 937 if (tracker->IsLikelyProvisionalAbort(timestamp)) {
918 tracker->UpdateAbort(abort_type, timestamp, 938 tracker->UpdateAbort(abort_type, user_initiated, timestamp,
919 is_certainly_browser_timestamp); 939 is_certainly_browser_timestamp);
920 } 940 }
921 } 941 }
922 aborted_provisional_loads_.clear(); 942 aborted_provisional_loads_.clear();
923 } 943 }
924 944
925 std::unique_ptr<PageLoadTracker> 945 std::unique_ptr<PageLoadTracker>
926 MetricsWebContentsObserver::NotifyAbortedProvisionalLoadsNewNavigation( 946 MetricsWebContentsObserver::NotifyAbortedProvisionalLoadsNewNavigation(
927 content::NavigationHandle* new_navigation) { 947 content::NavigationHandle* new_navigation) {
928 // If there are multiple aborted loads that can be attributed to this one, 948 // If there are multiple aborted loads that can be attributed to this one,
929 // just count the latest one for simplicity. Other loads will fall into the 949 // just count the latest one for simplicity. Other loads will fall into the
930 // OTHER bucket, though there shouldn't be very many. 950 // OTHER bucket, though there shouldn't be very many.
931 if (aborted_provisional_loads_.size() == 0) 951 if (aborted_provisional_loads_.size() == 0)
932 return nullptr; 952 return nullptr;
933 if (aborted_provisional_loads_.size() > 1) 953 if (aborted_provisional_loads_.size() > 1)
934 RecordInternalError(ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS); 954 RecordInternalError(ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS);
935 955
936 std::unique_ptr<PageLoadTracker> last_aborted_load = 956 std::unique_ptr<PageLoadTracker> last_aborted_load =
937 std::move(aborted_provisional_loads_.back()); 957 std::move(aborted_provisional_loads_.back());
938 aborted_provisional_loads_.pop_back(); 958 aborted_provisional_loads_.pop_back();
939 959
940 base::TimeTicks timestamp = new_navigation->NavigationStart(); 960 base::TimeTicks timestamp = new_navigation->NavigationStart();
941 if (last_aborted_load->IsLikelyProvisionalAbort(timestamp)) { 961 if (last_aborted_load->IsLikelyProvisionalAbort(timestamp)) {
942 last_aborted_load->UpdateAbort( 962 last_aborted_load->UpdateAbort(
943 AbortTypeForPageTransition(new_navigation->GetPageTransition()), 963 AbortTypeForPageTransition(new_navigation->GetPageTransition()),
944 timestamp, false); 964 IsNavigationUserInitiated(new_navigation), timestamp, false);
945 } 965 }
946 966
947 aborted_provisional_loads_.clear(); 967 aborted_provisional_loads_.clear();
948 return last_aborted_load; 968 return last_aborted_load;
949 } 969 }
950 970
951 void MetricsWebContentsObserver::OnTimingUpdated( 971 void MetricsWebContentsObserver::OnTimingUpdated(
952 content::RenderFrameHost* render_frame_host, 972 content::RenderFrameHost* render_frame_host,
953 const PageLoadTiming& timing, 973 const PageLoadTiming& timing,
954 const PageLoadMetadata& metadata) { 974 const PageLoadMetadata& metadata) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) 1016 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage())
997 return false; 1017 return false;
998 const std::string& mime_type = web_contents()->GetContentsMimeType(); 1018 const std::string& mime_type = web_contents()->GetContentsMimeType();
999 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") 1019 if (mime_type != "text/html" && mime_type != "application/xhtml+xml")
1000 return false; 1020 return false;
1001 } 1021 }
1002 return true; 1022 return true;
1003 } 1023 }
1004 1024
1005 } // namespace page_load_metrics 1025 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698