Chromium Code Reviews| 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 fe9f281890e4a367400eaeb18e15b0cdaee2880e..c5b730ec3e7bf896ed46dcd8983fdb8ad831b548 100644 |
| --- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc |
| +++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc |
| @@ -103,14 +103,23 @@ MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents( |
| return metrics; |
| } |
| -MetricsWebContentsObserver::~MetricsWebContentsObserver() { |
| +MetricsWebContentsObserver::~MetricsWebContentsObserver() {} |
| + |
| +void MetricsWebContentsObserver::WebContentsDestroyed() { |
| // TODO(csharrison): Use a more user-initiated signal for CLOSE. |
| NotifyPageEndAllLoads(END_CLOSE, UserInitiatedInfo::NotUserInitiated()); |
| + // We tear down PageLoadTrackers in WebContentsDestroyed, rather than in the |
| + // destructor, since |web_contents()| returns nullptr in the destructor, and |
| + // PageLoadMetricsObservers can cause code to execute that wants to be able to |
| + // access the current WebContents. |
| + committed_load_ = nullptr; |
| + provisional_loads_.clear(); |
| + aborted_provisional_loads_.clear(); |
| + |
| for (auto& observer : testing_observers_) |
| observer.OnGoingAway(); |
| } |
| - |
|
Charlie Harrison
2017/05/26 19:31:34
keep the whitespace
Bryan McQuade
2017/05/26 20:07:32
Done
|
| void MetricsWebContentsObserver::RegisterInputEventObserver( |
| content::RenderViewHost* host) { |
| if (host != nullptr) |