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( ...@@ -76,7 +76,7 @@ MultiDeviceNotificationPresenter::GetMetricValueForNotification(
MultiDeviceNotificationPresenter::MultiDeviceNotificationPresenter( MultiDeviceNotificationPresenter::MultiDeviceNotificationPresenter(
message_center::MessageCenter* message_center, message_center::MessageCenter* message_center,
service_manager::Connector* connector) service_manager::Connector* connector)
: message_center_(message_center), connector_(connector), binding_(this) { : message_center_(message_center), connector_(connector) {
DCHECK(message_center_); DCHECK(message_center_);
DCHECK(connector_); DCHECK(connector_);
...@@ -227,11 +227,8 @@ void MultiDeviceNotificationPresenter::ObserveMultiDeviceSetupIfPossible() { ...@@ -227,11 +227,8 @@ void MultiDeviceNotificationPresenter::ObserveMultiDeviceSetupIfPossible() {
&multidevice_setup_ptr_); &multidevice_setup_ptr_);
// Add this object as the delegate of the MultiDeviceSetup Service. // 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( multidevice_setup_ptr_->SetAccountStatusChangeDelegate(
std::move(delegate_ptr)); receiver_.BindNewPipeAndPassRemote());
message_center_->AddObserver(this); message_center_->AddObserver(this);
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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" #include "ui/message_center/message_center_observer.h"
namespace message_center { namespace message_center {
...@@ -128,8 +128,9 @@ class ASH_EXPORT MultiDeviceNotificationPresenter ...@@ -128,8 +128,9 @@ class ASH_EXPORT MultiDeviceNotificationPresenter
chromeos::multidevice_setup::mojom::MultiDeviceSetupPtr chromeos::multidevice_setup::mojom::MultiDeviceSetupPtr
multidevice_setup_ptr_; multidevice_setup_ptr_;
mojo::Binding<chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate> mojo::Receiver<
binding_; chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate>
receiver_{this};
base::WeakPtrFactory<MultiDeviceNotificationPresenter> weak_ptr_factory_{ base::WeakPtrFactory<MultiDeviceNotificationPresenter> weak_ptr_factory_{
this}; this};
......
...@@ -17,16 +17,16 @@ AccountStatusChangeDelegateNotifier::AccountStatusChangeDelegateNotifier() = ...@@ -17,16 +17,16 @@ AccountStatusChangeDelegateNotifier::AccountStatusChangeDelegateNotifier() =
AccountStatusChangeDelegateNotifier::~AccountStatusChangeDelegateNotifier() = AccountStatusChangeDelegateNotifier::~AccountStatusChangeDelegateNotifier() =
default; default;
void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegatePtr( void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegateRemote(
mojom::AccountStatusChangeDelegatePtr delegate_ptr) { mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote) {
if (delegate_ptr_.is_bound()) { if (delegate_remote_.is_bound()) {
PA_LOG(ERROR) << "AccountStatusChangeDelegateNotifier::" PA_LOG(ERROR) << "AccountStatusChangeDelegateNotifier::"
<< "SetAccountStatusChangeDelegatePtr(): Tried to set " << "SetAccountStatusChangeDelegateRemote(): Tried to set "
<< "delegate, but one already existed."; << "delegate, but one already existed.";
NOTREACHED(); NOTREACHED();
} }
delegate_ptr_ = std::move(delegate_ptr); delegate_remote_.Bind(std::move(delegate_remote));
OnDelegateSet(); OnDelegateSet();
} }
...@@ -34,8 +34,8 @@ void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegatePtr( ...@@ -34,8 +34,8 @@ void AccountStatusChangeDelegateNotifier::SetAccountStatusChangeDelegatePtr(
void AccountStatusChangeDelegateNotifier::OnDelegateSet() {} void AccountStatusChangeDelegateNotifier::OnDelegateSet() {}
void AccountStatusChangeDelegateNotifier::FlushForTesting() { void AccountStatusChangeDelegateNotifier::FlushForTesting() {
if (delegate_ptr_) if (delegate_remote_)
delegate_ptr_.FlushForTesting(); delegate_remote_.FlushForTesting();
} }
} // namespace multidevice_setup } // namespace multidevice_setup
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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 { namespace chromeos {
...@@ -21,17 +23,19 @@ class AccountStatusChangeDelegateNotifier { ...@@ -21,17 +23,19 @@ class AccountStatusChangeDelegateNotifier {
public: public:
virtual ~AccountStatusChangeDelegateNotifier(); virtual ~AccountStatusChangeDelegateNotifier();
void SetAccountStatusChangeDelegatePtr( void SetAccountStatusChangeDelegateRemote(
mojom::AccountStatusChangeDelegatePtr delegate_ptr); mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote);
protected: protected:
AccountStatusChangeDelegateNotifier(); AccountStatusChangeDelegateNotifier();
// Derived classes should override this function to be alerted when // Derived classes should override this function to be alerted when
// SetAccountStatusChangeDelegatePtr() is called. // SetAccountStatusChangeDelegateRemote() is called.
virtual void OnDelegateSet(); virtual void OnDelegateSet();
mojom::AccountStatusChangeDelegate* delegate() { return delegate_ptr_.get(); } mojom::AccountStatusChangeDelegate* delegate() {
return delegate_remote_.is_bound() ? delegate_remote_.get() : nullptr;
}
private: private:
friend class MultiDeviceSetupImpl; friend class MultiDeviceSetupImpl;
...@@ -40,7 +44,7 @@ class AccountStatusChangeDelegateNotifier { ...@@ -40,7 +44,7 @@ class AccountStatusChangeDelegateNotifier {
void FlushForTesting(); void FlushForTesting();
mojom::AccountStatusChangeDelegatePtr delegate_ptr_; mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_remote_;
DISALLOW_COPY_AND_ASSIGN(AccountStatusChangeDelegateNotifier); DISALLOW_COPY_AND_ASSIGN(AccountStatusChangeDelegateNotifier);
}; };
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "chromeos/services/multidevice_setup/host_status_provider.h" #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/cpp/oobe_completion_tracker.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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 PrefRegistrySimple;
class PrefService; class PrefService;
...@@ -55,8 +57,8 @@ class AccountStatusChangeDelegateNotifierImpl ...@@ -55,8 +57,8 @@ class AccountStatusChangeDelegateNotifierImpl
~AccountStatusChangeDelegateNotifierImpl() override; ~AccountStatusChangeDelegateNotifierImpl() override;
void SetAccountStatusChangeDelegatePtr( void SetAccountStatusChangeDelegateRemote(
mojom::AccountStatusChangeDelegatePtr delegate_ptr); mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote);
private: private:
friend class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest; friend class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest;
...@@ -111,7 +113,7 @@ class AccountStatusChangeDelegateNotifierImpl ...@@ -111,7 +113,7 @@ class AccountStatusChangeDelegateNotifierImpl
// Set to base::nullopt until the first host status update. // Set to base::nullopt until the first host status update.
base::Optional<mojom::HostStatus> host_status_from_most_recent_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_; HostStatusProvider* host_status_provider_;
PrefService* pref_service_; PrefService* pref_service_;
HostDeviceTimestampManager* host_device_timestamp_manager_; HostDeviceTimestampManager* host_device_timestamp_manager_;
......
...@@ -12,11 +12,11 @@ FakeAccountStatusChangeDelegate::FakeAccountStatusChangeDelegate() = default; ...@@ -12,11 +12,11 @@ FakeAccountStatusChangeDelegate::FakeAccountStatusChangeDelegate() = default;
FakeAccountStatusChangeDelegate::~FakeAccountStatusChangeDelegate() = default; FakeAccountStatusChangeDelegate::~FakeAccountStatusChangeDelegate() = default;
mojom::AccountStatusChangeDelegatePtr mojo::PendingRemote<mojom::AccountStatusChangeDelegate>
FakeAccountStatusChangeDelegate::GenerateInterfacePtr() { FakeAccountStatusChangeDelegate::GenerateRemote() {
mojom::AccountStatusChangeDelegatePtr interface_ptr; mojo::PendingRemote<mojom::AccountStatusChangeDelegate> remote;
bindings_.AddBinding(this, mojo::MakeRequest(&interface_ptr)); receivers_.Add(this, remote.InitWithNewPipeAndPassReceiver());
return interface_ptr; return remote;
} }
void FakeAccountStatusChangeDelegate::OnPotentialHostExistsForNewUser() { void FakeAccountStatusChangeDelegate::OnPotentialHostExistsForNewUser() {
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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 { namespace chromeos {
...@@ -20,7 +21,7 @@ class FakeAccountStatusChangeDelegate ...@@ -20,7 +21,7 @@ class FakeAccountStatusChangeDelegate
FakeAccountStatusChangeDelegate(); FakeAccountStatusChangeDelegate();
~FakeAccountStatusChangeDelegate() override; ~FakeAccountStatusChangeDelegate() override;
mojom::AccountStatusChangeDelegatePtr GenerateInterfacePtr(); mojo::PendingRemote<mojom::AccountStatusChangeDelegate> GenerateRemote();
size_t num_new_user_potential_host_events_handled() { size_t num_new_user_potential_host_events_handled() {
return num_new_user_potential_host_events_handled_; return num_new_user_potential_host_events_handled_;
...@@ -52,7 +53,7 @@ class FakeAccountStatusChangeDelegate ...@@ -52,7 +53,7 @@ class FakeAccountStatusChangeDelegate
size_t num_existing_user_host_switched_events_handled_ = 0u; size_t num_existing_user_host_switched_events_handled_ = 0u;
size_t num_existing_user_chromebook_added_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); DISALLOW_COPY_AND_ASSIGN(FakeAccountStatusChangeDelegate);
}; };
......
...@@ -157,8 +157,8 @@ MultiDeviceSetupImpl::~MultiDeviceSetupImpl() { ...@@ -157,8 +157,8 @@ MultiDeviceSetupImpl::~MultiDeviceSetupImpl() {
} }
void MultiDeviceSetupImpl::SetAccountStatusChangeDelegate( void MultiDeviceSetupImpl::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) { mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
delegate_notifier_->SetAccountStatusChangeDelegatePtr(std::move(delegate)); delegate_notifier_->SetAccountStatusChangeDelegateRemote(std::move(delegate));
} }
void MultiDeviceSetupImpl::AddHostStatusObserver( void MultiDeviceSetupImpl::AddHostStatusObserver(
...@@ -276,7 +276,7 @@ void MultiDeviceSetupImpl::RetrySetHostNow(RetrySetHostNowCallback callback) { ...@@ -276,7 +276,7 @@ void MultiDeviceSetupImpl::RetrySetHostNow(RetrySetHostNowCallback callback) {
void MultiDeviceSetupImpl::TriggerEventForDebugging( void MultiDeviceSetupImpl::TriggerEventForDebugging(
mojom::EventTypeForDebugging type, mojom::EventTypeForDebugging type,
TriggerEventForDebuggingCallback callback) { TriggerEventForDebuggingCallback callback) {
if (!delegate_notifier_->delegate_ptr_) { if (!delegate_notifier_->delegate_remote_) {
PA_LOG(ERROR) << "MultiDeviceSetupImpl::TriggerEventForDebugging(): No " PA_LOG(ERROR) << "MultiDeviceSetupImpl::TriggerEventForDebugging(): No "
<< "delgate has been set; cannot proceed."; << "delgate has been set; cannot proceed.";
std::move(callback).Run(false /* success */); std::move(callback).Run(false /* success */);
...@@ -286,7 +286,7 @@ void MultiDeviceSetupImpl::TriggerEventForDebugging( ...@@ -286,7 +286,7 @@ void MultiDeviceSetupImpl::TriggerEventForDebugging(
PA_LOG(VERBOSE) << "MultiDeviceSetupImpl::TriggerEventForDebugging(" << type PA_LOG(VERBOSE) << "MultiDeviceSetupImpl::TriggerEventForDebugging(" << type
<< ") called."; << ") called.";
mojom::AccountStatusChangeDelegate* delegate = mojom::AccountStatusChangeDelegate* delegate =
delegate_notifier_->delegate_ptr_.get(); delegate_notifier_->delegate_remote_.get();
switch (type) { switch (type) {
case mojom::EventTypeForDebugging::kNewUserPotentialHostExists: case mojom::EventTypeForDebugging::kNewUserPotentialHostExists:
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h" #include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "url/gurl.h" #include "url/gurl.h"
class PrefService; class PrefService;
...@@ -80,7 +81,8 @@ class MultiDeviceSetupImpl : public MultiDeviceSetupBase, ...@@ -80,7 +81,8 @@ class MultiDeviceSetupImpl : public MultiDeviceSetupBase,
// mojom::MultiDeviceSetup: // mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate( void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override; mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override; void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver( void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override; mojom::FeatureStateObserverPtr observer) override;
......
...@@ -615,7 +615,7 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -615,7 +615,7 @@ class MultiDeviceSetupImplTest : public testing::Test {
EXPECT_FALSE(fake_account_status_change_delegate_notifier()->delegate()); EXPECT_FALSE(fake_account_status_change_delegate_notifier()->delegate());
multidevice_setup_->SetAccountStatusChangeDelegate( multidevice_setup_->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate_->GenerateInterfacePtr()); fake_account_status_change_delegate_->GenerateRemote());
EXPECT_TRUE(fake_account_status_change_delegate_notifier()->delegate()); EXPECT_TRUE(fake_account_status_change_delegate_notifier()->delegate());
} }
......
...@@ -98,7 +98,7 @@ MultiDeviceSetupInitializer::MultiDeviceSetupInitializer( ...@@ -98,7 +98,7 @@ MultiDeviceSetupInitializer::MultiDeviceSetupInitializer(
MultiDeviceSetupInitializer::~MultiDeviceSetupInitializer() = default; MultiDeviceSetupInitializer::~MultiDeviceSetupInitializer() = default;
void MultiDeviceSetupInitializer::SetAccountStatusChangeDelegate( void MultiDeviceSetupInitializer::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) { mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
if (multidevice_setup_impl_) { if (multidevice_setup_impl_) {
multidevice_setup_impl_->SetAccountStatusChangeDelegate( multidevice_setup_impl_->SetAccountStatusChangeDelegate(
std::move(delegate)); std::move(delegate));
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "chromeos/services/device_sync/public/cpp/device_sync_client.h" #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/multidevice_setup_base.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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; class PrefService;
...@@ -88,7 +88,8 @@ class MultiDeviceSetupInitializer ...@@ -88,7 +88,8 @@ class MultiDeviceSetupInitializer
// mojom::MultiDeviceSetup: // mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate( void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override; mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override; void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver( void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override; mojom::FeatureStateObserverPtr observer) override;
...@@ -132,7 +133,7 @@ class MultiDeviceSetupInitializer ...@@ -132,7 +133,7 @@ class MultiDeviceSetupInitializer
// If API functions are called before initialization is complete, their // If API functions are called before initialization is complete, their
// parameters are cached here. Once asynchronous initialization is complete, // parameters are cached here. Once asynchronous initialization is complete,
// the parameters are passed to |multidevice_setup_impl_|. // 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::HostStatusObserverPtr> pending_host_status_observers_;
std::vector<mojom::FeatureStateObserverPtr> pending_feature_state_observers_; std::vector<mojom::FeatureStateObserverPtr> pending_feature_state_observers_;
std::vector<GetEligibleHostDevicesCallback> pending_get_eligible_hosts_args_; std::vector<GetEligibleHostDevicesCallback> pending_get_eligible_hosts_args_;
......
...@@ -243,7 +243,7 @@ TEST_F(MultiDeviceSetupServiceTest, CallFunctionsBeforeInitialization) { ...@@ -243,7 +243,7 @@ TEST_F(MultiDeviceSetupServiceTest, CallFunctionsBeforeInitialization) {
auto fake_account_status_change_delegate = auto fake_account_status_change_delegate =
std::make_unique<FakeAccountStatusChangeDelegate>(); std::make_unique<FakeAccountStatusChangeDelegate>();
multidevice_setup_ptr()->SetAccountStatusChangeDelegate( multidevice_setup_ptr()->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate->GenerateInterfacePtr()); fake_account_status_change_delegate->GenerateRemote());
multidevice_setup_ptr().FlushForTesting(); multidevice_setup_ptr().FlushForTesting();
// AddHostStatusObserver(). // AddHostStatusObserver().
...@@ -388,7 +388,7 @@ TEST_F(MultiDeviceSetupServiceTest, FinishInitializationFirst) { ...@@ -388,7 +388,7 @@ TEST_F(MultiDeviceSetupServiceTest, FinishInitializationFirst) {
auto fake_account_status_change_delegate = auto fake_account_status_change_delegate =
std::make_unique<FakeAccountStatusChangeDelegate>(); std::make_unique<FakeAccountStatusChangeDelegate>();
multidevice_setup_ptr()->SetAccountStatusChangeDelegate( multidevice_setup_ptr()->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate->GenerateInterfacePtr()); fake_account_status_change_delegate->GenerateRemote());
multidevice_setup_ptr().FlushForTesting(); multidevice_setup_ptr().FlushForTesting();
EXPECT_TRUE(fake_multidevice_setup()->delegate()); EXPECT_TRUE(fake_multidevice_setup()->delegate());
......
...@@ -98,8 +98,8 @@ void FakeMultiDeviceSetup::NotifyFeatureStateChanged( ...@@ -98,8 +98,8 @@ void FakeMultiDeviceSetup::NotifyFeatureStateChanged(
} }
void FakeMultiDeviceSetup::SetAccountStatusChangeDelegate( void FakeMultiDeviceSetup::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) { mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate) {
delegate_ = std::move(delegate); delegate_.Bind(std::move(delegate));
} }
void FakeMultiDeviceSetup::AddHostStatusObserver( void FakeMultiDeviceSetup::AddHostStatusObserver(
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.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/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_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 { namespace chromeos {
...@@ -37,7 +39,9 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase { ...@@ -37,7 +39,9 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
const base::flat_map<mojom::Feature, mojom::FeatureState>& const base::flat_map<mojom::Feature, mojom::FeatureState>&
feature_states); feature_states);
mojom::AccountStatusChangeDelegatePtr& delegate() { return delegate_; } mojo::Remote<mojom::AccountStatusChangeDelegate>& delegate() {
return delegate_;
}
std::vector<GetEligibleHostDevicesCallback>& get_eligible_hosts_args() { std::vector<GetEligibleHostDevicesCallback>& get_eligible_hosts_args() {
return get_eligible_hosts_args_; return get_eligible_hosts_args_;
...@@ -84,7 +88,8 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase { ...@@ -84,7 +88,8 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
private: private:
// mojom::MultiDeviceSetup: // mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate( void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate) override; mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate)
override;
void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override; void AddHostStatusObserver(mojom::HostStatusObserverPtr observer) override;
void AddFeatureStateObserver( void AddFeatureStateObserver(
mojom::FeatureStateObserverPtr observer) override; mojom::FeatureStateObserverPtr observer) override;
...@@ -110,7 +115,7 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase { ...@@ -110,7 +115,7 @@ class FakeMultiDeviceSetup : public MultiDeviceSetupBase {
mojom::PrivilegedHostDeviceSetter::SetHostDeviceCallback callback) mojom::PrivilegedHostDeviceSetter::SetHostDeviceCallback callback)
override; override;
mojom::AccountStatusChangeDelegatePtr delegate_; mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_;
mojo::InterfacePtrSet<mojom::HostStatusObserver> host_status_observers_; mojo::InterfacePtrSet<mojom::HostStatusObserver> host_status_observers_;
mojo::InterfacePtrSet<mojom::FeatureStateObserver> feature_state_observers_; mojo::InterfacePtrSet<mojom::FeatureStateObserver> feature_state_observers_;
......
...@@ -138,7 +138,8 @@ interface MultiDeviceSetup { ...@@ -138,7 +138,8 @@ interface MultiDeviceSetup {
// Registers the "account status change" delegate to be used by the service. // 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 // Only one delegate can be set; this function should not be called more than
// once. // once.
SetAccountStatusChangeDelegate(AccountStatusChangeDelegate delegate); SetAccountStatusChangeDelegate(
pending_remote<AccountStatusChangeDelegate> delegate);
// Adds an observer of host status changes. To stop observing, disconnect the // Adds an observer of host status changes. To stop observing, disconnect the
// HostStatusObserverPtr passed here. // 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