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