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

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

Issue 2903693004: Make PageLoadMetricsWaiter more resilient (Closed)
Patch Set: rebase Created 3 years, 7 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 && 425 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
426 committed_load_) { 426 committed_load_) {
427 // TODO(bmcquade): consider carrying the user_gesture bit forward to the 427 // TODO(bmcquade): consider carrying the user_gesture bit forward to the
428 // redirected navigation. 428 // redirected navigation.
429 committed_load_->NotifyClientRedirectTo(*tracker); 429 committed_load_->NotifyClientRedirectTo(*tracker);
430 } 430 }
431 431
432 committed_load_ = std::move(tracker); 432 committed_load_ = std::move(tracker);
433 committed_load_->Commit(navigation_handle); 433 committed_load_->Commit(navigation_handle);
434 DCHECK(committed_load_->did_commit()); 434 DCHECK(committed_load_->did_commit());
435
436 for (auto& observer : testing_observers_)
Charlie Harrison 2017/05/25 19:35:33 nit: for loops in the file generally have braces.
Bryan McQuade 2017/05/25 19:54:05 All of the other testing observer for loops don't
Charlie Harrison 2017/05/25 19:59:44 Ah yea, only looked at those for loops close to th
437 observer.OnCommit(committed_load_.get());
435 } 438 }
436 439
437 void MetricsWebContentsObserver::NavigationStopped() { 440 void MetricsWebContentsObserver::NavigationStopped() {
438 // TODO(csharrison): Use a more user-initiated signal for STOP. 441 // TODO(csharrison): Use a more user-initiated signal for STOP.
439 NotifyPageEndAllLoads(END_STOP, UserInitiatedInfo::NotUserInitiated()); 442 NotifyPageEndAllLoads(END_STOP, UserInitiatedInfo::NotUserInitiated());
440 } 443 }
441 444
442 void MetricsWebContentsObserver::OnInputEvent( 445 void MetricsWebContentsObserver::OnInputEvent(
443 const blink::WebInputEvent& event) { 446 const blink::WebInputEvent& event) {
444 // Ignore browser navigation or reload which comes with type Undefined. 447 // Ignore browser navigation or reload which comes with type Undefined.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { 610 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
608 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); 611 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME);
609 error = true; 612 error = true;
610 } 613 }
611 614
612 if (error) 615 if (error)
613 return; 616 return;
614 617
615 committed_load_->metrics_update_dispatcher()->UpdateMetrics(render_frame_host, 618 committed_load_->metrics_update_dispatcher()->UpdateMetrics(render_frame_host,
616 timing, metadata); 619 timing, metadata);
617
618 const bool is_main_frame = (render_frame_host->GetParent() == nullptr);
619 for (auto& observer : testing_observers_)
620 observer.OnTimingUpdated(is_main_frame, timing, metadata);
621 } 620 }
622 621
623 void MetricsWebContentsObserver::OnUpdateTimingOverIPC( 622 void MetricsWebContentsObserver::OnUpdateTimingOverIPC(
624 content::RenderFrameHost* render_frame_host, 623 content::RenderFrameHost* render_frame_host,
625 const mojom::PageLoadTiming& timing, 624 const mojom::PageLoadTiming& timing,
626 const mojom::PageLoadMetadata& metadata) { 625 const mojom::PageLoadMetadata& metadata) {
627 DCHECK(!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication)); 626 DCHECK(!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
628 OnTimingUpdated(render_frame_host, timing, metadata); 627 OnTimingUpdated(render_frame_host, timing, metadata);
629 628
630 for (auto& observer : testing_observers_) 629 for (auto& observer : testing_observers_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 observer_->RemoveTestingObserver(this); 674 observer_->RemoveTestingObserver(this);
676 observer_ = nullptr; 675 observer_ = nullptr;
677 } 676 }
678 } 677 }
679 678
680 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { 679 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() {
681 observer_ = nullptr; 680 observer_ = nullptr;
682 } 681 }
683 682
684 } // namespace page_load_metrics 683 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698