Commit b42ced69 authored by arthursonzogni's avatar arthursonzogni Committed by Chromium LUCI CQ

Revert "Retire ScopedObserver in HungPagesTableModel".

Instead of trying to forward fix, dumbly revert the cause of crashes.
Hopefully, just in time before M89 branch cut.

This revert will fix:
- https://crbug.com/1153966
- https://crbug.com/1153961

This revert part of:
https://chromium-review.googlesource.com/c/chromium/src/+/2548022
```
Retire ScopedObserver in /chrome/browser/ui/views.

ScopedObserver is being deprecated in favor of two new classes:
- base::ScopedObservation for observers that only ever observe
  a single source.
- base::ScopedMultiSourceObservation for observers that do or may
  observe more than a single source.

This CL was uploaded by git cl split.

R=bsep@chromium.org

Bug: 1145565
```

There was an existing bug. Unexpectedly, HungPagesTableModel::
InitForWebContents() can be called twice. See
https://crbug.com/1165917. For some reasons, this didn't resulted in any
crashes...

...until the reverted patch cames in.
The old base::ScopedObserver was supporting multiple observations. The
new one: base::ScopedObservation doesn't. As a result, if
base::ScopedObservation::Observe is called twice, then RemoveObserver
will be called only once instead of two, causing the issue.

Bug: 1153966,1153961
Change-Id: Iecc8e8e0e9fa387795ce55b4414d1d871cc4c9a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625867Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842940}
parent 6aa07208
......@@ -80,8 +80,8 @@ void HungPagesTableModel::InitForWebContents(
DCHECK(!hang_monitor_restarter.is_null());
DCHECK(!render_widget_host_);
DCHECK(!process_observation_.IsObserving());
DCHECK(!widget_observation_.IsObserving());
DCHECK(!process_observer_.IsObservingSources());
DCHECK(!widget_observer_.IsObservingSources());
DCHECK(tab_observers_.empty());
render_widget_host_ = render_widget_host;
......@@ -93,8 +93,8 @@ void HungPagesTableModel::InitForWebContents(
std::make_unique<WebContentsObserverImpl>(this, hung_contents));
}
process_observation_.Observe(render_widget_host_->GetProcess());
widget_observation_.Observe(render_widget_host_);
process_observer_.Add(render_widget_host_->GetProcess());
widget_observer_.Add(render_widget_host_);
// The world is different.
if (observer_)
......@@ -102,8 +102,8 @@ void HungPagesTableModel::InitForWebContents(
}
void HungPagesTableModel::Reset() {
process_observation_.Reset();
widget_observation_.Reset();
process_observer_.RemoveAll();
widget_observer_.RemoveAll();
tab_observers_.clear();
render_widget_host_ = nullptr;
......@@ -158,8 +158,8 @@ void HungPagesTableModel::RenderProcessExited(
void HungPagesTableModel::RenderWidgetHostDestroyed(
content::RenderWidgetHost* widget_host) {
DCHECK(widget_observation_.IsObservingSource(render_widget_host_));
widget_observation_.Reset();
DCHECK(widget_observer_.IsObserving(render_widget_host_));
widget_observer_.Remove(widget_host);
render_widget_host_ = nullptr;
// Notify the delegate.
......
......@@ -10,7 +10,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/scoped_observation.h"
#include "base/scoped_observer.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h"
......@@ -124,13 +124,11 @@ class HungPagesTableModel : public ui::TableModel,
// some more until the renderer process responds).
base::RepeatingClosure hang_monitor_restarter_;
base::ScopedObservation<content::RenderProcessHost,
content::RenderProcessHostObserver>
process_observation_{this};
ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver>
process_observer_{this};
base::ScopedObservation<content::RenderWidgetHost,
content::RenderWidgetHostObserver>
widget_observation_{this};
ScopedObserver<content::RenderWidgetHost, content::RenderWidgetHostObserver>
widget_observer_{this};
DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment