Commit f397a0d8 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Replace ScopedObserver with base::ScopedObservation in /content/browser/service_worker.

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=falken@chromium.org
Bug: 1145565

Change-Id: If3dc3daa800da2d45c6a10e7561862eeb1368bc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526922
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825793}
parent d425717e
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/metrics/statistics_recorder.h" #include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
...@@ -470,9 +470,8 @@ class MockContentBrowserClient : public TestContentBrowserClient { ...@@ -470,9 +470,8 @@ class MockContentBrowserClient : public TestContentBrowserClient {
// An observer that waits for the service worker to be running. // An observer that waits for the service worker to be running.
class WorkerRunningStatusObserver : public ServiceWorkerContextObserver { class WorkerRunningStatusObserver : public ServiceWorkerContextObserver {
public: public:
explicit WorkerRunningStatusObserver(ServiceWorkerContext* context) explicit WorkerRunningStatusObserver(ServiceWorkerContext* context) {
: scoped_context_observer_(this) { scoped_context_observation_.Observe(context);
scoped_context_observer_.Add(context);
} }
~WorkerRunningStatusObserver() override = default; ~WorkerRunningStatusObserver() override = default;
...@@ -495,8 +494,8 @@ class WorkerRunningStatusObserver : public ServiceWorkerContextObserver { ...@@ -495,8 +494,8 @@ class WorkerRunningStatusObserver : public ServiceWorkerContextObserver {
private: private:
base::RunLoop run_loop_; base::RunLoop run_loop_;
ScopedObserver<ServiceWorkerContext, ServiceWorkerContextObserver> base::ScopedObservation<ServiceWorkerContext, ServiceWorkerContextObserver>
scoped_context_observer_; scoped_context_observation_{this};
int64_t version_id_ = blink::mojom::kInvalidServiceWorkerVersionId; int64_t version_id_ = blink::mojom::kInvalidServiceWorkerVersionId;
DISALLOW_COPY_AND_ASSIGN(WorkerRunningStatusObserver); DISALLOW_COPY_AND_ASSIGN(WorkerRunningStatusObserver);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/frame_tree_node.h"
...@@ -1188,9 +1188,8 @@ class TestServiceWorkerContextCoreObserver ...@@ -1188,9 +1188,8 @@ class TestServiceWorkerContextCoreObserver
: public ServiceWorkerContextCoreObserver { : public ServiceWorkerContextCoreObserver {
public: public:
explicit TestServiceWorkerContextCoreObserver( explicit TestServiceWorkerContextCoreObserver(
ServiceWorkerContextWrapper* wrapper) ServiceWorkerContextWrapper* wrapper) {
: observer_(this) { observation_.Observe(wrapper);
observer_.Add(wrapper);
} }
void OnControlleeAdded(int64_t version_id, void OnControlleeAdded(int64_t version_id,
...@@ -1222,8 +1221,9 @@ class TestServiceWorkerContextCoreObserver ...@@ -1222,8 +1221,9 @@ class TestServiceWorkerContextCoreObserver
int on_controllee_removed_count_ = 0; int on_controllee_removed_count_ = 0;
int on_controllee_navigation_committed_count_ = 0; int on_controllee_navigation_committed_count_ = 0;
ScopedObserver<ServiceWorkerContextWrapper, ServiceWorkerContextCoreObserver> base::ScopedObservation<ServiceWorkerContextWrapper,
observer_; ServiceWorkerContextCoreObserver>
observation_{this};
}; };
TEST_F(ServiceWorkerContainerHostTestWithBackForwardCache, ControlleeEvents) { TEST_F(ServiceWorkerContainerHostTestWithBackForwardCache, ControlleeEvents) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h" #include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/fake_embedded_worker_instance_client.h" #include "content/browser/service_worker/fake_embedded_worker_instance_client.h"
...@@ -283,9 +283,8 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver { ...@@ -283,9 +283,8 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver {
base::Optional<bool> is_running; base::Optional<bool> is_running;
}; };
explicit TestServiceWorkerContextObserver(ServiceWorkerContext* context) explicit TestServiceWorkerContextObserver(ServiceWorkerContext* context) {
: scoped_observer_(this) { scoped_observation_.Observe(context);
scoped_observer_.Add(context);
} }
~TestServiceWorkerContextObserver() override = default; ~TestServiceWorkerContextObserver() override = default;
...@@ -374,7 +373,7 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver { ...@@ -374,7 +373,7 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver {
} }
void OnDestruct(content::ServiceWorkerContext* context) override { void OnDestruct(content::ServiceWorkerContext* context) override {
scoped_observer_.Remove(context); scoped_observation_.RemoveObservation();
EventLog log; EventLog log;
log.type = EventType::Destruct; log.type = EventType::Destruct;
...@@ -384,8 +383,8 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver { ...@@ -384,8 +383,8 @@ class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver {
const std::vector<EventLog>& events() { return events_; } const std::vector<EventLog>& events() { return events_; }
private: private:
ScopedObserver<ServiceWorkerContext, ServiceWorkerContextObserver> base::ScopedObservation<ServiceWorkerContext, ServiceWorkerContextObserver>
scoped_observer_; scoped_observation_{this};
std::vector<EventLog> events_; std::vector<EventLog> events_;
DISALLOW_COPY_AND_ASSIGN(TestServiceWorkerContextObserver); DISALLOW_COPY_AND_ASSIGN(TestServiceWorkerContextObserver);
}; };
......
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