Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 435 | 435 |
| 436 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { | 436 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { |
| 437 // TODO(bmcquade): To improve accuracy, consider adding commit time to | 437 // TODO(bmcquade): To improve accuracy, consider adding commit time to |
| 438 // NavigationHandle. Taking a timestamp here should be close enough for now. | 438 // NavigationHandle. Taking a timestamp here should be close enough for now. |
| 439 commit_time_ = base::TimeTicks::Now(); | 439 commit_time_ = base::TimeTicks::Now(); |
| 440 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); | 440 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); |
| 441 url_ = navigation_handle->GetURL(); | 441 url_ = navigation_handle->GetURL(); |
| 442 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. | 442 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. |
| 443 page_transition_ = navigation_handle->GetPageTransition(); | 443 page_transition_ = navigation_handle->GetPageTransition(); |
| 444 user_gesture_ = navigation_handle->HasUserGesture(); | 444 user_gesture_ = navigation_handle->HasUserGesture(); |
| 445 for (const auto& observer : observers_) { | 445 |
| 446 observer->OnCommit(navigation_handle); | 446 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
| |
| 447 if ((*it)->OnCommit(navigation_handle) == | |
| 448 PageLoadMetricsObserver::STOP_OBSERVING) { | |
| 449 it = observers_.erase(it); | |
| 450 } else { | |
| 451 ++it; | |
| 452 } | |
| 447 } | 453 } |
| 448 LogAbortChainHistograms(navigation_handle); | 454 LogAbortChainHistograms(navigation_handle); |
| 449 } | 455 } |
| 450 | 456 |
| 451 void PageLoadTracker::FailedProvisionalLoad( | 457 void PageLoadTracker::FailedProvisionalLoad( |
| 452 content::NavigationHandle* navigation_handle) { | 458 content::NavigationHandle* navigation_handle) { |
| 453 DCHECK(!failed_provisional_load_info_); | 459 DCHECK(!failed_provisional_load_info_); |
| 454 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( | 460 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( |
| 455 base::TimeTicks::Now() - navigation_handle->NavigationStart(), | 461 base::TimeTicks::Now() - navigation_handle->NavigationStart(), |
| 456 navigation_handle->GetNetErrorCode())); | 462 navigation_handle->GetNetErrorCode())); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1088 content::NavigationHandle* navigation_handle) const { | 1094 content::NavigationHandle* navigation_handle) const { |
| 1089 DCHECK(navigation_handle->IsInMainFrame()); | 1095 DCHECK(navigation_handle->IsInMainFrame()); |
| 1090 DCHECK(!navigation_handle->HasCommitted() || | 1096 DCHECK(!navigation_handle->HasCommitted() || |
| 1091 !navigation_handle->IsSamePage()); | 1097 !navigation_handle->IsSamePage()); |
| 1092 | 1098 |
| 1093 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 1099 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 1094 navigation_handle).ShouldTrack(); | 1100 navigation_handle).ShouldTrack(); |
| 1095 } | 1101 } |
| 1096 | 1102 |
| 1097 } // namespace page_load_metrics | 1103 } // namespace page_load_metrics |
| OLD | NEW |