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

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: rebase 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (new_timing.first_meaningful_paint && !last_timing.first_meaningful_paint) 245 if (new_timing.first_meaningful_paint && !last_timing.first_meaningful_paint)
246 observer->OnFirstMeaningfulPaint(new_timing, extra_info); 246 observer->OnFirstMeaningfulPaint(new_timing, extra_info);
247 if (new_timing.parse_start && !last_timing.parse_start) 247 if (new_timing.parse_start && !last_timing.parse_start)
248 observer->OnParseStart(new_timing, extra_info); 248 observer->OnParseStart(new_timing, extra_info);
249 if (new_timing.parse_stop && !last_timing.parse_stop) 249 if (new_timing.parse_stop && !last_timing.parse_stop)
250 observer->OnParseStop(new_timing, extra_info); 250 observer->OnParseStop(new_timing, extra_info);
251 if (extra_info.metadata.behavior_flags != last_metadata.behavior_flags) 251 if (extra_info.metadata.behavior_flags != last_metadata.behavior_flags)
252 observer->OnLoadingBehaviorObserved(extra_info); 252 observer->OnLoadingBehaviorObserved(extra_info);
253 } 253 }
254 254
255 // TODO(crbug.com/617904): Browser initiated navigations should have
256 // HasUserGesture() set to true. Update this once we get enough data from just
257 // renderer initiated aborts.
258 bool IsNavigationUserInitiated(content::NavigationHandle* handle) {
259 return handle->HasUserGesture();
260 }
261
255 } // namespace 262 } // namespace
256 263
257 PageLoadTracker::PageLoadTracker( 264 PageLoadTracker::PageLoadTracker(
258 bool in_foreground, 265 bool in_foreground,
259 PageLoadMetricsEmbedderInterface* embedder_interface, 266 PageLoadMetricsEmbedderInterface* embedder_interface,
260 const GURL& currently_committed_url, 267 const GURL& currently_committed_url,
261 content::NavigationHandle* navigation_handle, 268 content::NavigationHandle* navigation_handle,
262 int aborted_chain_size, 269 int aborted_chain_size,
263 int aborted_chain_size_same_url) 270 int aborted_chain_size_same_url)
264 : did_stop_tracking_(false), 271 : did_stop_tracking_(false),
265 app_entered_background_(false), 272 app_entered_background_(false),
266 navigation_start_(navigation_handle->NavigationStart()), 273 navigation_start_(navigation_handle->NavigationStart()),
267 url_(navigation_handle->GetURL()), 274 url_(navigation_handle->GetURL()),
268 abort_type_(ABORT_NONE), 275 abort_type_(ABORT_NONE),
276 abort_user_initiated_(false),
269 started_in_foreground_(in_foreground), 277 started_in_foreground_(in_foreground),
270 page_transition_(navigation_handle->GetPageTransition()), 278 page_transition_(navigation_handle->GetPageTransition()),
271 num_cache_requests_(0), 279 num_cache_requests_(0),
272 num_network_requests_(0), 280 num_network_requests_(0),
281 user_gesture_(IsNavigationUserInitiated(navigation_handle)),
273 aborted_chain_size_(aborted_chain_size), 282 aborted_chain_size_(aborted_chain_size),
274 aborted_chain_size_same_url_(aborted_chain_size_same_url), 283 aborted_chain_size_same_url_(aborted_chain_size_same_url),
275 embedder_interface_(embedder_interface) { 284 embedder_interface_(embedder_interface) {
276 DCHECK(!navigation_handle->HasCommitted()); 285 DCHECK(!navigation_handle->HasCommitted());
277 embedder_interface_->RegisterObservers(this); 286 embedder_interface_->RegisterObservers(this);
278 for (const auto& observer : observers_) { 287 for (const auto& observer : observers_) {
279 observer->OnStart(navigation_handle, currently_committed_url, 288 observer->OnStart(navigation_handle, currently_committed_url,
280 started_in_foreground_); 289 started_in_foreground_);
281 } 290 }
282 } 291 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 406 }
398 407
399 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { 408 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) {
400 // TODO(bmcquade): To improve accuracy, consider adding commit time to 409 // TODO(bmcquade): To improve accuracy, consider adding commit time to
401 // NavigationHandle. Taking a timestamp here should be close enough for now. 410 // NavigationHandle. Taking a timestamp here should be close enough for now.
402 commit_time_ = base::TimeTicks::Now(); 411 commit_time_ = base::TimeTicks::Now();
403 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); 412 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_);
404 url_ = navigation_handle->GetURL(); 413 url_ = navigation_handle->GetURL();
405 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. 414 // Some transitions (like CLIENT_REDIRECT) are only known at commit time.
406 page_transition_ = navigation_handle->GetPageTransition(); 415 page_transition_ = navigation_handle->GetPageTransition();
416 user_gesture_ = navigation_handle->HasUserGesture();
407 for (const auto& observer : observers_) { 417 for (const auto& observer : observers_) {
408 observer->OnCommit(navigation_handle); 418 observer->OnCommit(navigation_handle);
409 } 419 }
410 LogAbortChainHistograms(navigation_handle); 420 LogAbortChainHistograms(navigation_handle);
411 } 421 }
412 422
413 void PageLoadTracker::FailedProvisionalLoad( 423 void PageLoadTracker::FailedProvisionalLoad(
414 content::NavigationHandle* navigation_handle) { 424 content::NavigationHandle* navigation_handle) {
415 DCHECK(!failed_provisional_load_info_); 425 DCHECK(!failed_provisional_load_info_);
416 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( 426 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 time_to_abort = abort_time_ - navigation_start_; 564 time_to_abort = abort_time_ - navigation_start_;
555 } else { 565 } else {
556 DCHECK(abort_time_.is_null()); 566 DCHECK(abort_time_.is_null());
557 } 567 }
558 568
559 if (!commit_time_.is_null()) { 569 if (!commit_time_.is_null()) {
560 DCHECK_GE(commit_time_, navigation_start_); 570 DCHECK_GE(commit_time_, navigation_start_);
561 time_to_commit = commit_time_ - navigation_start_; 571 time_to_commit = commit_time_ - navigation_start_;
562 } 572 }
563 573
574 // abort_type_ == ABORT_NONE implies !abort_user_initiated_.
575 DCHECK(abort_type_ != ABORT_NONE || !abort_user_initiated_);
564 return PageLoadExtraInfo( 576 return PageLoadExtraInfo(
565 first_background_time, first_foreground_time, started_in_foreground_, 577 first_background_time, first_foreground_time, started_in_foreground_,
566 commit_time_.is_null() ? GURL() : url_, time_to_commit, abort_type_, 578 user_gesture_, commit_time_.is_null() ? GURL() : url_, time_to_commit,
567 time_to_abort, num_cache_requests_, num_network_requests_, metadata_); 579 abort_type_, abort_user_initiated_, time_to_abort, num_cache_requests_,
580 num_network_requests_, metadata_);
568 } 581 }
569 582
570 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, 583 void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
584 bool user_initiated,
571 base::TimeTicks timestamp, 585 base::TimeTicks timestamp,
572 bool is_certainly_browser_timestamp) { 586 bool is_certainly_browser_timestamp) {
573 DCHECK_NE(abort_type, ABORT_NONE); 587 DCHECK_NE(abort_type, ABORT_NONE);
574 // Use UpdateAbort to update an already notified PageLoadTracker. 588 // Use UpdateAbort to update an already notified PageLoadTracker.
575 if (abort_type_ != ABORT_NONE) 589 if (abort_type_ != ABORT_NONE)
576 return; 590 return;
577 591
578 UpdateAbortInternal(abort_type, timestamp, is_certainly_browser_timestamp); 592 UpdateAbortInternal(abort_type, user_initiated, timestamp,
593 is_certainly_browser_timestamp);
579 } 594 }
580 595
581 void PageLoadTracker::UpdateAbort(UserAbortType abort_type, 596 void PageLoadTracker::UpdateAbort(UserAbortType abort_type,
597 bool user_initiated,
582 base::TimeTicks timestamp, 598 base::TimeTicks timestamp,
583 bool is_certainly_browser_timestamp) { 599 bool is_certainly_browser_timestamp) {
584 DCHECK_NE(abort_type, ABORT_NONE); 600 DCHECK_NE(abort_type, ABORT_NONE);
585 DCHECK_NE(abort_type, ABORT_OTHER); 601 DCHECK_NE(abort_type, ABORT_OTHER);
586 DCHECK_EQ(abort_type_, ABORT_OTHER); 602 DCHECK_EQ(abort_type_, ABORT_OTHER);
587 603
588 // For some aborts (e.g. navigations), the initiated timestamp can be earlier 604 // For some aborts (e.g. navigations), the initiated timestamp can be earlier
589 // than the timestamp that aborted the load. Taking the minimum gives the 605 // than the timestamp that aborted the load. Taking the minimum gives the
590 // closest user initiated time known. 606 // closest user initiated time known.
591 UpdateAbortInternal(abort_type, std::min(abort_time_, timestamp), 607 UpdateAbortInternal(abort_type, user_initiated,
608 std::min(abort_time_, timestamp),
592 is_certainly_browser_timestamp); 609 is_certainly_browser_timestamp);
593 } 610 }
594 611
595 bool PageLoadTracker::IsLikelyProvisionalAbort( 612 bool PageLoadTracker::IsLikelyProvisionalAbort(
596 base::TimeTicks abort_cause_time) const { 613 base::TimeTicks abort_cause_time) const {
597 // Note that |abort_cause_time - abort_time| can be negative. 614 // Note that |abort_cause_time - abort_time| can be negative.
598 return abort_type_ == ABORT_OTHER && 615 return abort_type_ == ABORT_OTHER &&
599 (abort_cause_time - abort_time_).InMilliseconds() < 100; 616 (abort_cause_time - abort_time_).InMilliseconds() < 100;
600 } 617 }
601 618
602 bool PageLoadTracker::MatchesOriginalNavigation( 619 bool PageLoadTracker::MatchesOriginalNavigation(
603 content::NavigationHandle* navigation_handle) { 620 content::NavigationHandle* navigation_handle) {
604 // Neither navigation should have committed. 621 // Neither navigation should have committed.
605 DCHECK(!navigation_handle->HasCommitted()); 622 DCHECK(!navigation_handle->HasCommitted());
606 DCHECK(commit_time_.is_null()); 623 DCHECK(commit_time_.is_null());
607 return navigation_handle->GetURL() == url_; 624 return navigation_handle->GetURL() == url_;
608 } 625 }
609 626
610 void PageLoadTracker::UpdateAbortInternal(UserAbortType abort_type, 627 void PageLoadTracker::UpdateAbortInternal(UserAbortType abort_type,
628 bool user_initiated,
611 base::TimeTicks timestamp, 629 base::TimeTicks timestamp,
612 bool is_certainly_browser_timestamp) { 630 bool is_certainly_browser_timestamp) {
613 // When a provisional navigation commits, that navigation's start time is 631 // When a provisional navigation commits, that navigation's start time is
614 // interpreted as the abort time for other provisional loads in the tab. 632 // interpreted as the abort time for other provisional loads in the tab.
615 // However, this only makes sense if the committed load started after the 633 // However, this only makes sense if the committed load started after the
616 // aborted provisional loads started. Thus we ignore cases where the committed 634 // aborted provisional loads started. Thus we ignore cases where the committed
617 // load started before the aborted provisional load, as this would result in 635 // load started before the aborted provisional load, as this would result in
618 // recording a negative time-to-abort. The real issue here is that we have to 636 // recording a negative time-to-abort. The real issue here is that we have to
619 // infer the cause of aborts. It would be better if the navigation code could 637 // infer the cause of aborts. It would be better if the navigation code could
620 // instead report the actual cause of an aborted navigation. See crbug/571647 638 // instead report the actual cause of an aborted navigation. See crbug/571647
621 // for details. 639 // for details.
622 if (timestamp < navigation_start_) { 640 if (timestamp < navigation_start_) {
623 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START); 641 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START);
624 abort_type_ = ABORT_NONE; 642 abort_type_ = ABORT_NONE;
625 abort_time_ = base::TimeTicks(); 643 abort_time_ = base::TimeTicks();
626 return; 644 return;
627 } 645 }
628 abort_type_ = abort_type; 646 abort_type_ = abort_type;
629 abort_time_ = timestamp; 647 abort_time_ = timestamp;
648 abort_user_initiated_ = user_initiated && abort_type != ABORT_CLIENT_REDIRECT;
630 649
631 if (is_certainly_browser_timestamp) { 650 if (is_certainly_browser_timestamp) {
632 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); 651 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_);
633 } 652 }
634 } 653 }
635 654
636 // static 655 // static
637 MetricsWebContentsObserver::MetricsWebContentsObserver( 656 MetricsWebContentsObserver::MetricsWebContentsObserver(
638 content::WebContents* web_contents, 657 content::WebContents* web_contents,
639 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) 658 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
(...skipping 12 matching lines...) Expand all
652 MetricsWebContentsObserver* metrics = FromWebContents(web_contents); 671 MetricsWebContentsObserver* metrics = FromWebContents(web_contents);
653 if (!metrics) { 672 if (!metrics) {
654 metrics = new MetricsWebContentsObserver(web_contents, 673 metrics = new MetricsWebContentsObserver(web_contents,
655 std::move(embedder_interface)); 674 std::move(embedder_interface));
656 web_contents->SetUserData(UserDataKey(), metrics); 675 web_contents->SetUserData(UserDataKey(), metrics);
657 } 676 }
658 return metrics; 677 return metrics;
659 } 678 }
660 679
661 MetricsWebContentsObserver::~MetricsWebContentsObserver() { 680 MetricsWebContentsObserver::~MetricsWebContentsObserver() {
662 NotifyAbortAllLoads(ABORT_CLOSE); 681 // TODO(csharrison): Use a more user-initiated signal for CLOSE.
682 NotifyAbortAllLoads(ABORT_CLOSE, false);
663 } 683 }
664 684
665 void MetricsWebContentsObserver::RegisterInputEventObserver( 685 void MetricsWebContentsObserver::RegisterInputEventObserver(
666 content::RenderViewHost* host) { 686 content::RenderViewHost* host) {
667 if (host != nullptr) 687 if (host != nullptr)
668 host->GetWidget()->AddInputEventObserver(this); 688 host->GetWidget()->AddInputEventObserver(this);
669 } 689 }
670 690
671 void MetricsWebContentsObserver::UnregisterInputEventObserver( 691 void MetricsWebContentsObserver::UnregisterInputEventObserver(
672 content::RenderViewHost* host) { 692 content::RenderViewHost* host) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 807
788 if (finished_nav && !should_track) 808 if (finished_nav && !should_track)
789 finished_nav->StopTracking(); 809 finished_nav->StopTracking();
790 810
791 if (navigation_handle->HasCommitted()) { 811 if (navigation_handle->HasCommitted()) {
792 // Ignore same-page navigations. 812 // Ignore same-page navigations.
793 if (navigation_handle->IsSamePage()) 813 if (navigation_handle->IsSamePage())
794 return; 814 return;
795 815
796 // Notify other loads that they may have been aborted by this committed 816 // Notify other loads that they may have been aborted by this committed
797 // load. Note that by using the committed navigation start as the abort 817 // load. is_certainly_browser_timestamp is set to false because
798 // cause, we lose data on provisional loads that were aborted by other 818 // NavigationStart() could be set in either the renderer or browser process.
799 // provisional loads. Those will either be listed as ABORT_OTHER or as being
800 // aborted by this load.
801 // is_certainly_browser_timestamp is set to false because NavigationStart()
802 // could be set in either the renderer or browser process.
803 NotifyAbortAllLoadsWithTimestamp( 819 NotifyAbortAllLoadsWithTimestamp(
804 AbortTypeForPageTransition(navigation_handle->GetPageTransition()), 820 AbortTypeForPageTransition(navigation_handle->GetPageTransition()),
821 IsNavigationUserInitiated(navigation_handle),
805 navigation_handle->NavigationStart(), false); 822 navigation_handle->NavigationStart(), false);
806 823
807 if (should_track) { 824 if (should_track) {
808 HandleCommittedNavigationForTrackedLoad(navigation_handle, 825 HandleCommittedNavigationForTrackedLoad(navigation_handle,
809 std::move(finished_nav)); 826 std::move(finished_nav));
810 } else { 827 } else {
811 committed_load_.reset(); 828 committed_load_.reset();
812 } 829 }
813 } else if (should_track) { 830 } else if (should_track) {
814 HandleFailedNavigationForTrackedLoad(navigation_handle, 831 HandleFailedNavigationForTrackedLoad(navigation_handle,
(...skipping 14 matching lines...) Expand all
829 net::Error error = navigation_handle->GetNetErrorCode(); 846 net::Error error = navigation_handle->GetNetErrorCode();
830 847
831 // net::OK: This case occurs when the NavigationHandle finishes and reports 848 // net::OK: This case occurs when the NavigationHandle finishes and reports
832 // !HasCommitted(), but reports no net::Error. This should not occur 849 // !HasCommitted(), but reports no net::Error. This should not occur
833 // pre-PlzNavigate, but afterwards it should represent the navigation stopped 850 // pre-PlzNavigate, but afterwards it should represent the navigation stopped
834 // by the user before it was ready to commit. 851 // by the user before it was ready to commit.
835 // net::ERR_ABORTED: An aborted provisional load has error 852 // net::ERR_ABORTED: An aborted provisional load has error
836 // net::ERR_ABORTED. Note that this can come from some non user-initiated 853 // net::ERR_ABORTED. Note that this can come from some non user-initiated
837 // errors, such as downloads, or 204 responses. See crbug.com/542369. 854 // errors, such as downloads, or 204 responses. See crbug.com/542369.
838 if ((error == net::OK) || (error == net::ERR_ABORTED)) { 855 if ((error == net::OK) || (error == net::ERR_ABORTED)) {
839 tracker->NotifyAbort(ABORT_OTHER, base::TimeTicks::Now(), true); 856 tracker->NotifyAbort(ABORT_OTHER, false, base::TimeTicks::Now(), true);
840 aborted_provisional_loads_.push_back(std::move(tracker)); 857 aborted_provisional_loads_.push_back(std::move(tracker));
841 } 858 }
842 } 859 }
843 860
844 void MetricsWebContentsObserver::HandleCommittedNavigationForTrackedLoad( 861 void MetricsWebContentsObserver::HandleCommittedNavigationForTrackedLoad(
845 content::NavigationHandle* navigation_handle, 862 content::NavigationHandle* navigation_handle,
846 std::unique_ptr<PageLoadTracker> tracker) { 863 std::unique_ptr<PageLoadTracker> tracker) {
847 if (!navigation_handle->HasUserGesture() && 864 if (!navigation_handle->HasUserGesture() &&
848 (navigation_handle->GetPageTransition() & 865 (navigation_handle->GetPageTransition() &
849 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 && 866 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
850 committed_load_) 867 committed_load_)
851 committed_load_->NotifyClientRedirectTo(*tracker); 868 committed_load_->NotifyClientRedirectTo(*tracker);
852 869
853 committed_load_ = std::move(tracker); 870 committed_load_ = std::move(tracker);
854 committed_load_->Commit(navigation_handle); 871 committed_load_->Commit(navigation_handle);
855 } 872 }
856 873
857 void MetricsWebContentsObserver::NavigationStopped() { 874 void MetricsWebContentsObserver::NavigationStopped() {
858 NotifyAbortAllLoads(ABORT_STOP); 875 // TODO(csharrison): Use a more user-initiated signal for STOP.
876 NotifyAbortAllLoads(ABORT_STOP, false);
859 } 877 }
860 878
861 void MetricsWebContentsObserver::OnInputEvent( 879 void MetricsWebContentsObserver::OnInputEvent(
862 const blink::WebInputEvent& event) { 880 const blink::WebInputEvent& event) {
863 // Ignore browser navigation or reload which comes with type Undefined. 881 // Ignore browser navigation or reload which comes with type Undefined.
864 if (event.type == blink::WebInputEvent::Type::Undefined) 882 if (event.type == blink::WebInputEvent::Type::Undefined)
865 return; 883 return;
866 884
867 if (committed_load_) 885 if (committed_load_)
868 committed_load_->OnInputEvent(event); 886 committed_load_->OnInputEvent(event);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 return; 943 return;
926 } 944 }
927 945
928 // If this is a crash, eagerly log the aborted provisional loads and the 946 // If this is a crash, eagerly log the aborted provisional loads and the
929 // committed load. |provisional_loads_| don't need to be destroyed here 947 // committed load. |provisional_loads_| don't need to be destroyed here
930 // because their lifetime is tied to the NavigationHandle. 948 // because their lifetime is tied to the NavigationHandle.
931 committed_load_.reset(); 949 committed_load_.reset();
932 aborted_provisional_loads_.clear(); 950 aborted_provisional_loads_.clear();
933 } 951 }
934 952
935 void MetricsWebContentsObserver::NotifyAbortAllLoads(UserAbortType abort_type) { 953 void MetricsWebContentsObserver::NotifyAbortAllLoads(UserAbortType abort_type,
936 NotifyAbortAllLoadsWithTimestamp(abort_type, base::TimeTicks::Now(), true); 954 bool user_initiated) {
955 NotifyAbortAllLoadsWithTimestamp(abort_type, user_initiated,
956 base::TimeTicks::Now(), true);
937 } 957 }
938 958
939 void MetricsWebContentsObserver::NotifyAbortAllLoadsWithTimestamp( 959 void MetricsWebContentsObserver::NotifyAbortAllLoadsWithTimestamp(
940 UserAbortType abort_type, 960 UserAbortType abort_type,
961 bool user_initiated,
941 base::TimeTicks timestamp, 962 base::TimeTicks timestamp,
942 bool is_certainly_browser_timestamp) { 963 bool is_certainly_browser_timestamp) {
943 if (committed_load_) { 964 if (committed_load_) {
944 committed_load_->NotifyAbort(abort_type, timestamp, 965 committed_load_->NotifyAbort(abort_type, user_initiated, timestamp,
945 is_certainly_browser_timestamp); 966 is_certainly_browser_timestamp);
946 } 967 }
947 for (const auto& kv : provisional_loads_) { 968 for (const auto& kv : provisional_loads_) {
948 kv.second->NotifyAbort(abort_type, timestamp, 969 kv.second->NotifyAbort(abort_type, user_initiated, timestamp,
949 is_certainly_browser_timestamp); 970 is_certainly_browser_timestamp);
950 } 971 }
951 for (const auto& tracker : aborted_provisional_loads_) { 972 for (const auto& tracker : aborted_provisional_loads_) {
952 if (tracker->IsLikelyProvisionalAbort(timestamp)) { 973 if (tracker->IsLikelyProvisionalAbort(timestamp)) {
953 tracker->UpdateAbort(abort_type, timestamp, 974 tracker->UpdateAbort(abort_type, user_initiated, timestamp,
954 is_certainly_browser_timestamp); 975 is_certainly_browser_timestamp);
955 } 976 }
956 } 977 }
957 aborted_provisional_loads_.clear(); 978 aborted_provisional_loads_.clear();
958 } 979 }
959 980
960 std::unique_ptr<PageLoadTracker> 981 std::unique_ptr<PageLoadTracker>
961 MetricsWebContentsObserver::NotifyAbortedProvisionalLoadsNewNavigation( 982 MetricsWebContentsObserver::NotifyAbortedProvisionalLoadsNewNavigation(
962 content::NavigationHandle* new_navigation) { 983 content::NavigationHandle* new_navigation) {
963 // If there are multiple aborted loads that can be attributed to this one, 984 // If there are multiple aborted loads that can be attributed to this one,
964 // just count the latest one for simplicity. Other loads will fall into the 985 // just count the latest one for simplicity. Other loads will fall into the
965 // OTHER bucket, though there shouldn't be very many. 986 // OTHER bucket, though there shouldn't be very many.
966 if (aborted_provisional_loads_.size() == 0) 987 if (aborted_provisional_loads_.size() == 0)
967 return nullptr; 988 return nullptr;
968 if (aborted_provisional_loads_.size() > 1) 989 if (aborted_provisional_loads_.size() > 1)
969 RecordInternalError(ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS); 990 RecordInternalError(ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS);
970 991
971 std::unique_ptr<PageLoadTracker> last_aborted_load = 992 std::unique_ptr<PageLoadTracker> last_aborted_load =
972 std::move(aborted_provisional_loads_.back()); 993 std::move(aborted_provisional_loads_.back());
973 aborted_provisional_loads_.pop_back(); 994 aborted_provisional_loads_.pop_back();
974 995
975 base::TimeTicks timestamp = new_navigation->NavigationStart(); 996 base::TimeTicks timestamp = new_navigation->NavigationStart();
976 if (last_aborted_load->IsLikelyProvisionalAbort(timestamp)) { 997 if (last_aborted_load->IsLikelyProvisionalAbort(timestamp)) {
977 last_aborted_load->UpdateAbort( 998 last_aborted_load->UpdateAbort(
978 AbortTypeForPageTransition(new_navigation->GetPageTransition()), 999 AbortTypeForPageTransition(new_navigation->GetPageTransition()),
979 timestamp, false); 1000 IsNavigationUserInitiated(new_navigation), timestamp, false);
980 } 1001 }
981 1002
982 aborted_provisional_loads_.clear(); 1003 aborted_provisional_loads_.clear();
983 return last_aborted_load; 1004 return last_aborted_load;
984 } 1005 }
985 1006
986 void MetricsWebContentsObserver::OnTimingUpdated( 1007 void MetricsWebContentsObserver::OnTimingUpdated(
987 content::RenderFrameHost* render_frame_host, 1008 content::RenderFrameHost* render_frame_host,
988 const PageLoadTiming& timing, 1009 const PageLoadTiming& timing,
989 const PageLoadMetadata& metadata) { 1010 const PageLoadMetadata& metadata) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) 1052 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage())
1032 return false; 1053 return false;
1033 const std::string& mime_type = web_contents()->GetContentsMimeType(); 1054 const std::string& mime_type = web_contents()->GetContentsMimeType();
1034 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") 1055 if (mime_type != "text/html" && mime_type != "application/xhtml+xml")
1035 return false; 1056 return false;
1036 } 1057 }
1037 return true; 1058 return true;
1038 } 1059 }
1039 1060
1040 } // namespace page_load_metrics 1061 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698