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

Convert callbacks in //chromeos/components/tether

This change converts callbacks from base::Bind and base::Callback to
Once/Repeating in //chromeos/components/tether.

Bug: 1007654
Change-Id: I8aa947682d8ba5f2864d6dc9a1ed153d5ba90416
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637929
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844962}
parent 24640130
......@@ -91,8 +91,8 @@ class ActiveHostTest : public testing::Test {
EXPECT_TRUE(active_host_->GetWifiNetworkGuid().empty());
EXPECT_TRUE(active_host_->GetTetherNetworkGuid().empty());
active_host_->GetActiveHost(base::Bind(&ActiveHostTest::OnActiveHostFetched,
base::Unretained(this)));
active_host_->GetActiveHost(base::BindOnce(
&ActiveHostTest::OnActiveHostFetched, base::Unretained(this)));
ASSERT_EQ(1u, get_active_host_results_.size());
EXPECT_EQ(
(GetActiveHostResult{ActiveHost::ActiveHostStatus::DISCONNECTED,
......@@ -135,8 +135,8 @@ TEST_F(ActiveHostTest, TestConnecting) {
EXPECT_EQ("tetherNetworkGuid", active_host_->GetTetherNetworkGuid());
EXPECT_TRUE(active_host_->GetWifiNetworkGuid().empty());
active_host_->GetActiveHost(
base::Bind(&ActiveHostTest::OnActiveHostFetched, base::Unretained(this)));
active_host_->GetActiveHost(base::BindOnce(
&ActiveHostTest::OnActiveHostFetched, base::Unretained(this)));
ASSERT_EQ(1u, get_active_host_results_.size());
EXPECT_EQ(
(GetActiveHostResult{
......@@ -157,8 +157,8 @@ TEST_F(ActiveHostTest, TestConnected) {
EXPECT_EQ("tetherNetworkGuid", active_host_->GetTetherNetworkGuid());
EXPECT_EQ("wifiNetworkGuid", active_host_->GetWifiNetworkGuid());
active_host_->GetActiveHost(
base::Bind(&ActiveHostTest::OnActiveHostFetched, base::Unretained(this)));
active_host_->GetActiveHost(base::BindOnce(
&ActiveHostTest::OnActiveHostFetched, base::Unretained(this)));
ASSERT_EQ(1u, get_active_host_results_.size());
EXPECT_EQ(
(GetActiveHostResult{
......
......@@ -28,7 +28,7 @@ class AsynchronousShutdownObjectContainer {
// Shuts down the objects contained by this class and invokes
// |shutdown_complete_callback| upon completion. This function should only be
// called once.
virtual void Shutdown(const base::Closure& shutdown_complete_callback) = 0;
virtual void Shutdown(base::OnceClosure shutdown_complete_callback) = 0;
virtual TetherHostFetcher* tether_host_fetcher() = 0;
virtual DisconnectTetheringRequestSender*
......
......@@ -80,9 +80,9 @@ AsynchronousShutdownObjectContainerImpl::
~AsynchronousShutdownObjectContainerImpl() = default;
void AsynchronousShutdownObjectContainerImpl::Shutdown(
const base::Closure& shutdown_complete_callback) {
base::OnceClosure shutdown_complete_callback) {
DCHECK(shutdown_complete_callback_.is_null());
shutdown_complete_callback_ = shutdown_complete_callback;
shutdown_complete_callback_ = std::move(shutdown_complete_callback);
// The objects below require asynchronous shutdowns, so start observering
// these objects. Once they notify observers that they are finished shutting
......@@ -125,7 +125,7 @@ void AsynchronousShutdownObjectContainerImpl::ShutdownIfPossible() {
disconnect_tethering_request_sender_->RemoveObserver(this);
shutdown_complete_callback_.Run();
std::move(shutdown_complete_callback_).Run();
}
bool AsynchronousShutdownObjectContainerImpl::
......
......@@ -72,7 +72,7 @@ class AsynchronousShutdownObjectContainerImpl
~AsynchronousShutdownObjectContainerImpl() override;
// AsynchronousShutdownObjectContainer:
void Shutdown(const base::Closure& shutdown_complete_callback) override;
void Shutdown(base::OnceClosure shutdown_complete_callback) override;
TetherHostFetcher* tether_host_fetcher() override;
DisconnectTetheringRequestSender* disconnect_tethering_request_sender()
override;
......@@ -109,7 +109,7 @@ class AsynchronousShutdownObjectContainerImpl
std::unique_ptr<WifiHotspotDisconnector> wifi_hotspot_disconnector_;
// Not set until Shutdown() is invoked.
base::Closure shutdown_complete_callback_;
base::OnceClosure shutdown_complete_callback_;
DISALLOW_COPY_AND_ASSIGN(AsynchronousShutdownObjectContainerImpl);
};
......
......@@ -91,7 +91,7 @@ class AsynchronousShutdownObjectContainerImplTest : public testing::Test {
}
void CallShutdown() {
container_->Shutdown(base::Bind(
container_->Shutdown(base::BindOnce(
&AsynchronousShutdownObjectContainerImplTest::OnShutdownComplete,
base::Unretained(this)));
}
......
......@@ -26,7 +26,7 @@ class CrashRecoveryManager {
// This function should only be called during the initialization of
// TetherComponent.
virtual void RestorePreCrashStateIfNecessary(
const base::Closure& on_restoration_finished) = 0;
base::OnceClosure on_restoration_finished) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(CrashRecoveryManager);
......
......@@ -55,7 +55,7 @@ CrashRecoveryManagerImpl::CrashRecoveryManagerImpl(
CrashRecoveryManagerImpl::~CrashRecoveryManagerImpl() = default;
void CrashRecoveryManagerImpl::RestorePreCrashStateIfNecessary(
const base::Closure& on_restoration_finished) {
base::OnceClosure on_restoration_finished) {
ActiveHost::ActiveHostStatus status = active_host_->GetActiveHostStatus();
std::string active_host_device_id = active_host_->GetActiveHostDeviceId();
std::string wifi_network_guid = active_host_->GetWifiNetworkGuid();
......@@ -65,7 +65,7 @@ void CrashRecoveryManagerImpl::RestorePreCrashStateIfNecessary(
// There was no active Tether session, so either the last TetherComponent
// shutdown occurred normally (i.e., without a crash), or it occurred due
// to a crash and there was no active host at the time of the crash.
on_restoration_finished.Run();
std::move(on_restoration_finished).Run();
return;
}
......@@ -79,16 +79,17 @@ void CrashRecoveryManagerImpl::RestorePreCrashStateIfNecessary(
PA_LOG(WARNING) << "Browser crashed while Tether connection attempt was in "
<< "progress. Abandoning connection attempt.";
active_host_->SetActiveHostDisconnected();
on_restoration_finished.Run();
std::move(on_restoration_finished).Run();
return;
}
RestoreConnectedState(on_restoration_finished, active_host_device_id,
tether_network_guid, wifi_network_guid);
RestoreConnectedState(std::move(on_restoration_finished),
active_host_device_id, tether_network_guid,
wifi_network_guid);
}
void CrashRecoveryManagerImpl::RestoreConnectedState(
const base::Closure& on_restoration_finished,
base::OnceClosure on_restoration_finished,
const std::string& active_host_device_id,
const std::string& tether_network_guid,
const std::string& wifi_network_guid) {
......@@ -106,7 +107,7 @@ void CrashRecoveryManagerImpl::RestoreConnectedState(
<< "but the scan result for the active host was lost. Setting "
<< "the active host to DISCONNECTED.";
active_host_->SetActiveHostDisconnected();
on_restoration_finished.Run();
std::move(on_restoration_finished).Run();
return;
}
......@@ -127,7 +128,7 @@ void CrashRecoveryManagerImpl::RestoreConnectedState(
<< "connection is no longer present. Setting the active host "
<< "to DISCONNECTED.";
active_host_->SetActiveHostDisconnected();
on_restoration_finished.Run();
std::move(on_restoration_finished).Run();
return;
}
......@@ -138,13 +139,13 @@ void CrashRecoveryManagerImpl::RestoreConnectedState(
network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork(
tether_network_guid, wifi_network_guid);
active_host_->GetActiveHost(
base::Bind(&CrashRecoveryManagerImpl::OnActiveHostFetched,
weak_ptr_factory_.GetWeakPtr(), on_restoration_finished));
active_host_->GetActiveHost(base::BindOnce(
&CrashRecoveryManagerImpl::OnActiveHostFetched,
weak_ptr_factory_.GetWeakPtr(), std::move(on_restoration_finished)));
}
void CrashRecoveryManagerImpl::OnActiveHostFetched(
const base::Closure& on_restoration_finished,
base::OnceClosure on_restoration_finished,
ActiveHost::ActiveHostStatus active_host_status,
base::Optional<multidevice::RemoteDeviceRef> active_host,
const std::string& tether_network_guid,
......@@ -172,7 +173,7 @@ void CrashRecoveryManagerImpl::OnActiveHostFetched(
active_host /* new_active_host */,
tether_network_guid /* new_tether_network_guid */,
wifi_network_guid /* new_wifi_network_guid */);
on_restoration_finished.Run();
std::move(on_restoration_finished).Run();
}
} // namespace tether
......
......@@ -48,7 +48,7 @@ class CrashRecoveryManagerImpl : public CrashRecoveryManager {
// CrashRecoveryManager:
void RestorePreCrashStateIfNecessary(
const base::Closure& on_restoration_finished) override;
base::OnceClosure on_restoration_finished) override;
protected:
CrashRecoveryManagerImpl(NetworkStateHandler* network_state_handler,
......@@ -56,12 +56,12 @@ class CrashRecoveryManagerImpl : public CrashRecoveryManager {
HostScanCache* host_scan_cache);
private:
void RestoreConnectedState(const base::Closure& on_restoration_finished,
void RestoreConnectedState(base::OnceClosure on_restoration_finished,
const std::string& active_host_device_id,
const std::string& tether_network_guid,
const std::string& wifi_network_guid);
void OnActiveHostFetched(
const base::Closure& on_restoration_finished,
base::OnceClosure on_restoration_finished,
ActiveHost::ActiveHostStatus active_host_status,
base::Optional<multidevice::RemoteDeviceRef> active_host,
const std::string& tether_network_guid,
......
......@@ -101,8 +101,8 @@ class CrashRecoveryManagerImplTest : public testing::Test {
void StartRestoration() {
crash_recovery_manager_->RestorePreCrashStateIfNecessary(
base::Bind(&CrashRecoveryManagerImplTest::OnRestorationFinished,
base::Unretained(this)));
base::BindOnce(&CrashRecoveryManagerImplTest::OnRestorationFinished,
base::Unretained(this)));
}
void OnRestorationFinished() { is_restoration_finished_ = true; }
......
......@@ -63,8 +63,8 @@ void DisconnectTetheringRequestSenderImpl::SendDisconnectRequestToDevice(
num_pending_host_fetches_++;
tether_host_fetcher_->FetchTetherHost(
device_id,
base::Bind(&DisconnectTetheringRequestSenderImpl::OnTetherHostFetched,
weak_ptr_factory_.GetWeakPtr(), device_id));
base::BindOnce(&DisconnectTetheringRequestSenderImpl::OnTetherHostFetched,
weak_ptr_factory_.GetWeakPtr(), device_id));
}
bool DisconnectTetheringRequestSenderImpl::HasPendingRequests() {
......
......@@ -101,9 +101,10 @@ void FakeActiveHost::SetActiveHost(ActiveHostStatus active_host_status,
tether_network_guid_ = tether_network_guid;
wifi_network_guid_ = wifi_network_guid;
GetActiveHost(base::Bind(&FakeActiveHost::SendActiveHostChangedUpdate,
base::Unretained(this), old_status, old_device_id,
old_tether_network_guid, old_wifi_network_guid));
GetActiveHost(base::BindOnce(&FakeActiveHost::SendActiveHostChangedUpdate,
base::Unretained(this), old_status,
old_device_id, old_tether_network_guid,
old_wifi_network_guid));
}
} // namespace tether
......
......@@ -9,18 +9,17 @@ namespace chromeos {
namespace tether {
FakeAsynchronousShutdownObjectContainer::
FakeAsynchronousShutdownObjectContainer(
const base::Closure& deletion_callback)
: deletion_callback_(deletion_callback) {}
FakeAsynchronousShutdownObjectContainer(base::OnceClosure deletion_callback)
: deletion_callback_(std::move(deletion_callback)) {}
FakeAsynchronousShutdownObjectContainer::
~FakeAsynchronousShutdownObjectContainer() {
deletion_callback_.Run();
std::move(deletion_callback_).Run();
}
void FakeAsynchronousShutdownObjectContainer::Shutdown(
const base::Closure& shutdown_complete_callback) {
shutdown_complete_callback_ = shutdown_complete_callback;
base::OnceClosure shutdown_complete_callback) {
shutdown_complete_callback_ = std::move(shutdown_complete_callback);
}
TetherHostFetcher*
......
......@@ -21,11 +21,11 @@ class FakeAsynchronousShutdownObjectContainer
public:
// |deletion_callback| will be invoked when the object is deleted.
FakeAsynchronousShutdownObjectContainer(
const base::Closure& deletion_callback = base::DoNothing());
base::OnceClosure deletion_callback = base::DoNothing());
~FakeAsynchronousShutdownObjectContainer() override;
base::Closure& shutdown_complete_callback() {
return shutdown_complete_callback_;
base::OnceClosure TakeShutdownCompleteCallback() {
return std::move(shutdown_complete_callback_);
}
void set_tether_host_fetcher(TetherHostFetcher* tether_host_fetcher) {
......@@ -48,7 +48,7 @@ class FakeAsynchronousShutdownObjectContainer
}
// AsynchronousShutdownObjectContainer:
void Shutdown(const base::Closure& shutdown_complete_callback) override;
void Shutdown(base::OnceClosure shutdown_complete_callback) override;
TetherHostFetcher* tether_host_fetcher() override;
DisconnectTetheringRequestSender* disconnect_tethering_request_sender()
override;
......@@ -56,8 +56,8 @@ class FakeAsynchronousShutdownObjectContainer
WifiHotspotDisconnector* wifi_hotspot_disconnector() override;
private:
base::Closure deletion_callback_;
base::Closure shutdown_complete_callback_;
base::OnceClosure deletion_callback_;
base::OnceClosure shutdown_complete_callback_;
TetherHostFetcher* tether_host_fetcher_ = nullptr;
DisconnectTetheringRequestSender* disconnect_tethering_request_sender_ =
......
......@@ -13,8 +13,8 @@ FakeCrashRecoveryManager::FakeCrashRecoveryManager() = default;
FakeCrashRecoveryManager::~FakeCrashRecoveryManager() = default;
void FakeCrashRecoveryManager::RestorePreCrashStateIfNecessary(
const base::Closure& on_restoration_finished) {
on_restoration_finished_callback_ = on_restoration_finished;
base::OnceClosure on_restoration_finished) {
on_restoration_finished_callback_ = std::move(on_restoration_finished);
}
} // namespace tether
......
......@@ -19,16 +19,16 @@ class FakeCrashRecoveryManager : public CrashRecoveryManager {
FakeCrashRecoveryManager();
~FakeCrashRecoveryManager() override;
base::Closure& on_restoration_finished_callback() {
return on_restoration_finished_callback_;
base::OnceClosure TakeOnRestorationFinishedCallback() {
return std::move(on_restoration_finished_callback_);
}
// CrashRecoveryManager:
void RestorePreCrashStateIfNecessary(
const base::Closure& on_restoration_finished) override;
base::OnceClosure on_restoration_finished) override;
private:
base::Closure on_restoration_finished_callback_;
base::OnceClosure on_restoration_finished_callback_;
DISALLOW_COPY_AND_ASSIGN(FakeCrashRecoveryManager);
};
......
......@@ -9,12 +9,12 @@ namespace chromeos {
namespace tether {
FakeSynchronousShutdownObjectContainer::FakeSynchronousShutdownObjectContainer(
const base::Closure& deletion_callback)
: deletion_callback_(deletion_callback) {}
base::OnceClosure deletion_callback)
: deletion_callback_(std::move(deletion_callback)) {}
FakeSynchronousShutdownObjectContainer::
~FakeSynchronousShutdownObjectContainer() {
deletion_callback_.Run();
std::move(deletion_callback_).Run();
}
ActiveHost* FakeSynchronousShutdownObjectContainer::active_host() {
......
......@@ -21,7 +21,7 @@ class FakeSynchronousShutdownObjectContainer
public:
// |deletion_callback| will be invoked when the object is deleted.
FakeSynchronousShutdownObjectContainer(
const base::Closure& deletion_callback = base::DoNothing());
base::OnceClosure deletion_callback = base::DoNothing());
~FakeSynchronousShutdownObjectContainer() override;
void set_active_host(ActiveHost* active_host) { active_host_ = active_host; }
......@@ -45,7 +45,7 @@ class FakeSynchronousShutdownObjectContainer
TetherDisconnector* tether_disconnector() override;
private:
base::Closure deletion_callback_;
base::OnceClosure deletion_callback_;
ActiveHost* active_host_ = nullptr;
HostScanCache* host_scan_cache_ = nullptr;
......
......@@ -67,7 +67,7 @@ void HostScannerImpl::StartScan() {
return;
is_fetching_hosts_ = true;
tether_host_fetcher_->FetchAllTetherHosts(base::Bind(
tether_host_fetcher_->FetchAllTetherHosts(base::BindOnce(
&HostScannerImpl::OnTetherHostsFetched, weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -41,8 +41,8 @@ void NetworkConfigurationRemover::RemoveNetworkConfigurationByPath(
const std::string& wifi_network_path) {
managed_network_configuration_handler_->RemoveConfiguration(
wifi_network_path,
base::Bind(&RemoveConfigurationSuccessCallback, wifi_network_path),
base::Bind(&RemoveConfigurationFailureCallback, wifi_network_path));
base::BindOnce(&RemoveConfigurationSuccessCallback, wifi_network_path),
base::BindOnce(&RemoveConfigurationFailureCallback, wifi_network_path));
}
} // namespace tether
......
......@@ -74,8 +74,8 @@ void NetworkConnectionHandlerTetherDelegate::DisconnectFromNetwork(
tether_network_guid,
base::BindOnce(&NetworkConnectionHandlerTetherDelegate::OnRequestSuccess,
weak_ptr_factory_.GetWeakPtr(), request_num),
base::Bind(&NetworkConnectionHandlerTetherDelegate::OnRequestError,
weak_ptr_factory_.GetWeakPtr(), request_num),
base::BindOnce(&NetworkConnectionHandlerTetherDelegate::OnRequestError,
weak_ptr_factory_.GetWeakPtr(), request_num),
TetherSessionCompletionLogger::SessionCompletionReason::
USER_DISCONNECTED);
}
......@@ -101,9 +101,9 @@ void NetworkConnectionHandlerTetherDelegate::ConnectToNetwork(
<< ", but there is already an active connection. "
<< "Disconnecting from network with GUID "
<< previous_host_guid << ".";
DisconnectFromNetwork(
previous_host_guid, base::DoNothing(),
base::Bind(&OnFailedDisconnectionFromPreviousHost, previous_host_guid));
DisconnectFromNetwork(previous_host_guid, base::DoNothing(),
base::BindOnce(&OnFailedDisconnectionFromPreviousHost,
previous_host_guid));
}
int request_num = next_request_num_++;
......@@ -114,8 +114,8 @@ void NetworkConnectionHandlerTetherDelegate::ConnectToNetwork(
tether_network_guid,
base::BindOnce(&NetworkConnectionHandlerTetherDelegate::OnRequestSuccess,
weak_ptr_factory_.GetWeakPtr(), request_num),
base::Bind(&NetworkConnectionHandlerTetherDelegate::OnRequestError,
weak_ptr_factory_.GetWeakPtr(), request_num));
base::BindOnce(&NetworkConnectionHandlerTetherDelegate::OnRequestError,
weak_ptr_factory_.GetWeakPtr(), request_num));
}
void NetworkConnectionHandlerTetherDelegate::OnRequestSuccess(int request_num) {
......
......@@ -116,8 +116,8 @@ class NetworkConnectionHandlerTetherDelegateTest : public testing::Test {
guid,
base::BindOnce(&NetworkConnectionHandlerTetherDelegateTest::OnSuccess,
base::Unretained(this)),
base::Bind(&NetworkConnectionHandlerTetherDelegateTest::OnError,
base::Unretained(this)));
base::BindOnce(&NetworkConnectionHandlerTetherDelegateTest::OnError,
base::Unretained(this)));
}
void CallTetherDisconnect(const std::string& guid) {
......@@ -125,8 +125,8 @@ class NetworkConnectionHandlerTetherDelegateTest : public testing::Test {
guid,
base::BindOnce(&NetworkConnectionHandlerTetherDelegateTest::OnSuccess,
base::Unretained(this)),
base::Bind(&NetworkConnectionHandlerTetherDelegateTest::OnError,
base::Unretained(this)));
base::BindOnce(&NetworkConnectionHandlerTetherDelegateTest::OnError,
base::Unretained(this)));
}
void OnSuccess() { result_ = kSuccessResult; }
......
......@@ -159,8 +159,8 @@ TetherComponentImpl::TetherComponentImpl(
synchronous_shutdown_object_container_->active_host(),
synchronous_shutdown_object_container_->host_scan_cache())) {
crash_recovery_manager_->RestorePreCrashStateIfNecessary(
base::Bind(&TetherComponentImpl::OnPreCrashStateRestored,
weak_ptr_factory_.GetWeakPtr()));
base::BindOnce(&TetherComponentImpl::OnPreCrashStateRestored,
weak_ptr_factory_.GetWeakPtr()));
}
TetherComponentImpl::~TetherComponentImpl() = default;
......@@ -218,7 +218,7 @@ void TetherComponentImpl::InitiateShutdown() {
<< "\".";
tether_disconnector->DisconnectFromNetwork(
active_host->GetTetherNetworkGuid(), base::DoNothing(),
base::Bind(&OnDisconnectErrorDuringShutdown),
base::BindOnce(&OnDisconnectErrorDuringShutdown),
GetSessionCompletionReasonFromShutdownReason(shutdown_reason_));
}
......@@ -229,8 +229,8 @@ void TetherComponentImpl::InitiateShutdown() {
// Start the shutdown process for objects which shutdown asynchronously.
asynchronous_shutdown_object_container_->Shutdown(
base::Bind(&TetherComponentImpl::OnShutdownComplete,
weak_ptr_factory_.GetWeakPtr()));
base::BindOnce(&TetherComponentImpl::OnShutdownComplete,
weak_ptr_factory_.GetWeakPtr()));
}
void TetherComponentImpl::OnShutdownComplete() {
......
......@@ -131,8 +131,8 @@ class TetherComponentImplTest : public testing::Test {
fake_tether_disconnector_ = std::make_unique<FakeTetherDisconnector>();
fake_synchronous_container_ = new FakeSynchronousShutdownObjectContainer(
base::Bind(&TetherComponentImplTest::OnSynchronousContainerDeleted,
base::Unretained(this)));
base::BindOnce(&TetherComponentImplTest::OnSynchronousContainerDeleted,
base::Unretained(this)));
fake_synchronous_container_->set_active_host(fake_active_host_.get());
fake_synchronous_container_->set_host_scan_scheduler(
fake_host_scan_scheduler_.get());
......@@ -145,8 +145,8 @@ class TetherComponentImplTest : public testing::Test {
fake_synchronous_container_factory_.get());
fake_asynchronous_container_ = new FakeAsynchronousShutdownObjectContainer(
base::Bind(&TetherComponentImplTest::OnAsynchronousContainerDeleted,
base::Unretained(this)));
base::BindOnce(&TetherComponentImplTest::OnAsynchronousContainerDeleted,
base::Unretained(this)));
fake_asynchronous_container_factory_ =
base::WrapUnique(new FakeAsynchronousShutdownObjectContainerFactory(
fake_asynchronous_container_));
......@@ -173,17 +173,17 @@ class TetherComponentImplTest : public testing::Test {
}
void InvokeCrashRecoveryCallback() {
base::Closure& on_restoration_finished_callback =
fake_crash_recovery_manager_->on_restoration_finished_callback();
base::OnceClosure on_restoration_finished_callback =
fake_crash_recovery_manager_->TakeOnRestorationFinishedCallback();
EXPECT_FALSE(on_restoration_finished_callback.is_null());
on_restoration_finished_callback.Run();
std::move(on_restoration_finished_callback).Run();
}
void InvokeAsynchronousShutdownCallback() {
base::Closure& shutdown_complete_callback =
fake_asynchronous_container_->shutdown_complete_callback();
base::OnceClosure shutdown_complete_callback =
fake_asynchronous_container_->TakeShutdownCompleteCallback();
EXPECT_FALSE(shutdown_complete_callback.is_null());
shutdown_complete_callback.Run();
std::move(shutdown_complete_callback).Run();
}
void OnSynchronousContainerDeleted() {
......@@ -294,7 +294,7 @@ TEST_F(TetherComponentImplTest, TestShutdown_BeforeCrashRecoveryComplete) {
EXPECT_FALSE(was_synchronous_container_deleted_);
EXPECT_FALSE(was_asynchronous_container_deleted_);
EXPECT_TRUE(
fake_asynchronous_container_->shutdown_complete_callback().is_null());
fake_asynchronous_container_->TakeShutdownCompleteCallback().is_null());
InvokeCrashRecoveryCallback();
EXPECT_TRUE(was_synchronous_container_deleted_);
......
......@@ -109,9 +109,9 @@ void TetherConnectorImpl::ConnectToNetwork(
tether_host_fetcher_->FetchTetherHost(
device_id_pending_connection_,
base::Bind(&TetherConnectorImpl::OnTetherHostToConnectFetched,
weak_ptr_factory_.GetWeakPtr(),
device_id_pending_connection_));
base::BindOnce(&TetherConnectorImpl::OnTetherHostToConnectFetched,
weak_ptr_factory_.GetWeakPtr(),
device_id_pending_connection_));
}
bool TetherConnectorImpl::CancelConnectionAttempt(
......@@ -201,8 +201,8 @@ void TetherConnectorImpl::OnSuccessfulConnectTetheringResponse(
wifi_hotspot_connector_->ConnectToWifiHotspot(
ssid_copy, password_copy, active_host_->GetTetherNetworkGuid(),
base::Bind(&TetherConnectorImpl::OnWifiConnection,
weak_ptr_factory_.GetWeakPtr(), remote_device_id));
base::BindOnce(&TetherConnectorImpl::OnWifiConnection,
weak_ptr_factory_.GetWeakPtr(), remote_device_id));
}
void TetherConnectorImpl::OnConnectTetheringFailure(
......@@ -351,7 +351,7 @@ void TetherConnectorImpl::OnWifiConnection(
// crbug.com/761171.
wifi_hotspot_disconnector_->DisconnectFromWifiHotspot(
wifi_network_guid, base::DoNothing(),
base::Bind(&OnDisconnectFromWifiFailure, device_id));
base::BindOnce(&OnDisconnectFromWifiFailure, device_id));
return;
}
......
......@@ -251,8 +251,8 @@ class TetherConnectorImplTest : public testing::Test {
tether_network_guid,
base::BindOnce(&TetherConnectorImplTest::SuccessCallback,
base::Unretained(this)),
base::Bind(&TetherConnectorImplTest::ErrorCallback,
base::Unretained(this)));
base::BindOnce(&TetherConnectorImplTest::ErrorCallback,
base::Unretained(this)));
}
void VerifyConnectTetheringOperationFails(
......
......@@ -73,8 +73,8 @@ class TetherDisconnectorImplTest : public testing::Test {
tether_network_guid,
base::BindOnce(&TetherDisconnectorImplTest::SuccessCallback,
base::Unretained(this)),
base::Bind(&TetherDisconnectorImplTest::ErrorCallback,
base::Unretained(this)),
base::BindOnce(&TetherDisconnectorImplTest::ErrorCallback,
base::Unretained(this)),
session_completion_reason);
}
......
......@@ -43,13 +43,13 @@ class FakePersistentHostScanCache : public FakeHostScanCache,
// MockTimer which invokes a callback in its destructor.
class ExtendedMockTimer : public base::MockOneShotTimer {
public:
explicit ExtendedMockTimer(const base::Closure& destructor_callback)
: destructor_callback_(destructor_callback) {}
explicit ExtendedMockTimer(base::OnceClosure destructor_callback)
: destructor_callback_(std::move(destructor_callback)) {}
~ExtendedMockTimer() override { destructor_callback_.Run(); }
~ExtendedMockTimer() override { std::move(destructor_callback_).Run(); }
private:
base::Closure destructor_callback_;
base::OnceClosure destructor_callback_;
};
class TestTimerFactory : public TimerFactory {
......@@ -80,8 +80,8 @@ class TestTimerFactory : public TimerFactory {
tether_network_guids_for_upcoming_timers_.begin());
ExtendedMockTimer* mock_timer = new ExtendedMockTimer(
base::Bind(&TestTimerFactory::OnActiveTimerDestructor,
base::Unretained(this), guid_for_timer));
base::BindOnce(&TestTimerFactory::OnActiveTimerDestructor,
base::Unretained(this), guid_for_timer));
tether_network_guid_to_timer_map_[guid_for_timer] = mock_timer;
return base::WrapUnique(mock_timer);
......
......@@ -141,8 +141,8 @@ class WifiHotspotDisconnectorImplTest : public testing::Test {
wifi_network_guid,
base::BindOnce(&WifiHotspotDisconnectorImplTest::SuccessCallback,
base::Unretained(this)),
base::Bind(&WifiHotspotDisconnectorImplTest::ErrorCallback,
base::Unretained(this)));
base::BindOnce(&WifiHotspotDisconnectorImplTest::ErrorCallback,
base::Unretained(this)));
}
void OnNetworkConnectionManagerDisconnect() {
......
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