Skip to content

Commit

Permalink
Replace ScopedObserver with base::ScopedObservation in /content/brows…
Browse files Browse the repository at this point in the history
…er/browsing_data.

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

Change-Id: I118ba2a88ecbbbe731ff98061c4e11c6255abcb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2525764
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Martin Šrámek <msramek@chromium.org>
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: Martin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825438}
  • Loading branch information
sigurasg authored and Commit Bot committed Nov 9, 2020
1 parent 026b2d3 commit 52c63a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ ServiceWorkerActivationObserver::ServiceWorkerActivationObserver(
ServiceWorkerContextWrapper* context,
base::OnceClosure callback)
: context_(context),
scoped_observer_(this),
callback_(std::move(callback)) {
scoped_observer_.Add(context);
scoped_observation_.Observe(context);
}

ServiceWorkerActivationObserver::~ServiceWorkerActivationObserver() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <string>
#include <vector>

#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "content/browser/service_worker/service_worker_context_core_observer.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
Expand Down Expand Up @@ -41,8 +41,9 @@ class ServiceWorkerActivationObserver
ServiceWorkerVersion::Status) override;

ServiceWorkerContextWrapper* context_;
ScopedObserver<ServiceWorkerContextWrapper, ServiceWorkerContextCoreObserver>
scoped_observer_;
base::ScopedObservation<ServiceWorkerContextWrapper,
ServiceWorkerContextCoreObserver>
scoped_observation_{this};
base::OnceClosure callback_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -1353,8 +1354,8 @@ class MultipleTasksObserver {
class Target : public BrowsingDataRemover::Observer {
public:
Target(MultipleTasksObserver* parent, BrowsingDataRemover* remover)
: parent_(parent), observer_(this) {
observer_.Add(remover);
: parent_(parent) {
observation_.Observe(remover);
}
~Target() override = default;

Expand All @@ -1364,8 +1365,8 @@ class MultipleTasksObserver {

private:
MultipleTasksObserver* parent_;
ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer>
observer_;
base::ScopedObservation<BrowsingDataRemover, BrowsingDataRemover::Observer>
observation_{this};
};

explicit MultipleTasksObserver(BrowsingDataRemover* remover)
Expand Down
11 changes: 5 additions & 6 deletions content/browser/browsing_data/clear_site_data_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "content/public/browser/clear_site_data_utils.h"

#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_filter_builder.h"
Expand Down Expand Up @@ -38,11 +38,10 @@ class SiteDataClearer : public BrowsingDataRemover::Observer {
avoid_closing_connections_(avoid_closing_connections),
callback_(std::move(callback)),
pending_task_count_(0),
remover_(nullptr),
scoped_observer_(this) {
remover_(nullptr) {
remover_ = BrowserContext::GetBrowsingDataRemover(browser_context);
DCHECK(remover_);
scoped_observer_.Add(remover_);
scoped_observation_.Observe(remover_);
}

~SiteDataClearer() override {
Expand Down Expand Up @@ -129,8 +128,8 @@ class SiteDataClearer : public BrowsingDataRemover::Observer {
base::OnceClosure callback_;
int pending_task_count_;
BrowsingDataRemover* remover_;
ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer>
scoped_observer_;
base::ScopedObservation<BrowsingDataRemover, BrowsingDataRemover::Observer>
scoped_observation_{this};
};

} // namespace
Expand Down

0 comments on commit 52c63a5

Please sign in to comment.