Commit 100ea9d3 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert AccountStatusChangeDelegate to new Mojo types

This CL converts AccountStatusChangeDelegatePtr and
AccountStatusChangeDelegateRequest to new Mojo types
using PendingRemote, Remote, and ReceiverSet.

It also update SetAccountStatusChangeDelegate from
multidevice_setup.mojom.

Bug: 955171
Change-Id: I2493c44e041b53a76c6fe4e1f7870bd395cc69d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824724Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#700093}
parent 91727e91
......@@ -76,7 +76,7 @@ MultiDeviceNotificationPresenter::GetMetricValueForNotification(
MultiDeviceNotificationPresenter::MultiDeviceNotificationPresenter(
message_center::MessageCenter* message_center,
service_manager::Connector* connector)
: message_center_(message_center), connector_(connector), binding_(this) {
: message_center_(message_center), connector_(connector) {
DCHECK(message_center_);
DCHECK(connector_);
......@@ -227,11 +227,8 @@ void MultiDeviceNotificationPresenter::ObserveMultiDeviceSetupIfPossible() {
&multidevice_setup_ptr_);
// Add this object as the delegate of the MultiDeviceSetup Service.
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegatePtr
delegate_ptr;
binding_.Bind(mojo::MakeRequest(&delegate_ptr));
multidevice_setup_ptr_->SetAccountStatusChangeDelegate(
std::move(delegate_ptr));
receiver_.BindNewPipeAndPassRemote());
message_center_->AddObserver(this);
}
......
......@@ -14,7 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/message_center/message_center_observer.h"
namespace message_center {
......@@ -128,8 +128,9 @@ class ASH_EXPORT MultiDeviceNotificationPresenter
chromeos::multidevice_setup::mojom::MultiDeviceSetupPtr
multidevice_setup_ptr_;
mojo::Binding<chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate>
binding_;
mojo::Receiver<
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate>
receiver_{this};
base::WeakPtrFactory<MultiDeviceNotificationPresenter> weak_ptr_factory_{
this};
......
......@@ -17,16 +17,16 @@ AccountStatusChangeDelegateNotifier::AccountStatusChangeDelegateNotifier() =
AccountStatusChangeDelegateNotifier::~AccountStatusChangeDelegateNotifier() =
default;
void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegatePtr(
mojom::AccountStatusChangeDelegatePtr delegate_ptr) {
if (delegate_ptr_.is_bound()) {
void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegateRemote(
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote) {
if (delegate_remote_.is_bound()) {
PA_LOG(ERROR) << "AccountStatusChangeDelegateNotifier::"
<< "SetAccountStatusChangeDelegatePtr(): Tried to set "
<< "SetAccountStatusChangeDelegateRemote(): Tried to set "
<< "delegate, but one already existed.";
NOTREACHED();
}
delegate_ptr_ = std::move(delegate_ptr);
delegate_remote_.Bind(std::move(delegate_remote));
OnDelegateSet();
}
......@@ -34,8 +34,8 @@ void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegatePtr(
void AccountStatusChangeDelegateNotifier::OnDelegateSet() {}
void AccountStatusChangeDelegateNotifier::FlushForTesting() {
if (delegate_ptr_)
delegate_ptr_.FlushForTesting();
if (delegate_remote_)
delegate_remote_.FlushForTesting();
}
} // namespace multidevice_setup
......
......@@ -7,6 +7,8 @@
#include "base/macros.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
......@@ -21,17 +23,19 @@ class AccountStatusChangeDelegateNotifier {
public:
virtual ~AccountStatusChangeDelegateNotifier();
void SetAccountStatusChangeDelegatePtr(
mojom::AccountStatusChangeDelegatePtr delegate_ptr);
void SetAccountStatusChangeDelegateRemote(
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote);
protected:
AccountStatusChangeDelegateNotifier();
// Derived classes should override this function to be alerted when
// SetAccountStatusChangeDelegatePtr() is called.
// SetAccountStatusChangeDelegateRemote() is called.
virtual void OnDelegateSet();
mojom::AccountStatusChangeDelegate* delegate() { return delegate_ptr_.get(); }
mojom::AccountStatusChangeDelegate* delegate() {
return delegate_remote_.is_bound() ? delegate_remote_.get() : nullptr;
}
private:
friend class MultiDeviceSetupImpl;
......@@ -40,7 +44,7 @@ class AccountStatusChangeDelegateNotifier {
void FlushForTesting();
mojom::AccountStatusChangeDelegatePtr delegate_ptr_;
mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_remote_;
DISALLOW_COPY_AND_ASSIGN(AccountStatusChangeDelegateNotifier);
};
......
......@@ -13,6 +13,8 @@
#include "chromeos/services/multidevice_setup/host_status_provider.h"
#include "chromeos/services/multidevice_setup/public/cpp/oobe_completion_tracker.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
class PrefRegistrySimple;
class PrefService;
......@@ -55,8 +57,8 @@ class AccountStatusChangeDelegateNotifierImpl
~AccountStatusChangeDelegateNotifierImpl() override;
void SetAccountStatusChangeDelegatePtr(
mojom::AccountStatusChangeDelegatePtr delegate_ptr);
void SetAccountStatusChangeDelegateRemote(
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote);
private:
friend class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest;
......@@ -111,7 +113,7 @@ class AccountStatusChangeDelegateNotifierImpl
// Set to base::nullopt until the first host status update.
base::Optional<mojom::HostStatus> host_status_from_most_recent_update_;
mojom::AccountStatusChangeDelegatePtr delegate_ptr_;
mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_remote_;
HostStatusProvider* host_status_provider_;
PrefService* pref_service_;
HostDeviceTimestampManager* host_device_timestamp_manager_;
......
......@@ -142,9 +142,9 @@ class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest
old_host_device_id);
}
void SetAccountStatusChangeDelegatePtr() {
delegate_notifier_->SetAccountStatusChangeDelegatePtr(
fake_delegate_->GenerateInterfacePtr());
void SetAccountStatusChangeDelegateRemote() {
delegate_notifier_->SetAccountStatusChangeDelegateRemote(
fake_delegate_->GenerateRemote());
delegate_notifier_->FlushForTesting();
}
......@@ -207,7 +207,7 @@ class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
SetObserverWithPotentialHost) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
EXPECT_EQ(0u, fake_delegate()->num_new_user_potential_host_events_handled());
EXPECT_EQ(0u, GetNewUserPotentialHostExistsTimestamp());
......@@ -220,7 +220,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
PotentialHostAddedLater) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kNoEligibleHosts,
base::nullopt /* host_device */);
......@@ -236,7 +236,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
OnlyPotentialHostCausesNewUserEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kNoEligibleHosts,
base::nullopt /* host_device */);
......@@ -276,7 +276,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildAccountStatusChangeDelegateNotifier();
int64_t earlier_test_time_millis = kTestTimeMillis / 2;
SetNewUserPotentialHostExistsTimestamp(earlier_test_time_millis);
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
......@@ -290,7 +290,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildAccountStatusChangeDelegateNotifier();
int64_t earlier_test_time_millis = kTestTimeMillis / 2;
SetExistingUserChromebookAddedTimestamp(earlier_test_time_millis);
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
......@@ -302,7 +302,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
LosingPotentialHostTriggersNoLongerNewUserEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
EXPECT_EQ(1u, fake_delegate()->num_new_user_potential_host_events_handled());
......@@ -318,7 +318,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
SettingHostTriggersNoLongerNewUserEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
EXPECT_EQ(1u, fake_delegate()->num_new_user_potential_host_events_handled());
......@@ -342,7 +342,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
EXPECT_EQ(kTestTimeMillis, GetOobeSetupFlowTimestamp());
// Set delegate, which triggers event check.
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
EXPECT_EQ(0u, fake_delegate()->num_new_user_potential_host_events_handled());
EXPECT_EQ(0u, GetNewUserPotentialHostExistsTimestamp());
......@@ -351,7 +351,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
CompletingOobeSetupFlowWithDelegateSetTriggersNoLongerNewUserEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
......@@ -367,7 +367,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
NoLongerNewUserEventBlockedByOldChromebookAddedTimestamp) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Record earlier Chromebook added event.
int64_t earlier_test_time_millis = kTestTimeMillis / 2;
......@@ -391,7 +391,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildFakePhone(kFakePhoneKey, kFakePhoneName);
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Check the delegate initializes to 0.
EXPECT_EQ(0u,
fake_delegate()->num_existing_user_host_switched_events_handled());
......@@ -423,7 +423,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
SettingSameHostTriggersNoHostSwitchedEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Set initially verified host.
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
......@@ -437,7 +437,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
ChangingHostDevicesTriggersHostSwitchEventWhenHostNameIsUnchanged) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Set initially verified host.
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
......@@ -454,7 +454,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildFakePhone(kFakePhoneKey, kFakePhoneName);
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Set initial host but do not verify.
SetHostWithStatus(mojom::HostStatus::kHostSetButNotYetVerified, fakePhone);
// Verify host.
......@@ -466,7 +466,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
OnlyVerifiedHostCausesHostSwitchedEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Set initially verified host.
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
......@@ -492,7 +492,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
ForgettingAndThenSwitchingHostsDoesNotTriggerHostSwitchedEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Set initially verified host.
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
......@@ -520,7 +520,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
// Host switched and verified between sessions.
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
EXPECT_EQ(1u,
fake_delegate()->num_existing_user_host_switched_events_handled());
}
......@@ -528,7 +528,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
NoHostSwitchedEventWithoutExistingHost) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetUpHost(BuildFakePhone(kFakePhoneKey, kFakePhoneName));
EXPECT_EQ(0u,
fake_delegate()->num_existing_user_host_switched_events_handled());
......@@ -551,7 +551,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
NotifiesObserverForChromebookAddedEvents) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Check the delegate initializes to 0.
EXPECT_EQ(
0u, fake_delegate()->num_existing_user_chromebook_added_events_handled());
......@@ -570,7 +570,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildFakePhone(kFakePhoneKey, kFakePhoneName);
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Start with potential hosts but none set.
SetHostWithStatus(mojom::HostStatus::kEligibleHostExistsButNoHostSet,
base::nullopt /* host_device */);
......@@ -589,7 +589,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
ReplacingUnverifiedHostAWithVerifiedHostBCausesChromebookAddedEvent) {
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Start with potential hosts but none set.
// Set initial host but do not verify.
SetHostWithStatus(mojom::HostStatus::kHostSetButNotYetVerified,
......@@ -613,7 +613,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
EXPECT_EQ(
1u, fake_delegate()->num_existing_user_chromebook_added_events_handled());
}
......@@ -624,7 +624,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildFakePhone(kFakePhoneKey, kFakePhoneName);
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetUpHost(fakePhone);
// The host was set on this Chromebook so it should not trigger the Chromebook
......@@ -648,7 +648,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
GetExistingUserChromebookAddedTimestamp());
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
SetHostWithStatus(mojom::HostStatus::kHostVerified,
BuildFakePhone(kFakePhoneKey, kFakePhoneName));
......@@ -677,7 +677,7 @@ TEST_F(MultiDeviceSetupAccountStatusChangeDelegateNotifierTest,
BuildFakePhone(kFakePhoneKeyA, kFakePhoneNameA);
BuildAccountStatusChangeDelegateNotifier();
SetAccountStatusChangeDelegatePtr();
SetAccountStatusChangeDelegateRemote();
// Check the delegate initializes to empty.
EXPECT_EQ(GetMostRecentVerifiedHostDeviceIdPref(), "");
......
......@@ -12,11 +12,11 @@ FakeAccountStatusChangeDelegate::FakeAccountStatusChangeDelegate() = default;
FakeAccountStatusChangeDelegate::~FakeAccountStatusChangeDelegate() = default;
mojom::AccountStatusChangeDelegatePtr
FakeAccountStatusChangeDelegate::GenerateInterfacePtr() {
mojom::AccountStatusChangeDelegatePtr interface_ptr;
bindings_.AddBinding(this, mojo::MakeRequest(&interface_ptr));
return interface_ptr;
mojo::PendingRemote<mojom::AccountStatusChangeDelegate>
FakeAccountStatusChangeDelegate::GenerateRemote() {
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> remote;
receivers_.Add(this, remote.InitWithNewPipeAndPassReceiver());
return remote;
}
void FakeAccountStatusChangeDelegate::OnPotentialHostExistsForNewUser() {
......
......@@ -7,7 +7,8 @@
#include "base/macros.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
namespace chromeos {
......@@ -20,7 +21,7 @@ class FakeAccountStatusChangeDelegate
FakeAccountStatusChangeDelegate();
~FakeAccountStatusChangeDelegate() override;
mojom::AccountStatusChangeDelegatePtr GenerateInterfacePtr();
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> GenerateRemote();
size_t num_new_user_potential_host_events_handled() {
return num_new_user_potential_host_events_handled_;
......@@ -52,7 +53,7 @@ class FakeAccountStatusChangeDelegate
size_t num_existing_user_host_switched_events_handled_ = 0u;
size_t num_existing_user_chromebook_added_events_handled_ = 0u;
mojo::BindingSet<mojom::AccountStatusChangeDelegate> bindings_;
mojo::ReceiverSet<mojom::AccountStatusChangeDelegate> receivers_;
DISALLOW_COPY_AND_ASSIGN(FakeAccountStatusChangeDelegate);
};
......
......@@ -157,8 +157,8 @@ MultiDeviceSetupImpl::~MultiDeviceSetupImpl() {
}
void MultiDeviceSetupImpl::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) {
delegate_notifier_->SetAccountStatusChangeDelegatePtr(std::move(delegate));
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
delegate_notifier_->SetAccountStatusChangeDelegateRemote(std::move(delegate));
}
void MultiDeviceSetupImpl::AddHostStatusObserver(
......@@ -276,7 +276,7 @@ void MultiDeviceSetupImpl::RetrySetHostNow(RetrySetHostNowCallback callback) {
void MultiDeviceSetupImpl::TriggerEventForDebugging(
mojom::EventTypeForDebugging type,
TriggerEventForDebuggingCallback callback) {
if (!delegate_notifier_->delegate_ptr_) {
if (!delegate_notifier_->delegate_remote_) {
PA_LOG(ERROR) << "MultiDeviceSetupImpl::TriggerEventForDebugging(): No "
<< "delgate has been set; cannot proceed.";
std::move(callback).Run(false /* success */);
......@@ -286,7 +286,7 @@ void MultiDeviceSetupImpl::TriggerEventForDebugging(
PA_LOG(VERBOSE) << "MultiDeviceSetupImpl::TriggerEventForDebugging(" << type
<< ") called.";
mojom::AccountStatusChangeDelegate* delegate =
delegate_notifier_->delegate_ptr_.get();
delegate_notifier_->delegate_remote_.get();
switch (type) {
case mojom::EventTypeForDebugging::kNewUserPotentialHostExists:
......
......@@ -14,6 +14,7 @@
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "url/gurl.h"
class PrefService;
......@@ -80,7 +81,8 @@ class MultiDeviceSetupImpl : public MultiDeviceSetupBase,
// mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override;
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override;
......
......@@ -615,7 +615,7 @@ class MultiDeviceSetupImplTest : public testing::Test {
EXPECT_FALSE(fake_account_status_change_delegate_notifier()->delegate());
multidevice_setup_->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate_->GenerateInterfacePtr());
fake_account_status_change_delegate_->GenerateRemote());
EXPECT_TRUE(fake_account_status_change_delegate_notifier()->delegate());
}
......
......@@ -98,7 +98,7 @@ MultiDeviceSetupInitializer::MultiDeviceSetupInitializer(
MultiDeviceSetupInitializer::~MultiDeviceSetupInitializer() = default;
void MultiDeviceSetupInitializer::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) {
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
if (multidevice_setup_impl_) {
multidevice_setup_impl_->SetAccountStatusChangeDelegate(
std::move(delegate));
......
......@@ -12,7 +12,7 @@
#include "chromeos/services/device_sync/public/cpp/device_sync_client.h"
#include "chromeos/services/multidevice_setup/multidevice_setup_base.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
class PrefService;
......@@ -88,7 +88,8 @@ class MultiDeviceSetupInitializer
// mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override;
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override;
......@@ -132,7 +133,7 @@ class MultiDeviceSetupInitializer
// If API functions are called before initialization is complete, their
// parameters are cached here. Once asynchronous initialization is complete,
// the parameters are passed to |multidevice_setup_impl_|.
mojom::AccountStatusChangeDelegatePtr pending_delegate_;
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> pending_delegate_;
std::vector<mojom::HostStatusObserverPtr> pending_host_status_observers_;
std::vector<mojom::FeatureStateObserverPtr> pending_feature_state_observers_;
std::vector<GetEligibleHostDevicesCallback> pending_get_eligible_hosts_args_;
......
......@@ -243,7 +243,7 @@ TEST_F(MultiDeviceSetupServiceTest, CallFunctionsBeforeInitialization) {
auto fake_account_status_change_delegate =
std::make_unique<FakeAccountStatusChangeDelegate>();
multidevice_setup_ptr()->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate->GenerateInterfacePtr());
fake_account_status_change_delegate->GenerateRemote());
multidevice_setup_ptr().FlushForTesting();
// AddHostStatusObserver().
......@@ -388,7 +388,7 @@ TEST_F(MultiDeviceSetupServiceTest, FinishInitializationFirst) {
auto fake_account_status_change_delegate =
std::make_unique<FakeAccountStatusChangeDelegate>();
multidevice_setup_ptr()->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate->GenerateInterfacePtr());
fake_account_status_change_delegate->GenerateRemote());
multidevice_setup_ptr().FlushForTesting();
EXPECT_TRUE(fake_multidevice_setup()->delegate());
......
......@@ -98,8 +98,8 @@ void FakeMultiDeviceSetup::NotifyFeatureStateChanged(
}
void FakeMultiDeviceSetup::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) {
delegate_ = std::move(delegate);
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
delegate_.Bind(std::move(delegate));
}
void FakeMultiDeviceSetup::AddHostStatusObserver(
......
......@@ -13,6 +13,8 @@
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
......@@ -37,7 +39,9 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
const base::flat_map<mojom::Feature, mojom::FeatureState>&
feature_states);
mojom::AccountStatusChangeDelegatePtr& delegate() { return delegate_; }
mojo::Remote<mojom::AccountStatusChangeDelegate>& delegate() {
return delegate_;
}
std::vector<GetEligibleHostDevicesCallback>& get_eligible_hosts_args() {
return get_eligible_hosts_args_;
......@@ -84,7 +88,8 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
private:
// mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override;
mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override;
......@@ -110,7 +115,7 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
mojom::PrivilegedHostDeviceSetter::SetHostDeviceCallback callback)
override;
mojom::AccountStatusChangeDelegatePtr delegate_;
mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_;
mojo::InterfacePtrSet<mojom::HostStatusObserver> host_status_observers_;
mojo::InterfacePtrSet<mojom::FeatureStateObserver> feature_state_observers_;
......
......@@ -138,7 +138,8 @@ interface MultiDeviceSetup {
// Registers the "account status change" delegate to be used by the service.
// Only one delegate can be set; this function should not be called more than
// once.
SetAccountStatusChangeDelegate(AccountStatusChangeDelegate delegate);
SetAccountStatusChangeDelegate(
pending_remote<AccountStatusChangeDelegate> delegate);
// Adds an observer of host status changes. To stop observing, disconnect the
// HostStatusObserverPtr passed here.
......
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