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

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

Issue 2903693004: Make PageLoadMetricsWaiter more resilient (Closed)
Patch Set: fix compile Created 3 years, 6 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 && 435 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
436 committed_load_) { 436 committed_load_) {
437 // TODO(bmcquade): consider carrying the user_gesture bit forward to the 437 // TODO(bmcquade): consider carrying the user_gesture bit forward to the
438 // redirected navigation. 438 // redirected navigation.
439 committed_load_->NotifyClientRedirectTo(*tracker); 439 committed_load_->NotifyClientRedirectTo(*tracker);
440 } 440 }
441 441
442 committed_load_ = std::move(tracker); 442 committed_load_ = std::move(tracker);
443 committed_load_->Commit(navigation_handle); 443 committed_load_->Commit(navigation_handle);
444 DCHECK(committed_load_->did_commit()); 444 DCHECK(committed_load_->did_commit());
445
446 for (auto& observer : testing_observers_)
447 observer.OnCommit(committed_load_.get());
445 } 448 }
446 449
447 void MetricsWebContentsObserver::NavigationStopped() { 450 void MetricsWebContentsObserver::NavigationStopped() {
448 // TODO(csharrison): Use a more user-initiated signal for STOP. 451 // TODO(csharrison): Use a more user-initiated signal for STOP.
449 NotifyPageEndAllLoads(END_STOP, UserInitiatedInfo::NotUserInitiated()); 452 NotifyPageEndAllLoads(END_STOP, UserInitiatedInfo::NotUserInitiated());
450 } 453 }
451 454
452 void MetricsWebContentsObserver::OnInputEvent( 455 void MetricsWebContentsObserver::OnInputEvent(
453 const blink::WebInputEvent& event) { 456 const blink::WebInputEvent& event) {
454 // Ignore browser navigation or reload which comes with type Undefined. 457 // Ignore browser navigation or reload which comes with type Undefined.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { 620 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
618 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); 621 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME);
619 error = true; 622 error = true;
620 } 623 }
621 624
622 if (error) 625 if (error)
623 return; 626 return;
624 627
625 committed_load_->metrics_update_dispatcher()->UpdateMetrics(render_frame_host, 628 committed_load_->metrics_update_dispatcher()->UpdateMetrics(render_frame_host,
626 timing, metadata); 629 timing, metadata);
627
628 const bool is_main_frame = (render_frame_host->GetParent() == nullptr);
629 for (auto& observer : testing_observers_)
630 observer.OnTimingUpdated(is_main_frame, timing, metadata);
631 } 630 }
632 631
633 void MetricsWebContentsObserver::OnUpdateTimingOverIPC( 632 void MetricsWebContentsObserver::OnUpdateTimingOverIPC(
634 content::RenderFrameHost* render_frame_host, 633 content::RenderFrameHost* render_frame_host,
635 const mojom::PageLoadTiming& timing, 634 const mojom::PageLoadTiming& timing,
636 const mojom::PageLoadMetadata& metadata) { 635 const mojom::PageLoadMetadata& metadata) {
637 DCHECK(!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication)); 636 DCHECK(!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
638 OnTimingUpdated(render_frame_host, timing, metadata); 637 OnTimingUpdated(render_frame_host, timing, metadata);
639 638
640 for (auto& observer : testing_observers_) 639 for (auto& observer : testing_observers_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 observer_->RemoveTestingObserver(this); 684 observer_->RemoveTestingObserver(this);
686 observer_ = nullptr; 685 observer_ = nullptr;
687 } 686 }
688 } 687 }
689 688
690 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { 689 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() {
691 observer_ = nullptr; 690 observer_ = nullptr;
692 } 691 }
693 692
694 } // namespace page_load_metrics 693 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698