Commit 4fd17bfd authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/subresource_filter.

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=jkarlin@chromium.org

Bug: 1145565
Change-Id: Id5414833dd0227489e629f56ea4a94a7ad86df58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533023
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826433}
parent d82b9f56
...@@ -131,7 +131,7 @@ ContentSubresourceFilterThrottleManager:: ...@@ -131,7 +131,7 @@ ContentSubresourceFilterThrottleManager::
dealer_handle_(dealer_handle), dealer_handle_(dealer_handle),
client_(std::move(client)) { client_(std::move(client)) {
SubresourceFilterObserverManager::CreateForWebContents(web_contents); SubresourceFilterObserverManager::CreateForWebContents(web_contents);
scoped_observer_.Add( scoped_observation_.Observe(
SubresourceFilterObserverManager::FromWebContents(web_contents)); SubresourceFilterObserverManager::FromWebContents(web_contents));
} }
...@@ -141,7 +141,7 @@ ContentSubresourceFilterThrottleManager:: ...@@ -141,7 +141,7 @@ ContentSubresourceFilterThrottleManager::
void ContentSubresourceFilterThrottleManager::OnSubresourceFilterGoingAway() { void ContentSubresourceFilterThrottleManager::OnSubresourceFilterGoingAway() {
// Stop observing here because the observer manager could be destroyed by the // Stop observing here because the observer manager could be destroyed by the
// time this class is destroyed. // time this class is destroyed.
scoped_observer_.RemoveAll(); scoped_observation_.RemoveObservation();
} }
void ContentSubresourceFilterThrottleManager::RenderFrameDeleted( void ContentSubresourceFilterThrottleManager::RenderFrameDeleted(
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h" #include "components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h"
...@@ -272,8 +272,9 @@ class ContentSubresourceFilterThrottleManager ...@@ -272,8 +272,9 @@ class ContentSubresourceFilterThrottleManager
content::WebContentsFrameReceiverSet<mojom::SubresourceFilterHost> receiver_; content::WebContentsFrameReceiverSet<mojom::SubresourceFilterHost> receiver_;
ScopedObserver<SubresourceFilterObserverManager, SubresourceFilterObserver> base::ScopedObservation<SubresourceFilterObserverManager,
scoped_observer_{this}; SubresourceFilterObserver>
scoped_observation_{this};
// Lazily instantiated in EnsureRulesetHandle when the first page level // Lazily instantiated in EnsureRulesetHandle when the first page level
// activation is triggered. Will go away when there are no more activated // activation is triggered. Will go away when there are no more activated
......
...@@ -12,19 +12,18 @@ ...@@ -12,19 +12,18 @@
namespace subresource_filter { namespace subresource_filter {
TestSubresourceFilterObserver::TestSubresourceFilterObserver( TestSubresourceFilterObserver::TestSubresourceFilterObserver(
content::WebContents* web_contents) content::WebContents* web_contents) {
: scoped_observer_(this) {
auto* manager = auto* manager =
SubresourceFilterObserverManager::FromWebContents(web_contents); SubresourceFilterObserverManager::FromWebContents(web_contents);
DCHECK(manager); DCHECK(manager);
scoped_observer_.Add(manager); scoped_observation_.Observe(manager);
Observe(web_contents); Observe(web_contents);
} }
TestSubresourceFilterObserver::~TestSubresourceFilterObserver() {} TestSubresourceFilterObserver::~TestSubresourceFilterObserver() {}
void TestSubresourceFilterObserver::OnSubresourceFilterGoingAway() { void TestSubresourceFilterObserver::OnSubresourceFilterGoingAway() {
scoped_observer_.RemoveAll(); scoped_observation_.RemoveObservation();
} }
void TestSubresourceFilterObserver::OnPageActivationComputed( void TestSubresourceFilterObserver::OnPageActivationComputed(
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "components/safe_browsing/core/db/util.h" #include "components/safe_browsing/core/db/util.h"
#include "components/safe_browsing/core/db/v4_protocol_manager_util.h" #include "components/safe_browsing/core/db/v4_protocol_manager_util.h"
#include "components/subresource_filter/content/browser/subresource_filter_observer.h" #include "components/subresource_filter/content/browser/subresource_filter_observer.h"
...@@ -74,8 +74,9 @@ class TestSubresourceFilterObserver : public SubresourceFilterObserver, ...@@ -74,8 +74,9 @@ class TestSubresourceFilterObserver : public SubresourceFilterObserver,
pending_activations_; pending_activations_;
base::Optional<mojom::ActivationLevel> last_committed_activation_; base::Optional<mojom::ActivationLevel> last_committed_activation_;
ScopedObserver<SubresourceFilterObserverManager, SubresourceFilterObserver> base::ScopedObservation<SubresourceFilterObserverManager,
scoped_observer_; SubresourceFilterObserver>
scoped_observation_{this};
DISALLOW_COPY_AND_ASSIGN(TestSubresourceFilterObserver); DISALLOW_COPY_AND_ASSIGN(TestSubresourceFilterObserver);
}; };
......
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