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

Unified Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2372573005: Update OnCommit to return ObservePolicy. (Closed)
Patch Set: add tests Created 4 years, 3 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
index 0a1bf48d2475c23ef94aaf2c9fa5c120d7301306..f1f3e3fbe2eaef57f7f89ba03fc77425a04cacf7 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -442,8 +442,14 @@ void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) {
// Some transitions (like CLIENT_REDIRECT) are only known at commit time.
page_transition_ = navigation_handle->GetPageTransition();
user_gesture_ = navigation_handle->HasUserGesture();
- for (const auto& observer : observers_) {
- observer->OnCommit(navigation_handle);
+
+ for (auto it = observers_.begin(); it != observers_.end();) {
Charlie Harrison 2016/09/27 16:32:48 Refactor this to a common method?
Bryan McQuade 2016/09/27 18:00:14 Sure, I factored it into a macro, per our conversa
+ if ((*it)->OnCommit(navigation_handle) ==
+ PageLoadMetricsObserver::STOP_OBSERVING) {
+ it = observers_.erase(it);
+ } else {
+ ++it;
+ }
}
LogAbortChainHistograms(navigation_handle);
}
« 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