Commit 8f31d976 authored by Reilly Grant's avatar Reilly Grant Committed by Chromium LUCI CQ

Convert callbacks in //chrome/browser/chromeos/settings

This change converts callbacks from base::Bind and base::Callback to
Once/Repeating in //chrome/browser/chromeos/settings.

Bug: 1148570
Change-Id: I10bcc9e993a9df44932719297ed1893821ae2525
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2641476
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845589}
parent bb1b5f91
...@@ -81,9 +81,9 @@ CrosSettings::CrosSettings() = default; ...@@ -81,9 +81,9 @@ CrosSettings::CrosSettings() = default;
CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service, CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service,
PrefService* local_state) { PrefService* local_state) {
CrosSettingsProvider::NotifyObserversCallback notify_cb( CrosSettingsProvider::NotifyObserversCallback notify_cb(
base::Bind(&CrosSettings::FireObservers, base::BindRepeating(&CrosSettings::FireObservers,
// This is safe since |this| is never deleted. // This is safe since |this| is never deleted.
base::Unretained(this))); base::Unretained(this)));
auto supervised_user_cros_provider = auto supervised_user_cros_provider =
std::make_unique<SupervisedUserCrosSettingsProvider>(notify_cb); std::make_unique<SupervisedUserCrosSettingsProvider>(notify_cb);
...@@ -272,8 +272,8 @@ bool CrosSettings::AddSettingsProvider( ...@@ -272,8 +272,8 @@ bool CrosSettings::AddSettingsProvider(
// Providers instantiated inside this class will have the same callback // Providers instantiated inside this class will have the same callback
// passed to their constructor, but doing it here allows for providers // passed to their constructor, but doing it here allows for providers
// to be instantiated outside this class. // to be instantiated outside this class.
CrosSettingsProvider::NotifyObserversCallback notify_cb( CrosSettingsProvider::NotifyObserversCallback notify_cb(base::BindRepeating(
base::Bind(&CrosSettings::FireObservers, base::Unretained(this))); &CrosSettings::FireObservers, base::Unretained(this)));
provider_ptr->SetNotifyObserversCallback(notify_cb); provider_ptr->SetNotifyObserversCallback(notify_cb);
return true; return true;
} }
......
...@@ -42,9 +42,6 @@ class DeviceSettingsProvider ...@@ -42,9 +42,6 @@ class DeviceSettingsProvider
public DeviceSettingsService::Observer, public DeviceSettingsService::Observer,
public ownership::OwnerSettingsService::Observer { public ownership::OwnerSettingsService::Observer {
public: public:
// The callback type that is called to get the device mode.
typedef base::Callback<policy::DeviceMode(void)> GetDeviceModeCallback;
DeviceSettingsProvider(const NotifyObserversCallback& notify_cb, DeviceSettingsProvider(const NotifyObserversCallback& notify_cb,
DeviceSettingsService* device_settings_service, DeviceSettingsService* device_settings_service,
PrefService* pref_service); PrefService* pref_service);
......
...@@ -66,8 +66,8 @@ class DeviceSettingsProviderTest : public DeviceSettingsTestBase { ...@@ -66,8 +66,8 @@ class DeviceSettingsProviderTest : public DeviceSettingsTestBase {
EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber());
provider_.reset(new DeviceSettingsProvider( provider_.reset(new DeviceSettingsProvider(
base::Bind(&DeviceSettingsProviderTest::SettingChanged, base::BindRepeating(&DeviceSettingsProviderTest::SettingChanged,
base::Unretained(this)), base::Unretained(this)),
device_settings_service_.get(), local_state_.Get())); device_settings_service_.get(), local_state_.Get()));
Mock::VerifyAndClearExpectations(this); Mock::VerifyAndClearExpectations(this);
} }
......
...@@ -156,19 +156,19 @@ void DeviceSettingsService::LoadImmediately() { ...@@ -156,19 +156,19 @@ void DeviceSettingsService::LoadImmediately() {
} }
std::unique_ptr<SessionManagerOperation> operation(new LoadSettingsOperation( std::unique_ptr<SessionManagerOperation> operation(new LoadSettingsOperation(
request_key_load, cloud_validations, true /*force_immediate_load*/, request_key_load, cloud_validations, true /*force_immediate_load*/,
base::Bind(&DeviceSettingsService::HandleCompletedOperation, base::BindOnce(&DeviceSettingsService::HandleCompletedOperation,
weak_factory_.GetWeakPtr(), base::Closure()))); weak_factory_.GetWeakPtr(), base::OnceClosure())));
operation->Start(session_manager_client_, owner_key_util_, public_key_); operation->Start(session_manager_client_, owner_key_util_, public_key_);
} }
void DeviceSettingsService::Store( void DeviceSettingsService::Store(
std::unique_ptr<em::PolicyFetchResponse> policy, std::unique_ptr<em::PolicyFetchResponse> policy,
const base::Closure& callback) { base::OnceClosure callback) {
// On Active Directory managed devices policy is written only by authpolicyd. // On Active Directory managed devices policy is written only by authpolicyd.
CHECK(device_mode_ != policy::DEVICE_MODE_ENTERPRISE_AD); CHECK(device_mode_ != policy::DEVICE_MODE_ENTERPRISE_AD);
Enqueue(std::make_unique<StoreSettingsOperation>( Enqueue(std::make_unique<StoreSettingsOperation>(
base::Bind(&DeviceSettingsService::HandleCompletedAsyncOperation, base::BindOnce(&DeviceSettingsService::HandleCompletedAsyncOperation,
weak_factory_.GetWeakPtr(), callback), weak_factory_.GetWeakPtr(), std::move(callback)),
std::move(policy))); std::move(policy)));
} }
...@@ -281,8 +281,8 @@ void DeviceSettingsService::EnqueueLoad(bool request_key_load) { ...@@ -281,8 +281,8 @@ void DeviceSettingsService::EnqueueLoad(bool request_key_load) {
} }
Enqueue(std::make_unique<LoadSettingsOperation>( Enqueue(std::make_unique<LoadSettingsOperation>(
request_key_load, cloud_validations, false /*force_immediate_load*/, request_key_load, cloud_validations, false /*force_immediate_load*/,
base::Bind(&DeviceSettingsService::HandleCompletedAsyncOperation, base::BindOnce(&DeviceSettingsService::HandleCompletedAsyncOperation,
weak_factory_.GetWeakPtr(), base::Closure()))); weak_factory_.GetWeakPtr(), base::OnceClosure())));
} }
void DeviceSettingsService::EnsureReload(bool request_key_load) { void DeviceSettingsService::EnsureReload(bool request_key_load) {
...@@ -301,11 +301,11 @@ void DeviceSettingsService::StartNextOperation() { ...@@ -301,11 +301,11 @@ void DeviceSettingsService::StartNextOperation() {
} }
void DeviceSettingsService::HandleCompletedAsyncOperation( void DeviceSettingsService::HandleCompletedAsyncOperation(
const base::Closure& callback, base::OnceClosure callback,
SessionManagerOperation* operation, SessionManagerOperation* operation,
Status status) { Status status) {
DCHECK_EQ(operation, pending_operations_.front().get()); DCHECK_EQ(operation, pending_operations_.front().get());
HandleCompletedOperation(callback, operation, status); HandleCompletedOperation(std::move(callback), operation, status);
// Only remove the pending operation here, so new operations triggered by // Only remove the pending operation here, so new operations triggered by
// any of the callbacks above are queued up properly. // any of the callbacks above are queued up properly.
pending_operations_.pop_front(); pending_operations_.pop_front();
...@@ -314,7 +314,7 @@ void DeviceSettingsService::HandleCompletedAsyncOperation( ...@@ -314,7 +314,7 @@ void DeviceSettingsService::HandleCompletedAsyncOperation(
} }
void DeviceSettingsService::HandleCompletedOperation( void DeviceSettingsService::HandleCompletedOperation(
const base::Closure& callback, base::OnceClosure callback,
SessionManagerOperation* operation, SessionManagerOperation* operation,
Status status) { Status status) {
store_status_ = status; store_status_ = status;
...@@ -349,7 +349,7 @@ void DeviceSettingsService::HandleCompletedOperation( ...@@ -349,7 +349,7 @@ void DeviceSettingsService::HandleCompletedOperation(
// The completion callback happens after the notification so clients can // The completion callback happens after the notification so clients can
// filter self-triggered updates. // filter self-triggered updates.
if (!callback.is_null()) if (!callback.is_null())
callback.Run(); std::move(callback).Run();
} }
void DeviceSettingsService::NotifyOwnershipStatusChanged() const { void DeviceSettingsService::NotifyOwnershipStatusChanged() const {
......
...@@ -163,7 +163,7 @@ class DeviceSettingsService : public SessionManagerClient::Observer { ...@@ -163,7 +163,7 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
// reported through |callback|. If successful, the updated device settings are // reported through |callback|. If successful, the updated device settings are
// present in policy_data() and device_settings() when the callback runs. // present in policy_data() and device_settings() when the callback runs.
void Store(std::unique_ptr<enterprise_management::PolicyFetchResponse> policy, void Store(std::unique_ptr<enterprise_management::PolicyFetchResponse> policy,
const base::Closure& callback); base::OnceClosure callback);
// Returns the ownership status. May return OWNERSHIP_UNKNOWN if the disk // Returns the ownership status. May return OWNERSHIP_UNKNOWN if the disk
// hasn't been checked yet. // hasn't been checked yet.
...@@ -229,13 +229,13 @@ class DeviceSettingsService : public SessionManagerClient::Observer { ...@@ -229,13 +229,13 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
void StartNextOperation(); void StartNextOperation();
// Updates status, policy data and owner key from a finished operation. // Updates status, policy data and owner key from a finished operation.
void HandleCompletedOperation(const base::Closure& callback, void HandleCompletedOperation(base::OnceClosure callback,
SessionManagerOperation* operation, SessionManagerOperation* operation,
Status status); Status status);
// Same as HandleCompletedOperation(), but also starts the next pending // Same as HandleCompletedOperation(), but also starts the next pending
// operation if available. // operation if available.
void HandleCompletedAsyncOperation(const base::Closure& callback, void HandleCompletedAsyncOperation(base::OnceClosure callback,
SessionManagerOperation* operation, SessionManagerOperation* operation,
Status status); Status status);
......
...@@ -156,8 +156,8 @@ TEST_F(DeviceSettingsServiceTest, StoreFailure) { ...@@ -156,8 +156,8 @@ TEST_F(DeviceSettingsServiceTest, StoreFailure) {
session_manager_client_.ForceStorePolicyFailure(true); session_manager_client_.ForceStorePolicyFailure(true);
device_settings_service_->Store( device_settings_service_->Store(
device_policy_->GetCopy(), device_policy_->GetCopy(),
base::Bind(&DeviceSettingsServiceTest::SetOperationCompleted, base::BindOnce(&DeviceSettingsServiceTest::SetOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
FlushDeviceSettings(); FlushDeviceSettings();
EXPECT_TRUE(operation_completed_); EXPECT_TRUE(operation_completed_);
EXPECT_EQ(DeviceSettingsService::STORE_OPERATION_FAILED, EXPECT_EQ(DeviceSettingsService::STORE_OPERATION_FAILED,
...@@ -176,8 +176,8 @@ TEST_F(DeviceSettingsServiceTest, StoreSuccess) { ...@@ -176,8 +176,8 @@ TEST_F(DeviceSettingsServiceTest, StoreSuccess) {
true); true);
device_settings_service_->Store( device_settings_service_->Store(
device_policy_->GetCopy(), device_policy_->GetCopy(),
base::Bind(&DeviceSettingsServiceTest::SetOperationCompleted, base::BindOnce(&DeviceSettingsServiceTest::SetOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
FlushDeviceSettings(); FlushDeviceSettings();
EXPECT_TRUE(operation_completed_); EXPECT_TRUE(operation_completed_);
EXPECT_EQ(DeviceSettingsService::STORE_SUCCESS, EXPECT_EQ(DeviceSettingsService::STORE_SUCCESS,
...@@ -195,7 +195,8 @@ TEST_F(DeviceSettingsServiceTest, StoreRotation) { ...@@ -195,7 +195,8 @@ TEST_F(DeviceSettingsServiceTest, StoreRotation) {
->set_device_policy_refresh_rate(300); ->set_device_policy_refresh_rate(300);
device_policy_->SetDefaultNewSigningKey(); device_policy_->SetDefaultNewSigningKey();
device_policy_->Build(); device_policy_->Build();
device_settings_service_->Store(device_policy_->GetCopy(), base::Closure()); device_settings_service_->Store(device_policy_->GetCopy(),
base::OnceClosure());
FlushDeviceSettings(); FlushDeviceSettings();
owner_key_util_->SetPublicKeyFromPrivateKey( owner_key_util_->SetPublicKeyFromPrivateKey(
*device_policy_->GetNewSigningKey()); *device_policy_->GetNewSigningKey());
...@@ -218,7 +219,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) { ...@@ -218,7 +219,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) {
EXPECT_EQ(DeviceSettingsService::OWNERSHIP_UNKNOWN, EXPECT_EQ(DeviceSettingsService::OWNERSHIP_UNKNOWN,
device_settings_service_->GetOwnershipStatus()); device_settings_service_->GetOwnershipStatus());
device_settings_service_->GetOwnershipStatusAsync(base::Bind( device_settings_service_->GetOwnershipStatusAsync(base::BindOnce(
&DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this))); &DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this)));
FlushDeviceSettings(); FlushDeviceSettings();
EXPECT_FALSE(device_settings_service_->HasPrivateOwnerKey()); EXPECT_FALSE(device_settings_service_->HasPrivateOwnerKey());
...@@ -230,7 +231,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) { ...@@ -230,7 +231,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) {
owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_->GetSigningKey()); owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_->GetSigningKey());
ReloadDeviceSettings(); ReloadDeviceSettings();
device_settings_service_->GetOwnershipStatusAsync(base::Bind( device_settings_service_->GetOwnershipStatusAsync(base::BindOnce(
&DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this))); &DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this)));
FlushDeviceSettings(); FlushDeviceSettings();
EXPECT_FALSE(device_settings_service_->HasPrivateOwnerKey()); EXPECT_FALSE(device_settings_service_->HasPrivateOwnerKey());
...@@ -245,7 +246,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) { ...@@ -245,7 +246,7 @@ TEST_F(DeviceSettingsServiceTest, OwnershipStatus) {
owner_key_util_->SetPrivateKey(device_policy_->GetSigningKey()); owner_key_util_->SetPrivateKey(device_policy_->GetSigningKey());
InitOwner(AccountId::FromUserEmail(device_policy_->policy_data().username()), InitOwner(AccountId::FromUserEmail(device_policy_->policy_data().username()),
true); true);
device_settings_service_->GetOwnershipStatusAsync(base::Bind( device_settings_service_->GetOwnershipStatusAsync(base::BindOnce(
&DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this))); &DeviceSettingsServiceTest::SetOwnershipStatus, base::Unretained(this)));
FlushDeviceSettings(); FlushDeviceSettings();
EXPECT_TRUE(device_settings_service_->HasPrivateOwnerKey()); EXPECT_TRUE(device_settings_service_->HasPrivateOwnerKey());
...@@ -442,7 +443,8 @@ TEST_F(DeviceSettingsServiceTest, Observer) { ...@@ -442,7 +443,8 @@ TEST_F(DeviceSettingsServiceTest, Observer) {
EXPECT_CALL(observer_, OwnershipStatusChanged()).Times(0); EXPECT_CALL(observer_, OwnershipStatusChanged()).Times(0);
EXPECT_CALL(observer_, DeviceSettingsUpdated()).Times(1); EXPECT_CALL(observer_, DeviceSettingsUpdated()).Times(1);
device_settings_service_->Store(device_policy_->GetCopy(), base::Closure()); device_settings_service_->Store(device_policy_->GetCopy(),
base::OnceClosure());
FlushDeviceSettings(); FlushDeviceSettings();
Mock::VerifyAndClearExpectations(&observer_); Mock::VerifyAndClearExpectations(&observer_);
......
...@@ -32,8 +32,8 @@ namespace em = enterprise_management; ...@@ -32,8 +32,8 @@ namespace em = enterprise_management;
namespace chromeos { namespace chromeos {
SessionManagerOperation::SessionManagerOperation(const Callback& callback) SessionManagerOperation::SessionManagerOperation(Callback callback)
: callback_(callback) {} : callback_(std::move(callback)) {}
SessionManagerOperation::~SessionManagerOperation() {} SessionManagerOperation::~SessionManagerOperation() {}
...@@ -66,8 +66,9 @@ void SessionManagerOperation::StartLoading() { ...@@ -66,8 +66,9 @@ void SessionManagerOperation::StartLoading() {
return; return;
is_loading_ = true; is_loading_ = true;
if (cloud_validations_) { if (cloud_validations_) {
EnsurePublicKey(base::Bind(&SessionManagerOperation::RetrieveDeviceSettings, EnsurePublicKey(
weak_factory_.GetWeakPtr())); base::BindOnce(&SessionManagerOperation::RetrieveDeviceSettings,
weak_factory_.GetWeakPtr()));
} else { } else {
RetrieveDeviceSettings(); RetrieveDeviceSettings();
} }
...@@ -76,8 +77,8 @@ void SessionManagerOperation::StartLoading() { ...@@ -76,8 +77,8 @@ void SessionManagerOperation::StartLoading() {
void SessionManagerOperation::LoadImmediately() { void SessionManagerOperation::LoadImmediately() {
if (cloud_validations_) { if (cloud_validations_) {
StorePublicKey( StorePublicKey(
base::Bind(&SessionManagerOperation::BlockingRetrieveDeviceSettings, base::BindOnce(&SessionManagerOperation::BlockingRetrieveDeviceSettings,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
LoadPublicKey(owner_key_util_, public_key_)); LoadPublicKey(owner_key_util_, public_key_));
} else { } else {
BlockingRetrieveDeviceSettings(); BlockingRetrieveDeviceSettings();
...@@ -86,10 +87,10 @@ void SessionManagerOperation::LoadImmediately() { ...@@ -86,10 +87,10 @@ void SessionManagerOperation::LoadImmediately() {
void SessionManagerOperation::ReportResult( void SessionManagerOperation::ReportResult(
DeviceSettingsService::Status status) { DeviceSettingsService::Status status) {
callback_.Run(this, status); std::move(callback_).Run(this, status);
} }
void SessionManagerOperation::EnsurePublicKey(const base::Closure& callback) { void SessionManagerOperation::EnsurePublicKey(base::OnceClosure callback) {
if (force_key_load_ || !public_key_ || !public_key_->is_loaded()) { if (force_key_load_ || !public_key_ || !public_key_->is_loaded()) {
base::ThreadPool::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, FROM_HERE,
...@@ -98,9 +99,9 @@ void SessionManagerOperation::EnsurePublicKey(const base::Closure& callback) { ...@@ -98,9 +99,9 @@ void SessionManagerOperation::EnsurePublicKey(const base::Closure& callback) {
base::BindOnce(&SessionManagerOperation::LoadPublicKey, owner_key_util_, base::BindOnce(&SessionManagerOperation::LoadPublicKey, owner_key_util_,
force_key_load_ ? nullptr : public_key_), force_key_load_ ? nullptr : public_key_),
base::BindOnce(&SessionManagerOperation::StorePublicKey, base::BindOnce(&SessionManagerOperation::StorePublicKey,
weak_factory_.GetWeakPtr(), callback)); weak_factory_.GetWeakPtr(), std::move(callback)));
} else { } else {
callback.Run(); std::move(callback).Run();
} }
} }
...@@ -122,7 +123,7 @@ scoped_refptr<PublicKey> SessionManagerOperation::LoadPublicKey( ...@@ -122,7 +123,7 @@ scoped_refptr<PublicKey> SessionManagerOperation::LoadPublicKey(
return public_key; return public_key;
} }
void SessionManagerOperation::StorePublicKey(const base::Closure& callback, void SessionManagerOperation::StorePublicKey(base::OnceClosure callback,
scoped_refptr<PublicKey> new_key) { scoped_refptr<PublicKey> new_key) {
force_key_load_ = false; force_key_load_ = false;
public_key_ = new_key; public_key_ = new_key;
...@@ -132,7 +133,7 @@ void SessionManagerOperation::StorePublicKey(const base::Closure& callback, ...@@ -132,7 +133,7 @@ void SessionManagerOperation::StorePublicKey(const base::Closure& callback,
return; return;
} }
callback.Run(); std::move(callback).Run();
} }
void SessionManagerOperation::RetrieveDeviceSettings() { void SessionManagerOperation::RetrieveDeviceSettings() {
...@@ -224,8 +225,8 @@ void SessionManagerOperation::ReportValidatorStatus( ...@@ -224,8 +225,8 @@ void SessionManagerOperation::ReportValidatorStatus(
LoadSettingsOperation::LoadSettingsOperation(bool force_key_load, LoadSettingsOperation::LoadSettingsOperation(bool force_key_load,
bool cloud_validations, bool cloud_validations,
bool force_immediate_load, bool force_immediate_load,
const Callback& callback) Callback callback)
: SessionManagerOperation(callback) { : SessionManagerOperation(std::move(callback)) {
force_key_load_ = force_key_load; force_key_load_ = force_key_load;
cloud_validations_ = cloud_validations; cloud_validations_ = cloud_validations;
force_immediate_load_ = force_immediate_load; force_immediate_load_ = force_immediate_load;
...@@ -241,9 +242,9 @@ void LoadSettingsOperation::Run() { ...@@ -241,9 +242,9 @@ void LoadSettingsOperation::Run() {
} }
StoreSettingsOperation::StoreSettingsOperation( StoreSettingsOperation::StoreSettingsOperation(
const Callback& callback, Callback callback,
std::unique_ptr<em::PolicyFetchResponse> policy) std::unique_ptr<em::PolicyFetchResponse> policy)
: SessionManagerOperation(callback), policy_(std::move(policy)) { : SessionManagerOperation(std::move(callback)), policy_(std::move(policy)) {
if (policy_->has_new_public_key()) if (policy_->has_new_public_key())
force_key_load_ = true; force_key_load_ = true;
} }
......
...@@ -34,11 +34,11 @@ namespace chromeos { ...@@ -34,11 +34,11 @@ namespace chromeos {
// are subclasses for loading, storing and signing policy blobs. // are subclasses for loading, storing and signing policy blobs.
class SessionManagerOperation { class SessionManagerOperation {
public: public:
typedef base::Callback<void(SessionManagerOperation*, using Callback = base::OnceCallback<void(SessionManagerOperation*,
DeviceSettingsService::Status)> Callback; DeviceSettingsService::Status)>;
// Creates a new load operation. // Creates a new load operation.
explicit SessionManagerOperation(const Callback& callback); explicit SessionManagerOperation(Callback callback);
virtual ~SessionManagerOperation(); virtual ~SessionManagerOperation();
// Starts the operation. // Starts the operation.
...@@ -69,7 +69,7 @@ class SessionManagerOperation { ...@@ -69,7 +69,7 @@ class SessionManagerOperation {
virtual void Run() = 0; virtual void Run() = 0;
// Ensures the public key is loaded. // Ensures the public key is loaded.
void EnsurePublicKey(const base::Closure& callback); void EnsurePublicKey(base::OnceClosure callback);
// Starts a load operation. // Starts a load operation.
void StartLoading(); void StartLoading();
...@@ -101,7 +101,7 @@ class SessionManagerOperation { ...@@ -101,7 +101,7 @@ class SessionManagerOperation {
scoped_refptr<ownership::PublicKey> current_key); scoped_refptr<ownership::PublicKey> current_key);
// Stores the owner key loaded by LoadOwnerKey and calls |callback|. // Stores the owner key loaded by LoadOwnerKey and calls |callback|.
void StorePublicKey(const base::Closure& callback, void StorePublicKey(base::OnceClosure callback,
scoped_refptr<ownership::PublicKey> new_key); scoped_refptr<ownership::PublicKey> new_key);
// Triggers a device settings load. // Triggers a device settings load.
...@@ -146,7 +146,7 @@ class LoadSettingsOperation : public SessionManagerOperation { ...@@ -146,7 +146,7 @@ class LoadSettingsOperation : public SessionManagerOperation {
LoadSettingsOperation(bool force_key_load, LoadSettingsOperation(bool force_key_load,
bool cloud_validations, bool cloud_validations,
bool force_immediate_load, bool force_immediate_load,
const Callback& callback); Callback callback);
~LoadSettingsOperation() override; ~LoadSettingsOperation() override;
protected: protected:
...@@ -163,7 +163,7 @@ class StoreSettingsOperation : public SessionManagerOperation { ...@@ -163,7 +163,7 @@ class StoreSettingsOperation : public SessionManagerOperation {
public: public:
// Creates a new store operation. // Creates a new store operation.
StoreSettingsOperation( StoreSettingsOperation(
const Callback& callback, Callback callback,
std::unique_ptr<enterprise_management::PolicyFetchResponse> policy); std::unique_ptr<enterprise_management::PolicyFetchResponse> policy);
~StoreSettingsOperation() override; ~StoreSettingsOperation() override;
......
...@@ -130,8 +130,8 @@ TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) { ...@@ -130,8 +130,8 @@ TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) {
LoadSettingsOperation op( LoadSettingsOperation op(
false /* force_key_load */, true /* cloud_validations */, false /* force_key_load */, true /* cloud_validations */,
false /* force_immediate_load */, false /* force_immediate_load */,
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
EXPECT_CALL(*this, EXPECT_CALL(*this,
OnOperationCompleted( OnOperationCompleted(
...@@ -151,8 +151,8 @@ TEST_F(SessionManagerOperationTest, LoadOwnerKey) { ...@@ -151,8 +151,8 @@ TEST_F(SessionManagerOperationTest, LoadOwnerKey) {
LoadSettingsOperation op( LoadSettingsOperation op(
false /* force_key_load */, true /* cloud_validations */, false /* force_key_load */, true /* cloud_validations */,
false /* force_immediate_load */, false /* force_immediate_load */,
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
EXPECT_CALL(*this, EXPECT_CALL(*this,
OnOperationCompleted( OnOperationCompleted(
...@@ -170,8 +170,8 @@ TEST_F(SessionManagerOperationTest, LoadPolicy) { ...@@ -170,8 +170,8 @@ TEST_F(SessionManagerOperationTest, LoadPolicy) {
LoadSettingsOperation op( LoadSettingsOperation op(
false /* force_key_load */, true /* cloud_validations */, false /* force_key_load */, true /* cloud_validations */,
false /* force_immediate_load */, false /* force_immediate_load */,
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
EXPECT_CALL(*this, EXPECT_CALL(*this,
OnOperationCompleted(&op, DeviceSettingsService::STORE_SUCCESS)); OnOperationCompleted(&op, DeviceSettingsService::STORE_SUCCESS));
...@@ -193,8 +193,8 @@ TEST_F(SessionManagerOperationTest, LoadImmediately) { ...@@ -193,8 +193,8 @@ TEST_F(SessionManagerOperationTest, LoadImmediately) {
LoadSettingsOperation op( LoadSettingsOperation op(
false /* force_key_load */, true /* cloud_validations */, false /* force_key_load */, true /* cloud_validations */,
true /* force_immediate_load */, true /* force_immediate_load */,
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
EXPECT_CALL(*this, EXPECT_CALL(*this,
OnOperationCompleted( OnOperationCompleted(
...@@ -217,8 +217,8 @@ TEST_F(SessionManagerOperationTest, RestartLoad) { ...@@ -217,8 +217,8 @@ TEST_F(SessionManagerOperationTest, RestartLoad) {
LoadSettingsOperation op( LoadSettingsOperation op(
false /* force_key_load */, true /* cloud_validations */, false /* force_key_load */, true /* cloud_validations */,
false /* force_immediate_load */, false /* force_immediate_load */,
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this))); base::Unretained(this)));
// Just after the first RetrieveDevicePolicy() completion, // Just after the first RetrieveDevicePolicy() completion,
// verify the state, install a different key, then RestartLoad(). // verify the state, install a different key, then RestartLoad().
...@@ -272,8 +272,8 @@ TEST_F(SessionManagerOperationTest, RestartLoad) { ...@@ -272,8 +272,8 @@ TEST_F(SessionManagerOperationTest, RestartLoad) {
TEST_F(SessionManagerOperationTest, StoreSettings) { TEST_F(SessionManagerOperationTest, StoreSettings) {
owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
StoreSettingsOperation op( StoreSettingsOperation op(
base::Bind(&SessionManagerOperationTest::OnOperationCompleted, base::BindOnce(&SessionManagerOperationTest::OnOperationCompleted,
base::Unretained(this)), base::Unretained(this)),
policy_.GetCopy()); policy_.GetCopy());
EXPECT_CALL(*this, EXPECT_CALL(*this,
......
...@@ -18,8 +18,9 @@ ShutdownPolicyHandler::ShutdownPolicyHandler(CrosSettings* cros_settings, ...@@ -18,8 +18,9 @@ ShutdownPolicyHandler::ShutdownPolicyHandler(CrosSettings* cros_settings,
DCHECK(delegate); DCHECK(delegate);
shutdown_policy_subscription_ = cros_settings_->AddSettingsObserver( shutdown_policy_subscription_ = cros_settings_->AddSettingsObserver(
kRebootOnShutdown, kRebootOnShutdown,
base::Bind(&ShutdownPolicyHandler::NotifyDelegateWithShutdownPolicy, base::BindRepeating(
weak_factory_.GetWeakPtr())); &ShutdownPolicyHandler::NotifyDelegateWithShutdownPolicy,
weak_factory_.GetWeakPtr()));
} }
ShutdownPolicyHandler::~ShutdownPolicyHandler() {} ShutdownPolicyHandler::~ShutdownPolicyHandler() {}
......
...@@ -19,9 +19,8 @@ class StubCrosSettingsProviderTest : public testing::Test { ...@@ -19,9 +19,8 @@ class StubCrosSettingsProviderTest : public testing::Test {
protected: protected:
StubCrosSettingsProviderTest() StubCrosSettingsProviderTest()
: provider_(new StubCrosSettingsProvider( : provider_(new StubCrosSettingsProvider(
base::Bind(&StubCrosSettingsProviderTest::FireObservers, base::BindRepeating(&StubCrosSettingsProviderTest::FireObservers,
base::Unretained(this)))) { base::Unretained(this)))) {}
}
~StubCrosSettingsProviderTest() override {} ~StubCrosSettingsProviderTest() override {}
......
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