Retire ScopedObserver in /chromeos.
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. Bug: 1145565 Change-Id: I2f0b7675e3f91bc4adc14f43211f2324916c5d06 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2928598 Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org> Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org> Reviewed-by: Yue Li <updowndota@chromium.org> Commit-Queue: Yue Li <updowndota@chromium.org> Cr-Commit-Position: refs/heads/master@{#889528}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
708b3d5f7b
commit
6a11a8eb55
ash
app_list
views
assistant
assistant
chromeos
components
drivefs
dbus
services
assistant
@ -222,7 +222,7 @@ class AssistantInteractionCounter
|
||||
public:
|
||||
explicit AssistantInteractionCounter(
|
||||
chromeos::assistant::Assistant* service) {
|
||||
interaction_observer_.Add(service);
|
||||
interaction_observer_.Observe(service);
|
||||
}
|
||||
AssistantInteractionCounter(AssistantInteractionCounter&) = delete;
|
||||
AssistantInteractionCounter& operator=(AssistantInteractionCounter&) = delete;
|
||||
|
@ -52,7 +52,7 @@ class AssistantInteractionSubscriberMock
|
||||
: public chromeos::assistant::AssistantInteractionSubscriber {
|
||||
public:
|
||||
explicit AssistantInteractionSubscriberMock(Assistant* service) {
|
||||
scoped_subscriber_.Add(service);
|
||||
scoped_subscriber_.Observe(service);
|
||||
}
|
||||
|
||||
~AssistantInteractionSubscriberMock() override = default;
|
||||
@ -233,7 +233,7 @@ TEST_F(AssistantInteractionControllerImplTest,
|
||||
ShouldUpdateTimeOfLastInteraction) {
|
||||
MockAssistantInteractionSubscriber mock_subscriber;
|
||||
ScopedAssistantInteractionSubscriber scoped_subscriber{&mock_subscriber};
|
||||
scoped_subscriber.Add(assistant_service());
|
||||
scoped_subscriber.Observe(assistant_service());
|
||||
|
||||
base::RunLoop run_loop;
|
||||
base::Time actual_time_of_last_interaction;
|
||||
|
@ -81,7 +81,7 @@ class MockAssistantInteractionSubscriber
|
||||
chromeos::assistant::AssistantInteractionSubscriber> {
|
||||
public:
|
||||
explicit MockAssistantInteractionSubscriber(Assistant* service) {
|
||||
scoped_subscriber_.Add(service);
|
||||
scoped_subscriber_.Observe(service);
|
||||
}
|
||||
|
||||
~MockAssistantInteractionSubscriber() override = default;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/check.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/scoped_observer.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/test/bind.h"
|
||||
@ -349,8 +349,9 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
|
||||
|
||||
TEST_F(DriveFsHostTest, Basic) {
|
||||
MockDriveFsHostObserver observer;
|
||||
ScopedObserver<DriveFsHost, DriveFsHostObserver> observer_scoper(&observer);
|
||||
observer_scoper.Add(host_.get());
|
||||
base::ScopedObservation<DriveFsHost, DriveFsHostObserver> observation_scoper(
|
||||
&observer);
|
||||
observation_scoper.Observe(host_.get());
|
||||
|
||||
EXPECT_FALSE(host_->IsMounted());
|
||||
|
||||
@ -485,8 +486,9 @@ ACTION_P(CloneStruct, output) {
|
||||
TEST_F(DriveFsHostTest, OnSyncingStatusUpdate_ForwardToObservers) {
|
||||
ASSERT_NO_FATAL_FAILURE(DoMount());
|
||||
MockDriveFsHostObserver observer;
|
||||
ScopedObserver<DriveFsHost, DriveFsHostObserver> observer_scoper(&observer);
|
||||
observer_scoper.Add(host_.get());
|
||||
base::ScopedObservation<DriveFsHost, DriveFsHostObserver> observation_scoper(
|
||||
&observer);
|
||||
observation_scoper.Observe(host_.get());
|
||||
auto status = mojom::SyncingStatus::New();
|
||||
status->item_events.emplace_back(base::in_place, 12, 34, "filename.txt",
|
||||
mojom::ItemEvent::State::kInProgress, 123,
|
||||
@ -510,8 +512,9 @@ ACTION_P(CloneVectorOfStructs, output) {
|
||||
TEST_F(DriveFsHostTest, OnFilesChanged_ForwardToObservers) {
|
||||
ASSERT_NO_FATAL_FAILURE(DoMount());
|
||||
MockDriveFsHostObserver observer;
|
||||
ScopedObserver<DriveFsHost, DriveFsHostObserver> observer_scoper(&observer);
|
||||
observer_scoper.Add(host_.get());
|
||||
base::ScopedObservation<DriveFsHost, DriveFsHostObserver> observation_scoper(
|
||||
&observer);
|
||||
observation_scoper.Observe(host_.get());
|
||||
std::vector<mojom::FileChangePtr> changes;
|
||||
changes.emplace_back(base::in_place, base::FilePath("/create"),
|
||||
mojom::FileChange::Type::kCreate);
|
||||
@ -532,8 +535,9 @@ TEST_F(DriveFsHostTest, OnFilesChanged_ForwardToObservers) {
|
||||
TEST_F(DriveFsHostTest, OnError_ForwardToObservers) {
|
||||
ASSERT_NO_FATAL_FAILURE(DoMount());
|
||||
MockDriveFsHostObserver observer;
|
||||
ScopedObserver<DriveFsHost, DriveFsHostObserver> observer_scoper(&observer);
|
||||
observer_scoper.Add(host_.get());
|
||||
base::ScopedObservation<DriveFsHost, DriveFsHostObserver> observation_scoper(
|
||||
&observer);
|
||||
observation_scoper.Observe(host_.get());
|
||||
auto error = mojom::DriveError::New(
|
||||
mojom::DriveError::Type::kCantUploadStorageFull, base::FilePath("/foo"));
|
||||
mojom::DriveErrorPtr observed_error;
|
||||
@ -548,8 +552,9 @@ TEST_F(DriveFsHostTest, OnError_ForwardToObservers) {
|
||||
TEST_F(DriveFsHostTest, OnError_IgnoreUnknownErrorTypes) {
|
||||
ASSERT_NO_FATAL_FAILURE(DoMount());
|
||||
MockDriveFsHostObserver observer;
|
||||
ScopedObserver<DriveFsHost, DriveFsHostObserver> observer_scoper(&observer);
|
||||
observer_scoper.Add(host_.get());
|
||||
base::ScopedObservation<DriveFsHost, DriveFsHostObserver> observation_scoper(
|
||||
&observer);
|
||||
observation_scoper.Observe(host_.get());
|
||||
EXPECT_CALL(observer, OnError(_)).Times(0);
|
||||
delegate_->OnError(mojom::DriveError::New(
|
||||
static_cast<mojom::DriveError::Type>(
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "chromeos/dbus/fake_gnubby_client.h"
|
||||
|
||||
#include "base/scoped_observer.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "chromeos/dbus/attestation/attestation.pb.h"
|
||||
#include "chromeos/dbus/gnubby_client.h"
|
||||
@ -42,9 +42,9 @@ class FakeGnubbyClientTest : public testing::Test {
|
||||
|
||||
TEST_F(FakeGnubbyClientTest, NotificationSent) {
|
||||
TestObserver observer;
|
||||
ScopedObserver<GnubbyClient, GnubbyClient::Observer> scoped_observer(
|
||||
base::ScopedObservation<GnubbyClient, GnubbyClient::Observer> scoped_observer(
|
||||
&observer);
|
||||
scoped_observer.Add(&fake_gnubby_client_);
|
||||
scoped_observer.Observe(&fake_gnubby_client_);
|
||||
|
||||
EXPECT_EQ(fake_gnubby_client_.calls(), 0);
|
||||
EXPECT_EQ(observer.calls(), 0);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "base/scoped_observer.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "chromeos/services/assistant/public/cpp/assistant_enums.h"
|
||||
#include "chromeos/services/assistant/public/cpp/conversation_observer.h"
|
||||
#include "chromeos/services/libassistant/public/cpp/android_app_info.h"
|
||||
@ -155,10 +155,10 @@ class COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) Assistant {
|
||||
};
|
||||
|
||||
using ScopedAssistantInteractionSubscriber =
|
||||
ScopedObserver<Assistant,
|
||||
AssistantInteractionSubscriber,
|
||||
&Assistant::AddAssistantInteractionSubscriber,
|
||||
&Assistant::RemoveAssistantInteractionSubscriber>;
|
||||
base::ScopedObservation<Assistant,
|
||||
AssistantInteractionSubscriber,
|
||||
&Assistant::AddAssistantInteractionSubscriber,
|
||||
&Assistant::RemoveAssistantInteractionSubscriber>;
|
||||
|
||||
// Main interface between browser and |chromeos::assistant::Service|.
|
||||
class COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) AssistantService {
|
||||
|
@ -191,7 +191,7 @@ Service::Service(std::unique_ptr<network::PendingSharedURLLoaderFactory>
|
||||
DCHECK(identity_manager_);
|
||||
chromeos::PowerManagerClient* power_manager_client =
|
||||
context_->power_manager_client();
|
||||
power_manager_observer_.Add(power_manager_client);
|
||||
power_manager_observation_.Observe(power_manager_client);
|
||||
power_manager_client->RequestStatusUpdate();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "base/cancelable_callback.h"
|
||||
#include "base/component_export.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/scoped_observer.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/time/time.h"
|
||||
@ -159,9 +159,9 @@ class COMPONENT_EXPORT(ASSISTANT_SERVICE) Service
|
||||
std::unique_ptr<base::OneShotTimer> token_refresh_timer_;
|
||||
int token_refresh_error_backoff_factor = 1;
|
||||
scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
|
||||
ScopedObserver<chromeos::PowerManagerClient,
|
||||
chromeos::PowerManagerClient::Observer>
|
||||
power_manager_observer_{this};
|
||||
base::ScopedObservation<chromeos::PowerManagerClient,
|
||||
chromeos::PowerManagerClient::Observer>
|
||||
power_manager_observation_{this};
|
||||
|
||||
// Flag to guard the one-time mojom initialization.
|
||||
bool is_assistant_manager_service_finalized_ = false;
|
||||
|
Reference in New Issue
Block a user